1、OpenStackOcata单点部署教程OpenStackOcata版本单点部署姓名: 日期: 1 OpenStack安装环境搭建 CenOS 7初始配置单点虚拟机配置:CPU8核,内存16GB,存储100GB,网卡2块。操作系统:CentOS 7在搭建OpenStack安装环境之前需要初始化centos的系统配置,包括网络、在线更新源、安全三个部分。1.网络两块网卡一块设置为外网访问IP,另一块设置为本地管理网络IP。修改配置文件/etc/sysconfig/network-scripts/ifcfg-xxx(根据网卡名称修改):2.在线更新源备份原有源文件:mv /etc/ /etc/下载
2、网易源文件并更改文件名为:建立缓存并更新:yum clean allyum makecacheyum update3.安全关闭防火墙与selinux:systemctl disable systemctl stop setenforce 0配置文件/etc/selinux/config,将SELINUX设置为disabled。 基础环境配置1.启用OpenStack仓库yum install centos-release-openstack-ocata完成安装:安装OpenStack客户端-yum install python-openstackclient安装selinux安装包-yum i
3、nstall openstack-selinux2.设置内外网IP对应主机名修改配置文件/etc/hosts退出重新登录即可生效数据库安装配置安装相关软件包:yum install mariadb-server python2-PyMySQL编辑配置文件/etc/:启动数据库服务:systemctl enable systemctl start 设置数据库密码:mysql_secure_installation测试登录:mysql u root p4.消息队列RabbitMQ安装与配置安装软件包:yum install rabbitmq-server启用消息队列服务:systemctl ena
4、ble systemctl start 添加opensatck用户:rabbitmqctl add_user openstack PASS设置权限:rabbitmqctl set_permissions openstack .* .* .*安装与配置Memcached的作用为缓存tokens。安装相关软件包:yum install memcached python-memcached配置文件/etc/sysconfig/memcached启动服务:systemctl enable systemctl start 2 Keystone认证服务 概述云安全需要考虑数据安全、身份与访问管理安全、虚拟
5、化安全和基础设施安全四个部分。Keystone为OpenStack中的一个独立的提供安全认证的模块,主要负责OpenStack用户的身份认证、令牌管理、提供访问资源的服务目录,以及基于用户角色的访问控制。在OpenStack整体框架中,Keystone作用类似于服务总线,其他服务需要通过Keystone注册服务端点,其中服务端点为服务的访问点或URL。Keystone几个基本概念:用户通过Keystone访问OpenStack服务的个人、系统或者某个服务,Keystone通过认证信息验证用户请求合法性。角色一个用户所具有的角色,代表其被赋予的权限。服务端点一个可以用来访问某个具体服务的网络地址
6、。令牌服务查询目录 keystone安装与配置1.安装前准备使用root用户登录数据库mysql u root p创建keystone数据库CREATE DATABASE keystone;授权数据库访问GRANT ALL PRIVILEGES ON keystone.* TO keystonelocalhost IDENTIFIED BY PASS;GRANT ALL PRIVILEGES ON keystone.* TO keystone% IDENTIFIED BY PASS;退出数据库组件安装与配置安装相关软件包:yum install openstack-keystone httpd
7、 mod_wsgi修改配置文件/etc/keystone/:databaseconnection = mysql+ = fernet填充认证服务数据库:su -s /bin/sh -c keystone-manage db_sync keystone初始化Fernet key仓库:keystone-manage fernet_setup -keystone-user keystone -keystone-group keystonekeystone-manage credential_setup -keystone-user keystone -keystone-group keystone引
8、导认证服务:keystone-manage bootstrap -bootstrap-password PASS -bootstrap-admin-url -bootstrap-internal-url -bootstrap-public-url -bootstrap-region-id RegionOne Http服务器配置修改配置文件/etc/httpd/conf/:ServerName controller创建链接:ln -s /usr/share/keystone/ /etc/httpd/4.启动服务systemctl enable systemctl start 5.配置管理账户ex
9、portOS_USERNAME=adminexportOS_PASSWORD=PASSexportOS_PROJECT_NAME=adminexportOS_USER_DOMAIN_NAME=DefaultexportOS_PROJECT_DOMAIN_NAME=DefaultexportOS_AUTH_URL=OS_IDENTITY_API_VERSION=3 创建域/项目/用户/角色1.创建service项目openstack project create -domain default -description Service Project service2.创建Demo项目opens
10、tack project create -domain default -description Demo Project demo3.创建Demo用户openstack user create -domain default -password-prompt demo (需输入密码)4.创建demo用户相关的角色openstack role create user5.将角色加入对应的用户和项目中openstack role add -project demo -user demo user keystone功能验证1.关闭token临时认证机制编辑/etc/keystone/:删除以下三个部
11、分中的admin_token_auth2.取消临时环境变量unset OS_AUTH_URL OS_PASSWORD用户token认证openstack -os-auth-url -os-project-domain-name default -os-user-domain-name default -os-project-name admin -os-username admin token issue用户token认证openstack -os-auth-url -os-project-domain-name default -os-user-domain-name default -os
12、-project-name demo -os-username demo token issue 创建客户端认证脚本1.创建文件admin-openrc:exportOS_PROJECT_DOMAIN_NAME=DefaultexportOS_USER_DOMAIN_NAME=DefaultexportOS_PROJECT_NAME=adminexportOS_USERNAME=adminexportOS_PASSWORD=PASSexportOS_AUTH_URL= exportOS_IDENTITY_API_VERSION=3exportOS_IMAGE_API_VERSION=22.创建
13、文件demo-openrc:exportOS_PROJECT_DOMAIN_NAME=DefaultexportOS_USER_DOMAIN_NAME=DefaultexportOS_PROJECT_NAME=demoexportOS_USERNAME=demoexportOS_PASSWORD=PASSexportOS_AUTH_URL= exportOS_IDENTITY_API_VERSION=3exportOS_IMAGE_API_VERSION=23.测试脚本. admin-openrcopenstack token issue3 Glance镜像服务 概述Glance为OpenSt
14、ack提供虚拟机的镜像服务,由glance-api与glance-registry两个服务组成。glance-api是进入Glance的入口,负责接收用户的RESTful请求,再通过后台的存储系统完成镜像的存储与获取。 glance安装与配置1.安装前准备创建glance数据库及后续操作:mysql u root pCREATE DATABASE glance;GRANT ALL PRIVILEGES ON glance.* TO glancelocalhost IDENTIFIED BY PASS;GRANT ALL PRIVILEGES ON glance.* TO glance% IDE
15、NTIFIED BY PASS;2.使用admin认证. admin-openrc3.创建glance用户openstack user create -domain default -password-prompt glance4.将admin角色加入glance用户及service项目openstack role add -project service -user glance admin5.创建glance服务实体openstack service create -name glance -description OpenStack Image image6.创建镜像服务API接入点op
16、enstack endpoint create -region RegionOne image public endpoint create -region RegionOne image internal endpoint create -region RegionOne image admin install openstack-glance(2)编辑文件/etc/glance/databaseconnection = mysql+.auth_uri=controller:11211auth_type=passwordproject_domain_name=defaultuser_doma
17、in_name=defaultproject_name=serviceusername=glancepassword=PASSpaste_deploy#.flavor=keystoneglance_store#.stores=file,httpdefault_store=filefilesystem_store_datadir=/var/lib/glance/images/(3)编辑文件/etc/glance/databaseconnection = mysql+.auth_uri=controller:11211auth_type=passwordproject_domain_name=de
18、faultuser_domain_name=defaultproject_name=serviceusername=glancepassword=PASSpaste_deploy#.flavor=keystone8.填充glance数据库su -s /bin/sh -c glance-manage db_sync glance9.启动服务systemctl enable systemctl start glance功能验证1.使用admin认证. admin-openrc2.下载镜像wget 上传镜像至服务器openstack image create cirros -file -disk-f
19、ormat qcow2 -container-format bare public4.查看镜像是否上传成功openstack image list4 Nova计算服务 概述Nova为OpenStack的计算组件,由API、Compute、Conductor、Scheduler四个核心服务所组成,服务之间通过AMQP消息队列进行通信。API是进入Nova的HTTP接口,Compute和VMM交互运行虚拟机并管理虚拟机的生命周期。Schedular从可用资源池中选择最合适的计算节点来创建新的虚拟机实例,Conductor为数据库的访问提供一层安全保障。虚拟机创建服务流程:首先用户执行novacli
20、ent提供的用于创建虚拟机的命令,API服务监听到novaclient发送的HTTP请求并且将它转换成AMQP消息,通过消息队列(Queue)调用Conductor服务,Conductor服务通过消息队列接受到任务之后,先完成一些准备工作,再通过消息队列告诉Schedular去选择一个满足虚拟机创建要求的主机,Conductor拿到Schedular提供的目标主机之后,会要求Compute服务创建虚拟机。 controller节点安装与配置安装前准备工作:1.添加nova数据库mysql u root -pCREATE DATABASE nova_api;CREATE DATABASE nov
21、a;CREATE DATABASE nova_cell0;GRANT ALL PRIVILEGES ON nova_api.* TO novalocalhost IDENTIFIED BY PASS;GRANT ALL PRIVILEGES ON nova_api.* TO nova% IDENTIFIED BY PASS;GRANT ALL PRIVILEGES ON nova.* TO novalocalhost IDENTIFIED BY PASS;GRANT ALL PRIVILEGES ON nova.* TO nova% IDENTIFIED BY PASS;GRANT ALL P
22、RIVILEGES ON nova_cell0.* TO novalocalhost IDENTIFIED BY PASS;GRANT ALL PRIVILEGES ON nova_cell0.* TO nova% IDENTIFIED BY PASS;2.使用admin认证. admin-openrc3.创建nova用户openstack user create -domain default -password-prompt nova4.将admin角色加给nova用户openstack role add -project service -user nova admin5.创建nova服
23、务实体openstack service create -name nova -description OpenStack Compute compute6.创建计算API服务端点openstack endpoint create -region RegionOne compute public endpoint create -region RegionOne compute internal endpoint create -region RegionOne compute admin user create -domain default -password-prompt placeme
24、nt8.将placement用户添加到service项目及admin角色中openstack role add -project service -user placement admin9.创建placementAPI实体openstack service create -name placement -description Placement API placement10.创建placementAPI服务端点openstack endpoint create -region RegionOne placement public endpoint create -region Regio
25、nOne placement internal endpoint create -region RegionOne placement admin install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api2.修改配置文件/etc/nova/DEFAULT#.enabled_apis=osapi_compute,metadataapi_databa
26、se#.connection=mysql+.connection=mysql+.transport_url=.auth_strategy=keystonekeystone_authtoken#.auth_uri=controller:11211auth_type=passwordproject_domain_name=defaultuser_domain_name=defaultproject_name=serviceusername=novapassword=PASSDEFAULT#.my_ip=.use_neutron=Truefirewall_driver=true#.vncserver
27、_listen=$my_ipvncserver_proxyclient_address=$my_ipglance#.api_servers=.lock_path=/var/lib/nova/tmpplacement#.os_region_name=RegionOneproject_domain_name=Defaultproject_name=serviceauth_type=passworduser_domain_name=Defaultauth_url=placementpassword=PASS3.修改配置文件/etc/httpd/末尾增加: = Requireallgranted If
28、Version Orderallow,deny Allowfromall 4.重启httpd服务systemctl restart 5.填充nova-api数据库su -s /bin/sh -c nova-manage api_db sync nova6.注册cell0数据库su-s/bin/sh-cnova-managecell_v2map_cell0nova7.创建cell1 cellsu-s/bin/sh-cnova-managecell_v2create_cell-name=cell1-verbosenova8.填充nova数据库su-s/bin/sh-cnova-managedbsy
29、ncnova9.验证cell0和cell1nova-manage cell_v2 list_cells10.启动服务systemctl enable systemctl start compute节点安装与配置1.安装与配置compute组件yum install openstack-nova-compute修改文件/etc/nova/DEFAULT# .enabled_apis = osapi_compute,metadataDEFAULT# .transport_url = .auth_strategy = keystonekeystone_authtoken# .auth_uri = = = controll
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1