目录
一、OpenStack 环境配置
1.1、虚拟机资源信息
1、控制节点ct
CPU:双核双线程-CPU虚拟化开启
内存:8G 硬盘:300G+300G(CEPH块存储)
双网卡:VM1-(局域网)192.168.127.101 NAT-10.0.0.101
操作系统:Centos 7.6(1810)-最小化安装
2、计算节点c1
CPU:双核双线程-CPU虚拟化开启
内存:8G 硬盘:300G+300G(CEPH块存储)
双网卡:VM1(局域网)-192.168.127.102 NAT-10.0.0.102
操作系统:Centos 7.6(1810)-最小化安装
3、计算节点c2
CPU:双核双线程-CPU虚拟化开启
内存:8G 硬盘:300G+300G(CEPH块存储)
双网卡:VM1(局域网)-192.168.127.103 NAT-10.0.0.103
操作系统:Centos 7.6(1810)-最小化安装
1.2、部署思路
- 一、配置操作系统+OpenStack运行环境
- 二、配置OpenStack平台基础服务(rabbitmq、mariadb、memcache、Apache)
- 三、配置OpenStack keystone组件
- 四、配置OpenStack Glance组件
- 五、配置placement服务
- 六、配置OpenStack Nova组件
- 七、配置OpenStack Neutron组件
- 八、配置OpenStack dashboard组件
- 九、配置OpenStack Cinder组件
- 十、常用云主机操作
资源规划
主机名 | 内存 | 硬盘 | 网卡 | 系统 |
---|---|---|---|---|
CT | 8 | 300+300 | NAT:192.168.127.101 、VM:10.0.0.101 | Centos7.6 |
C1 | 8 | 300+300 | NAT:192.168.127.102 、VM:10.0.0.102 | Centos7.6 |
C2 | 8 | 300+300 | NAT:192.168.127.103 、VM:10.0.0.103 | Centos7.6 |
1.3、基础环境配置
配置项(所有节点):
1、主机名
hostnamectl set-hostname ct
su
hostnamectl set-hostname c1
su
hostnamectl set-hostname c2
su
2、防火墙、核心防护
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
vim /etc/sysconfig/selinux
SELINUX=disabled
3、网卡配置(以ct为例)
vi /etc/sysconfig/network-scripts/ifcfg-ens34
修改、确认一下参数
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.127.101
NETMASK=255.255.255.0
vi /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
IPV4_ROUTE_METRIC=90 ###调由优先级,NAT网卡优先
ONBOOT=yes
IPADDR=10.0.0.101
NETMASK=255.255.0.0
GATEWAY=10.0.0.254
systemctl restart network #重启网卡
配置Hosts
[root@ct ~]# vi /etc/hosts
192.168.127.101 ct
192.168.127.102 c1
192.168.127.103 c2
PS:以上为局域网IP
三台节点做免交互
非对称密钥
[root@ct ~]# ssh-keygen -t rsa
[root@ct ~]# ssh-copy-id ct
[root@ct ~]# ssh-copy-id c1
[root@ct ~]# ssh-copy-id c2
配置DNS(所有节点)
[root@ct ~]# vim /etc/resolv.conf
nameserver 114.114.114.114
控制节点ct时间同步配置
#主机ct
[root@ct ~]# yum install chrony -y
[root@ct ~]# vim /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst #注释掉以下几行
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp6.aliyun.com iburst #添加阿里云时间同步
allow 192.168.127.0/24 #允许127网段同步自己的时间
[root@ct ~]# systemctl enable chronyd
[root@ct ~]# systemctl restart chronyd
#主机c1,c2
[root@c1 ~]# yum install chrony -y
[root@c1 ~]# vi /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst #注释这几行
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ct iburst #同步主机ct
[root@c1 ~]# systemctl enable chronyd
[root@c1 ~]# systemctl restart chronyd
#使用 chronyc sources 命令查询时间同步信息
[root@ct ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 203.107.6.88 2 6 377 10 -1460us[-1354us] +/- 25ms
设置周期性任务
[root@ct ~]# crontab -l
*/2 * * * * /usr/bin/chronyc sources >> /var/log/chronyc.log
安装基础环境依赖包
yum -y install net-tools bash-completion vim gcc gcc-c++ make pcre pcre-devel expat-devel cmake bzip2
yum -y install centos-release-openstack-train #openstack的train版本仓库源安装包
yum -y install python-openstackclient #openstack客户端
yum -y install openstack-selinux #openstack核心防护
yum -y install openstack-utils #openstack管理工具
1.4、配置OpenStack平台基础服务
配置服务(控制节点ct):
1.4.1、安装、配置MariaDB
[root@ct ~]# yum -y install mariadb mariadb-server python2-PyMySQL
#此包用于openstack的控制端连接mysql所需要的模块,如果不安装,则无法连接数据库;此包只安装在控制端
[root@ct ~]# yum -y install libibverbs
###添加MySQL子配置文件,增加如下内容###
[root@ct ~]# vim /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 192.168.100.11
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
[root@ct ~]# vim /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 192.168.100.11 #控制节点局域网地址
default-storage-engine = innodb #默认存储引擎
innodb_file_per_table = on #每张表独立表空间文件
max_connections = 4096 #最大连接数
collation-server = utf8_general_ci #默认字符集
character-set-server = utf8
###开机自启动、开启服务
[root@ct my.cnf.d]# systemctl enable mariadb
[root@ct my.cnf.d]# systemctl start mariadb
###执行MariaDB 安全配置脚本
[root@ct my.cnf.d]# mysql_secure_installation
Enter current password for root (enter for none): #回车
OK, successfully used password, moving on...
Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
... Success!
Disallow root login remotely? [Y/n] N
... skipping.
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
1.4.2、安装RabbitMQ
所有创建虚拟机的指令,控制端都会发送到rabbitmq,node节点监听rabbitmq
[root@ct ~]# yum -y install rabbitmq-server
###配置服务,启动RabbitMQ服务,并设置其开机启动。
[root@ct ~]# systemctl enable rabbitmq-server.service
[root@ct ~]# systemctl start rabbitmq-server.service
###创建消息队列用户,用于controler和node节点连接rabbitmq的认证
[root@ct ~]# rabbitmqctl add_user openstack RABBIT_PASS
Creating user "openstack"
###配置openstack用户的操作权限(正则,配置读写权限)
[root@ct ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/"
#可查看25672和5672 两个端口(5672是Rabbitmq默认端口,25672是Rabbit的测试工具CLI的端口)
选择配置:
###查看rabbitmq插件列表
[root@ct ~]# rabbitmq-plugins list
###开启rabbitmq的web管理界面的插件,端口为15672
[root@ct ~]# rabbitmq-plugins enable rabbitmq_management
###检查端口(25672 5672 15672)
[root@ct my.cnf.d]# ss -natp | grep 5672
LISTEN 0 128 *:25672 *:* users:(("beam.smp",pid=24596,fd=46))
LISTEN 0 128 :::5672 :::* users:(("beam.smp",pid=24596,fd=55))
###可访问10.0.0.101:15672
默认账号密码均为guest
1.4.3、安装memcached
作用:
安装memcached是用于存储session信息;服务身份验证机制使用Memcached来缓存令牌 在登录openstack的dashboard时,会产生一些session信息,这些session信息会存放到memcached中
安装Memcached
[root@ct ~]# yum install -y memcached python-memcached
#python-*模块在OpenStack中起到连接数据库的作用
###修改Memcached配置文件
[root@ct ~]# cat /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 127.0.0.1,::1,ct"
[root@ct ~]# systemctl enable memcached
[root@ct ~]# systemctl start memcached
[root@ct ~]# netstat -nautp | grep 11211
###安装etcd
[root@ct ~]# yum -y install etcd
### 修改etcd配置文件
[root@ct ~]# cd /etc/etcd/
[root@ct etcd]# ls
etcd.conf
[root@ct etcd]# vim etcd.conf
#数据目录位置
#监听其他etcd member的url(2380端口,集群之间通讯,域名为无效值)
#对外提供服务的地址(2379端口,集群内部的通讯端口)
#集群中节点标识(名称)
#该节点成员的URL地址,2380端口:用于集群之间通讯。
#
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.127.101:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.127.101:2379"
ETCD_NAME="ct"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.127.101:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.127.101:2379"
ETCD_INITIAL_CLUSTER="ct=http://192.168.127.101:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01" #集群唯一标识
ETCD_INITIAL_CLUSTER_STATE="new" #初始集群状态,new为静态,若为existing,则表示此ETCD服务将尝试加入已有的集群
若为DNS,则表示此集群将作为被加入的对象
#开机自启动、开启服务,检测端口
[root@ct ~]# systemctl enable etcd.service
[root@ct ~]# systemctl start etcd.service
[root@ct ~]# netstat -anutp |grep 2379
[root@ct ~]# netstat -anutp |grep 2380
二、OpenStack-Keystone组件部署
部署openstack组件时,需先行安装认证服务(keystone),而认证服务是使用Apache运行的,安装完成后才可以创建、管理账号,然后安装镜像服务(glance)、计算服务(nova)、网络服务(neutron)
其中计算服务和网络服务分为管理端和客户端,所以需要在openstack的管理端安装计算服务和网络服务的管理端,在创建虚拟机的node节点上安装计算服务和网络服务的客户端,最后安装dashboard服务,openstack各种组件的API都是通过apache运行的;
openstack的管理端负责创建虚拟机过程的调度
通过openstack管理端创建虚拟机的相关数据最终都会记录到mysql(mariadb)中;node节点没有权限往数据库中写数据,只有控制端有权限,并且node节点与控制端通讯是通过rabbitmq间接通讯,node节点会监听rabbitmq,控制端也会监听rabbitmq,控制端把创建虚拟机的指令发送到rabbitmq,由监听rabbitmq指定队列的node节点接收消息并创建虚拟机;
2.1、创建数据库实例和数据库用户
[root@ct ~]# mysql -u root -p
MariaDB [(none)]> create database keystone;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'KEYSTONE_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'KEYSTONE_DBPASS';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit
2.2、安装、配置keystone、数据库、Apache
安装keystone、httpd、mod_wsgi
mod_wsgi包的作用是让apache能够代理pythone程序的组件;
openstack的各个组件,包括API都是用python写的,但访问的是apache,apache会把请求转发给python去处理,这些包只安装在controler节点
[root@ct ~]# yum -y install openstack-keystone httpd mod_wsgi
[root@ct ~]# cp -a /etc/keystone/keystone.conf{,.bak}
[root@ct ~]# grep -Ev "^$|#" /etc/keystone/keystone.conf.bak > /etc/keystone/keystone.conf
# 通过pymysql模块访问mysql,指定用户名密码、数据库的域名、数据库名
[root@ct ~]# openstack-config --set /etc/keystone/keystone.conf database connection mysql+pymysql://keystone:KEYSTONE_DBPASS@ct/keystone
#指定token的提供者;提供者就是keystone自己本身
[root@ct ~]# openstack-config --set /etc/keystone/keystone.conf token provider fernet
Fernet:一种安全的消息传递格式
# 初始化认证服务数据库
[root@ct ~]# su -s /bin/sh -c "keystone-manage db_sync" keystone
# 初始化fernet 密钥存储库(以下命令会生成两个密钥,生成的密钥放于/etc/keystone/目录下,用于加密数据)
[root@ct keystone]# keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
[root@ct keystone]# keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
# 配置bootstrap身份认证服务
[root@ct ~]# keystone-manage bootstrap --bootstrap-password ADMIN_PASS \
--bootstrap-admin-url http://ct:5000/v3/ \
--bootstrap-internal-url http://ct:5000/v3/ \
--bootstrap-public-url http://ct:5000/v3/ \
--bootstrap-region-id RegionOne #指定一个区域名称
- 此步骤是初始化openstack,会把openstack的admin用户的信息写入到mysql的user表中,以及url等其他信息写入到mysql的相关表中;
- admin-url是管理网(如公有云内部openstack管理网络),用于管理虚拟机的扩容或删除;如果共有网络和管理网是一个网络,则当业务量大时,会造成无法通过openstack的控制端扩容虚拟机,所以需要一个管理网;
#internal-url是内部网络,进行数据传输,如虚拟机访问存储和数据库、zookeeper等中间件,这个网络是不能被外网访问的,只能用于企业内部访问 - public-url是共有网络,可以给用户访问的(如公有云) #但是此环境没有这些网络,则公用同一个网络
- 5000端口是keystone提供认证的端口
- 需要在haproxy服务器上添加一条listen
- 各种网络的url需要指定controler节点的域名,一般是haproxy的vip的域名(高可用模式)
# 配置Apache HTTP服务器
[root@ct ~]# echo "ServerName controller" >> /etc/httpd/conf/httpd.conf
# 创建配置文件
#安装完mod_wsgi包后,会生成 wsgi-keystone.conf 这个文件,文件中配置了虚拟主机及监听了5000端口,mod_wsgi就是python的网关
[root@ct ~]# ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
# 开启服务
[root@ct conf.d]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@ct conf.d]# systemctl start httpd
配置管理员账户的环境变量
这些环境变量用于创建角色和项目使用,但是创建角色和项目需要有认证信息,所以通过环境变量声明用户名和密码等认证信息,欺骗openstack已经登录且通过认证,这样就可以创建项目和角色;也就是把admin用户的验证信息通过声明环境变量的方式传递给openstack进行验证,实现针对openstack的非交互式操作
[root@ct ~]# cat >> ~/.bashrc << EOF
export OS_USERNAME=admin #控制台登陆用户名
export OS_PASSWORD=ADMIN_PASS #控制台登陆密码
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://ct:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
EOF
[root@ct ~]# source ~/.bashrc
通过配置环境变量,可以使用openstack命令进行一些操作,示例:
[root@ct ~]# openstack user list
+----------------------------------+-------+
| ID | Name |
+----------------------------------+-------+
| 249ae3ac27f54111a691e85f2743bb7c | admin |
+----------------------------------+-------+
2.3、创建OpenStack 域、项目、用户和角色
1、创建一个项目(project),创建在指定的domain(域)中,指定描述信息,project名称为service(可使用openstack domain list 查询)
[root@ct ~]# openstack project create --domain default --description "Service Project" service
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Service Project |
| domain_id | default |
| enabled | True |
| id | f872e5498b7d4c53b3480ad008f9029f |
| is_domain | False |
| name | service |
| options | {} |
| parent_id | default |
| tags | [] |
+-------------+----------------------------------
2、创建角色(可使用openstack role list查看)
[root@ct ~]# openstack role create user
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | None |
| domain_id | None |
| id | e1215745429844a5ad953df5ee4289d0 |
| name | user |
| options | {} |
+-------------+----------------------------------+
3、查看openstack 角色列表
[root@ct ~]# openstack role list
+----------------------------------+--------+
| ID | Name |
+----------------------------------+--------+
| 4f18189b0d1a462687b5deb0139d2052 | user | #user:用户
| 8bba366482e3472eaa5a05bf8a899966 | reader |
| 9eebe985b9624f5fafb53fed15d72fcd | member | #member为 租户
| dacde8059d2249cfa93a72652accdc00 | admin | #admin为管理员
+----------------------------------+--------+
4、查看是否可以不指定密码就可以获取到token信息(验证认证服务)
[root@ct ~]# openstack token issue
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires | 2020-12-16T12:47:23+0000 |
| id | gAAAAABf2fPLPoJnyNr1ZAWcDYBSdLn8FWseSvVnUNmYeBE7qK-lyEyCJfcZaxJAxZzNgZTuQmJWza-LMh0YTJXO-TqH1b9v05bHPfrDKrtVdd0QGFE4xB5q-VUipreGgLM87b_JR39YmVnRt3ZrgrygKe-LyjV8rv8_I_1d_BIriDswUObUgPY |
| project_id | b6d3c88567fa402484192e5a62207a44 |
| user_id | b534e0e9cca54e57bce13d66f75b33df |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2.4、配置思路
Keystone 组件是作为OpenStack 集群中统一认证、授权的模块,其核心功能就是针对于User(用户)、Tenant(租户)、Role(角色)、Token(令牌/凭证)的控制(手工编译部署即围绕此功能展开的)
- User:使用 openstack 的用户。
- Tenant:租户,可以理解为一个人、项目或者组织拥有的资源的合集。在一个租户中可以拥有很多个用户,这些用户可以根据权限的划分使用租户中的资源。
- Role:角色,用于分配操作的权限。角色可以被指定给用户,使得该用户获得角色对应的操作权限。
- Token:指的是一串比特值或者字符串,用来作为访问资源的记号。Token 中含有可访问资源的范围和有效时间,token 是用户的一种凭证,需要使用正确的用户名和密码向 Keystone 服务申请才能得到 token。
使用手动部署的模式搭建OpenStack的思路:- 1、分模块部署
- 2、部署keystone模块的基础环境(下载依赖包、组件包、第三方工具/插件)
- 3、创建、开启此模块的功能(以keystone为例,创建并初始化认证数据库、修改配置文件、初始化密钥-fernet格式、配置身份认证服务)
- 4、验证
三、OpenStack-Glance组件部署
3.1、创建数据库实例和数据库用户
[root@ct ~]# mysql -u root -p
MariaDB [(none)]> CREATE DATABASE glance;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit
3.2、创建用户、修改配置文件
3.2.1 创建OpenStack的Glance用户
#创建用户前,需要首先执行管理员环境变量脚本(此处已经在~/.bashrc 中定义过了)
[root@ct ~]# openstack user create --domain default --password GLANCE_PASS glance ###创建glance用户
[root@ct ~]# openstack role add --project service --user glance admin #将glance用户添加到service项目中,并且针对这个项目拥有admin权限;注册glance的API,需要对service项目有admin权限
[root@ct ~]# openstack service create --name glance --description "OpenStack Image" image 创建一个service服务,service名称为glance,类型为image;创建完成后可以通过 openstack service list 查看
#创建镜像服务 API 端点,OpenStack使用三种API端点代表三种服务:admin、internal、public
[root@ct ~]# openstack endpoint create --region RegionOne image public http://ct:9292
[root@ct ~]# openstack endpoint create --region RegionOne image internal http://ct:9292
[root@ct ~]# openstack endpoint create --region RegionOne image admin http://ct:9292
3.2.2 修改 openstack-glance 配置文件
#安装openstack-glance软件包
[root@ct ~]# yum -y install openstack-glance
修改glance配置文件,glance有两个配置文件:/etc/glance/glance-api.conf
/etc/glance/glance-registry.conf
- 添加glance-api.conf配置
[root@ct ~]# cp -a /etc/glance/glance-api.conf{,.bak}
[root@ct ~]# grep -Ev '^$|#' /etc/glance/glance-api.conf.bak > /etc/glance/glance-api.conf
#传入修改的参数
openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers ct:11211
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password GLANCE_PASS
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
[root@ct glance]# cat glance-api.conf
[DEFAULT]
[cinder]
[cors]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
[file]
[glance.store.http.store]
[glance.store.rbd.store]
[glance.store.sheepdog.store]
[glance.store.swift.store]
[glance.store.vmware_datastore.store]
[glance_store]
stores = file,http #存储类型,file:文件,http:基于api调用的方式,把镜像放到其他存储上
default_store = file #默认存储方式
filesystem_store_datadir = /var/lib/glance/images/ ##指定镜像存放的本地目录
[image_format]
[keystone_authtoken]
www_authenticate_uri = http://ct:5000 ##指定认证的keystone的URL
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service #glance用户针对service项目拥有admin权限
username = glance
password = GLANCE_PASS
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
flavor = keystone #指定提供认证的服务器为keystone
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]
- 修改glance-registry.conf 配置文件
#备份、过滤注释信息
cp -a /etc/glance/glance-registry.conf{,.bak}
grep -Ev '^$|#' /etc/glance/glance-registry.conf.bak > /etc/glance/glance-registry.conf
#修改配置文件参数
openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers ct:11211
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password GLANCE_PASS
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-registry.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-registry.conf glance_store default_store file
openstack-config --set /etc/glance/glance-registry.conf glance_store filesystem_store_datadir /var/lib/glance/images/
#修改参数(配置与glance-api.conf相同)
[root@ct glance]# cat glance-registry.conf
[DEFAULT]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
[keystone_authtoken]
www_authenticate_uri = http://ct:5000
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]
3.2.3 初始化数据库、镜像导入验证现象
#初始化glance数据库,生成相关表结构;(不管有多少个controler,只需要初始化一次即可)
su -s /bin/sh -c "glance-manage db_sync" glance
#开启glance服务(此处开启之后会生成存放镜像的目录/var/lib/glance/image)
[root@ct ~]# systemctl enable openstack-glance-api.service
[root@ct ~]# systemctl start openstack-glance-api.service
#查看端口(也可以使用lsof -i:9292 )
[root@ct glance]# netstat -natp | grep 9292
tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 45532/python2
#赋予openstack-glance-api.service服务对存储设备的可写权限(-h:值对符号连接/软链接的文件修改)
[root@ct ~]# chown -hR glance:glance /var/lib/glance/
#先上传cirros镜像到控制节点的/root,然后导入glance,最后查看是否创建成功(安装yum lrzsa)
[root@ct ~]# openstack image create --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public cirros
#查看镜像的两种方式
[root@ct ~]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 51cedac0-9d13-4585-97a6-5b2a37c1013f | cirros | active |
+--------------------------------------+--------+--------+
[root@ct ~]# glance image-list
+--------------------------------------+--------+
| ID | Name |
+--------------------------------------+--------+
| 51cedac0-9d13-4585-97a6-5b2a37c1013f | cirros |
+--------------------------------------+--------+
3.3、 部署思路
OpenStack上创建虚拟机需要镜像支持,所以先行进行部署
部署思路:
- 1、创建数据库、授权
- 2、创建openstack用户、授权、管理
- 3、修改配置文件(glance-api.conf、glance-registry.conf)
- 4、初始化数据库、上传实例镜像
四、OpenStack-Placement组件部署
4.1、创建数据库实例和数据库用户
[root@ct ~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE placement;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY 'PLACEMENT_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'PLACEMENT_DBPASS';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
4.2、创建Placement服务用户和API的endpoint
创建placement用户
[root@ct ~]# openstack user create --domain default --password PLACEMENT_PASS placement
给与placement用户对service项目拥有admin权限
[root@ct ~]# openstack role add --project service --user placement admin
创建一个placement服务,服务类型为placement
[root@ct ~]# openstack service create --name placement --description "Placement API" placement
注册API端口到placement的service中;注册的信息会写入到mysql中
[root@ct ~]# openstack endpoint create --region RegionOne placement public http://ct:8778
[root@ct ~]# openstack endpoint create --region RegionOne placement internal http://ct:8778
[root@ct ~]# openstack endpoint create --region RegionOne placement admin http://ct:8778
安装placement服务
[root@ct ~]# yum -y install openstack-placement-api
● 修改placement配置文件
#修改配置文件
cp -a /etc/placement/placement.conf{,.bak}
grep -Ev '^$|#' /etc/placement/placement.conf.bak > /etc/placement/placement.conf
openstack-config --set /etc/placement/placement.conf placement_database connection mysql+pymysql://placement:PLACEMENT_DBPASS@ct/placement
openstack-config --set /etc/placement/placement.conf api auth_strategy keystone
openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_url http://ct:5000/v3
openstack-config --set /etc/placement/placement.conf keystone_authtoken memcached_servers ct:11211
openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_type password
openstack-config --set /etc/placement/placement.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/placement/placement.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/placement/placement.conf keystone_authtoken project_name service
openstack-config --set /etc/placement/placement.conf keystone_authtoken username placement
openstack-config --set /etc/placement/placement.conf keystone_authtoken password PLACEMENT_PASS
#查看placement配置文件
[root@ct placement]# cat placement.conf
[DEFAULT]
[api]
auth_strategy = keystone
[cors]
[keystone_authtoken]
auth_url = http://ct:5000/v3 #指定keystone地址
memcached_servers = ct:11211 #session信息是缓存放到了memcached中
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = placement
password = PLACEMENT_PASS
[oslo_policy]
[placement]
[placement_database]
connection = mysql+pymysql://placement:PLACEMENT_DBPASS@ct/placement
[profiler]
导入数据库
su -s /bin/sh -c "placement-manage db sync" placement
修改Apache配置文件: 00-placemenct-api.conf(安装完placement服务后会自动创建该文件-虚拟主机配置 )
[root@ct ct]# cat /etc/httpd/conf.d/00-placement-api.conf #安装完placement会自动创建此文件
Listen 8778
<VirtualHost *:8778>
WSGIProcessGroup placement-api
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess placement-api processes=3 threads=1 user=placement group=placement
WSGIScriptAlias / /usr/bin/placement-api
<IfVersion >= 2.4>
ErrorLogFormat "%M"
</IfVersion>
ErrorLog /var/log/placement/placement-api.log
#SSLEngine On
#SSLCertificateFile ...
#SSLCertificateKeyFile ...
</VirtualHost>
Alias /placement-api /usr/bin/placement-api
<Location /placement-api>
SetHandler wsgi-script
Options +ExecCGI
WSGIProcessGroup placement-api
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
</Location>
<Directory /usr/bin> #此处是bug,必须添加下面的配置来启用对placement api的访问,否则在访问apache的
<IfVersion >= 2.4> #api时会报403;添加在文件的最后即可
Require all granted
</IfVersion>
<IfVersion < 2.4> #apache版本;允许apache访问/usr/bin目录;否则/usr/bin/placement-api将不允许被访问
Order allow,deny
Allow from all #允许apache访问
</IfVersion>
</Directory>
● 重新启动apache
[root@ct placement]# systemctl restart httpd
● 测试
① curl 测试访问
[root@ct placement]# curl ct:8778
{"versions": [{"status": "CURRENT", "min_version": "1.0", "max_version": "1.36", "id": "v1.0", "links": [{"href": "", "rel": "self"}]}]}
② 查看端口占用(netstat、lsof)
[root@ct placement]# netstat -natp | grep 8778
tcp6 0 0 :::8778 :::* LISTEN 72994/httpd
③ 检查placement状态
[root@ct placement]# placement-status upgrade check
+----------------------------------+
| Upgrade Check Results |
+----------------------------------+
| Check: Missing Root Provider IDs |
| Result: Success |
| Details: None |
+----------------------------------+
| Check: Incomplete Consumers |
| Result: Success |
| Details: None |
+----------------------------------+
4.3、部署思路
-
Placement提供了placement-apiWSGI脚本,用于与Apache,nginx或其他支持WSGI的Web服务器一起运行服务(通过nginx或apache实现python入口代理)。
-
根据用于部署OpenStack的打包解决方案,WSGI脚本可能位于/usr/bin 或中/usr/local/bin
-
Placement服务是从 S 版本,从nova服务中拆分出来的组件,作用是收集各个node节点的可用资源,把node节点的资源统计写入到mysql,Placement服务会被nova scheduler服务进行调用 Placement服务的监听端口是8778
-
需修改的配置文件:
① placement.conf
主要修改思路:
Keystone认证相关(url、HOST:PORT、域、账号密码等)
对接数据库(位置)
② 00-placement-api.conf
主要修改思路:
Apache权限、访问控制
五、OpenStack-nova组件部署
5.1、nova组件部署位置
【控制节点ct】
nova-api(nova主服务)
nova-scheduler(nova调度服务)
nova-conductor(nova数据库服务,提供数据库访问)
nova-novncproxy(nova的vnc服务,提供实例的控制台)
【计算节点c1、c2】
nova-compute(nova计算服务)
5.2、计算节点Nova服务配置
5.2.1、创建nova数据库,并执行授权操作
[root@ct ~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE nova_api;
MariaDB [(none)]> CREATE DATABASE nova;
MariaDB [(none)]> CREATE DATABASE nova_cell0;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit
5.2.2、管理Nova用户及服务
创建nova用户
[root@ct ~]# openstack user create --domain default --password NOVA_PASS nova
#把nova用户添加到service项目,拥有admin权限
[root@ct ~]# openstack role add --project service --user nova admin
创建nova服务
[root@ct ~]# openstack service create --name nova --description "OpenStack Compute" compute
给Nova服务关联endpoint(端点)
[root@ct ~]# openstack endpoint create --region RegionOne compute public http://ct:8774/v2.1
[root@ct ~]# openstack endpoint create --region RegionOne compute internal http://ct:8774/v2.1
[root@ct ~]# openstack endpoint create --region RegionOne compute admin http://ct:8774/v2.1
5.2.3、安装nova组件(nova-api、nova-conductor、nova-novncproxy、nova-scheduler)
[root@ct ~]# yum -y install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler
● 修改nova配置文件(nova.conf)
[root@ct ~]# cp -a /etc/nova/nova.conf{,.bak}
[root@ct ~]# grep -Ev '^$|#' /etc/nova/nova.conf.bak > /etc/nova/nova.conf
#修改nova.conf
[root@ct ~]# openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis osapi_compute,metadata
[root@ct ~]# openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 192.168.127.101 ####修改为 ct的IP(内部IP)
[root@ct ~]# openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron true
[root@ct ~]# openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
[root@ct ~]# openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@ct
[root@ct ~]# openstack-config --set /etc/nova/nova.conf api_database connection mysql+pymysql://nova:NOVA_DBPASS@ct/nova_api
[root@ct ~]# openstack-config --set /etc/nova/nova.conf database connection mysql+pymysql://nova:NOVA_DBPASS@ct/nova
[root@ct ~]# openstack-config --set /etc/nova/nova.conf placement_database connection mysql+pymysql://placement:PLACEMENT_DBPASS@ct/placement
[root@ct ~]# openstack-config --set /etc/nova/nova.conf api auth_strategy keystone
[root@ct ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://ct:5000/v3
[root@ct ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers ct:11211
[root@ct ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password
[root@ct ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name Default
[root@ct ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name Default
[root@ct ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service
[root@ct ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova
[root@ct ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken password NOVA_PASS
[root@ct ~]# openstack-config --set /etc/nova/nova.conf vnc enabled true
[root@ct ~]# openstack-config --set /etc/nova/nova.conf vnc server_listen ' $my_ip'
[root@ct ~]# openstack-config --set /etc/nova/nova.conf vnc server_proxyclient_address ' $my_ip'
[root@ct ~]# openstack-config --set /etc/nova/nova.conf glance api_servers http://ct:9292
[root@ct ~]# openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp
[root@ct ~]# openstack-config --set /etc/nova/nova.conf placement region_name RegionOne
[root@ct ~]# openstack-config --set /etc/nova/nova.conf placement project_domain_name Default
[root@ct ~]# openstack-config --set /etc/nova/nova.conf placement project_name service
[root@ct ~]# openstack-config --set /etc/nova/nova.conf placement auth_type password
[root@ct ~]# openstack-config --set /etc/nova/nova.conf placement user_domain_name Default
[root@ct ~]# openstack-config --set /etc/nova/nova.conf placement auth_url http://ct:5000/v3
[root@ct ~]# openstack-config --set /etc/nova/nova.conf placement username placement
[root@ct ~]# openstack-config --set /etc/nova/nova.conf placement password PLACEMENT_PASS
#查看nova.conf
[root@ct ~]# cat /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata #指定支持的api类型
my_ip = 192.168.127.101 #定义本地IP
use_neutron = true #通过neutron获取IP地址
firewall_driver = nova.virt.firewall.NoopFirewallDriver
transport_url = rabbit://openstack:RABBIT_PASS@ct #指定连接的rabbitmq
[api]
auth_strategy = keystone #指定使用keystone认证
[api_database]
connection = mysql+pymysql://nova:NOVA_DBPASS@ct/nova_api
[barbican]
[cache]
[cinder]
[compute]
[conductor]
[console]
[consoleauth]
[cors]
[database]
connection = mysql+pymysql://nova:NOVA_DBPASS@ct/nova
[devices]
[ephemeral_storage_encryption]
[filter_scheduler]
[glance]
api_servers = http://ct:9292
[guestfs]
[healthcheck]
[hyperv]
[ironic]
[key_manager]
[keystone]
[keystone_authtoken] #配置keystone的认证信息
auth_url = http://ct:5000/v3 #到此url去认证
memcached_servers = ct:11211 #memcache数据库地址:端口
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = NOVA_PASS
[libvirt]
[metrics]
[mks]
[neutron]
[notifications]
[osapi_v21]
[oslo_concurrency] #指定锁路径
lock_path = /var/lib/nova/tmp #锁的作用是创建虚拟机时,在执行某个操作的时候,需要等此步骤执行完后才能执行下一个步骤,不能并行执行,保证操作是一步一步的执行
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[pci]
[placement]
region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://ct:5000/v3
username = placement
password = PLACEMENT_PASS
[powervm]
[privsep]
[profiler]
[quota]
[rdp]
[remote_debug]
[scheduler]
[serial_console]
[service_user]
[spice]
[upgrade_levels]
[vault]
[vendordata_dynamic_auth]
[vmware]
[vnc] #此处如果配置不正确,则连接不上虚拟机的控制台
enabled = true
server_listen = $my_ip #指定vnc的监听地址
server_proxyclient_address = $my_ip #server的客户端地址为本机地址;此地址是管理网的地址
[workarounds]
[wsgi]
[xenserver]
[xvp]
[zvm]
[placement_database]
connection = mysql+pymysql://placement:PLACEMENT_DBPASS@ct/placement
● 初始化数据库
初始化nova_api数据库
[root@ct ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
● 注册cell0数据库;nova服务内部把资源划分到不同的cell中,把计算节点划分到不同的cell中;openstack内部基于cell把计算节点进行逻辑上的分组
[root@ct ~]# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
#创建cell1单元格;
[root@ct ~]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
#初始化nova数据库;可以通过 /var/log/nova/nova-manage.log 日志判断是否初始化成功
[root@ct ~]# su -s /bin/sh -c "nova-manage db sync" nova
#可使用以下命令验证cell0和cell1是否注册成功
su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova #验证cell0和cell1组件是否注册成功
● 启动Nova服务
[root@ct ~]# systemctl enable openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
[root@ct ~]# systemctl start openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
● 检查nova服务端口
[root@ct ~]# netstat -tnlup|egrep '8774|8775'
[root@ct ~]# curl http://ct:8774
【计算节点配置Nova服务-c1节点】
● 安装nova-compute组件
yum -y install openstack-nova-compute
修改配置文件
#编辑计算节点节点Nova配置文件(c1和c2、只有IP不同)
cp -a /etc/nova/nova.conf{,.bak}
grep -Ev '^$|#' /etc/nova/nova.conf.bak > /etc/nova/nova.conf
openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis osapi_compute,metadata
openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@ct
openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 192.168.127.102 #修改为对应节点的内部IP
openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron true
openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
openstack-config --set /etc/nova/nova.conf api auth_strategy keystone
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://ct:5000/v3
openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers ct:11211
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service
openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova
openstack-config --set /etc/nova/nova.conf keystone_authtoken password NOVA_PASS
openstack-config --set /etc/nova/nova.conf vnc enabled true
openstack-config --set /etc/nova/nova.conf vnc server_listen 0.0.0.0
openstack-config --set /etc/nova/nova.conf vnc server_proxyclient_address ' $my_ip'
openstack-config --set /etc/nova/nova.conf vnc novncproxy_base_url http://192.168.127.101:6080/vnc_auto.html
openstack-config --set /etc/nova/nova.conf glance api_servers http://ct:9292
openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp
openstack-config --set /etc/nova/nova.conf placement region_name RegionOne
openstack-config --set /etc/nova/nova.conf placement project_domain_name Default
openstack-config --set /etc/nova/nova.conf placement project_name service
openstack-config --set /etc/nova/nova.conf placement auth_type password
openstack-config --set /etc/nova/nova.conf placement user_domain_name Default
openstack-config --set /etc/nova/nova.conf placement auth_url http://ct:5000/v3
openstack-config --set /etc/nova/nova.conf placement username placement
openstack-config --set /etc/nova/nova.conf placement password PLACEMENT_PASS
openstack-config --set /etc/nova/nova.conf libvirt virt_type qemu
#配置文件内容如下:
[root@c1 nova]# cat nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:RABBIT_PASS@ct
my_ip = 192.168.100.102
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api]
auth_strategy = keystone
[api_database]
[barbican]
[cache]
[cinder]
[compute]
[conductor]
[console]
[consoleauth]
[cors]
[database]
[devices]
[ephemeral_storage_encryption]
[filter_scheduler]
[glance]
api_servers = http://ct:9292
[guestfs]
[healthcheck]
[hyperv]
[ironic]
[key_manager]
[keystone]
[keystone_authtoken]
auth_url = http://ct:5000/v3
memcached_servers = ct:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = NOVA_PASS
[libvirt]
virt_type = qemu
[metrics]
[mks]
[neutron]
[notifications]
[osapi_v21]
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[pci]
[placement]
region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://ct:5000/v3
username = placement
password = PLACEMENT_PASS
[powervm]
[privsep]
[profiler]
[quota]
[rdp]
[remote_debug]
[scheduler]
[serial_console]
[service_user]
[spice]
[upgrade_levels]
[vault]
[vendordata_dynamic_auth]
[vmware]
[vnc]
enabled = true
server_listen = 0.0.0.0
server_proxyclient_address = $my_ip
novncproxy_base_url = http://192.168.127.101:6080/vnc_auto.html #比较特殊的地方,需要手动添加IP地址,否则之后搭建成功后,无法通过UI控制台访问到内部虚拟机
[workarounds]
[wsgi]
[xenserver]
[xvp]
[zvm]
● 开启服务
systemctl enable libvirtd.service openstack-nova-compute.service
systemctl start libvirtd.service openstack-nova-compute.service
【计算节点-c2】与c1相同(除了IP地址)
【controller节点操作】
● 查看compute节点是否注册到controller上,通过消息队列;需要在controller节点执行
[root@ct ~]# openstack compute service list --service nova-compute
● 扫描当前openstack中有哪些计算节点可用,发现后会把计算节点创建到cell中,后面就可以在cell中创建虚拟机;相当于openstack内部对计算节点进行分组,把计算节点分配到不同的cell中
[root@ct ~]# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
● 默认每次添加个计算节点,在控制端就需要执行一次扫描,这样会很麻烦,所以可以修改控制端nova的主配置文件:
[root@ct ~]# vim /etc/nova/nova.conf
[scheduler]
discover_hosts_in_cells_interval = 300 #每300秒扫描一次
[root@ct ~]# systemctl restart openstack-nova-api.service
● 验证计算节点服务
#检查 nova 的各个服务是否都是正常,以及 compute 服务是否注册成功
[root@ct ~]# openstack compute service list
#查看各个组件的 api 是否正常
[root@ct ~]# openstack catalog list
#查看是否能够拿到镜像
[root@ct ~]# openstack image list
#查看cell的api和placement的api是否正常,只要其中一个有误,后期无法创建虚拟机
[root@ct ~]# nova-status upgrade check
5.3、部署思路
Nova分为控制节点、计算节点
Nova组件核心功能是调度资源,在配置文件中需要体现的部分:指向认证节点位置(URL、ENDPOINT)、调用服务、注册、提供支持等,配置文件中的所有配置参数基本都是围绕此范围进行设置