placement组件监听的端口号是:8778
nova组件监听的端口号是:6080、8774、8775
其中6080端口号是novncproxy监听的端口号。
1.安装服务组件
yum install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api -y
2.在mariadb中创建nova_api、nova、nova_cell0数据库,创建nova用户、设置密码并授予对这三个数据库的所有操作权限:
mysql -uroot -p
create database nova_api;
create database nova;
create database nova_cell0;
grant all privileges on nova_api.* to 'nova'@'localhost' identified by 'nova' with grant option;
grant all privileges on nova_api.* to 'nova'@'%' identified by 'nova' with grant option;
grant all privileges on nova.* to 'nova'@'localhost' identified by 'nova' with grant option;
grant all privileges on nova.* to 'nova'@'%' identified by 'nova' with grant option;
grant all privileges on nova_cell0.* to 'nova'@'localhost' identified by 'nova' with grant option;
grant all privileges on nova_cell0.* to 'nova'@'%' identified by 'nova' with grant option;
flush privileges;
exit;
3.配置nova组件,以便它可以访问mariadb数据库,在导nova表到数据库之前,一定要先配置这个。
vim /etc/nova/nova.conf
在[api_database]中,添加:
connection = mysql+pymysql://nova:nova@controller1/nova_api
在[database]中,添加:
connection = mysql+pymysql://nova:nova@controller1/nova
保存退出。
3.将nova_api组件的表导入到mariadb的nova_api数据库中
su -s /bin/sh -c "nova-manage api_db sync" nova
查看nova_api数据库,我的有32张表。
4.将nova组件的表导入到mariadb的nova数据库中
su -s /bin/sh -c "nova-manage db sync" nova
查看nova数据库,我的有110张表。
可能会有一个警告:WARNING: cell0 mapping not found - not syncing cell0.解决办法在第五步。这个报错是从N版开始新增的cell功能。
5.注册nova_cell0数据库并创建cell1
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
查看nova_cell0,我的有110张表,和nova数据库中的表一摸一样。
创建cell1:
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
6.在keystone服务中,为nova和placement创建用户,并授予权限:
为nova创建用户并授予权限:
openstack user create --domain default --password-prompt nova #回车会要求设置密码,我设置的密码是nova
openstack role add --project service --user nova admin
为placement创建用户并授予权限:
openstack user create --domain default --password-prompt placement #回车会要求设置密码,我设置的密码是placement
openstack role add --project service --user placement admin
7.配置nova和placement服务组件向keystone服务组件请求token:
配置nova组件向keystone服务请求token:
vim /etc/nova/nova.conf
在[api]下,添加:
auth_strategy = keystone
在[keystone_authtoken]下,添加:
auth_url = http://controller1:5000/v3
memcached_servers = controller1:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova
配置placement服务组件向keystone服务组件请求token:
在[placement]下,添加:
os_region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller1:5000/v3
username = placement
password = placement
保存退出。
8.配置nova启用计算和元数据API
vim /etc/nova/nova.conf
在[DEFAULT]下,添加:
enabled_apis = osapi_compute,metadata
保存退出。
9.在keystone中为nova和placement分别创建服务实体和API端点
为nova创建服务实体和API端点:
openstack service create --name nova --description "OpenStack Compute" compute
openstack endpoint create --region RegionOne compute public http://controller1:8774/v2.1
openstack endpoint create --region RegionOne compute internal http://controller1:8774/v2.1
openstack endpoint create --region RegionOne compute admin http://controller1:8774/v2.1
为placement创建服务实体和API端点:
openstack service create --name placement --description "Placement API" placement
openstack endpoint create --region RegionOne placement public http://controller1:8778
openstack endpoint create --region RegionOne placement internal http://controller1:8778
openstack endpoint create --region RegionOne placement admin http://controller1:8778
10.配置nova访问RabbitMQ 消息队列
vim /etc/nova/nova.conf
在[DEFAULT]下,添加:
transport_url = rabbit://openstack:123456@controller1
保存退出。
11.启动nova支持网络服务
vim /etc/nova/nova.conf
在[DEFAULT]下,添加:
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
保存退出。
12.配置VNC代理
vim /etc/nova/nova.conf
在[DEFAULT]下,添加:
my_ip = 192.168.0.10
在[vnc]下,添加:
enabled = true
server_listen = $my_ip
server_proxyclient_address = $my_ip
保存退出
13.指定glance服务API的位置
vim /etc/nova/nova.conf
在[glance]下,添加:
api_servers = http://controller1:9292
保存退出。
14.配置oslo_concurrency锁定路径
vim /etc/nova/nova.conf
在[oslo_concurrency]下,添加:
lock_path = /var/lib/nova/tmp
保存退出。
15.由于软件包的一个bug,需要在/etc/httpd/conf.d/00-nova-placement-api.conf文件中添加如下配置,来启用对Placement API的访问:
vim /etc/httpd/conf.d/00-nova-placement-api.conf
在 ErrorLogFormat "%M" 这行之后,粘贴下面的内容:
<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny Allow from all
</IfVersion>
</Directory>
保存退出。
16.启动服务
重启httpd服务:systemctl restart httpd #httpd一定要重启,因为placement服务是通过httpd启动的。
启动nova服务并设置开机自启:
systemctl enable openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
systemctl start openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
将上面用到的配置汇总一下:
vim /etc/nova/nova.conf
[api_database]
connection = mysql+pymysql://nova:nova@controller1/nova_api
[database]
connection = mysql+pymysql://nova:nova@controller1/nova
[api]
auth_strategy = keystone
[keystone_authtoken]
auth_url = http://controller1:5000/v3
memcached_servers = controller1:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova
[placement]
os_region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller1:5000/v3
username = placement
password = placement
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:123456@controller1
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
my_ip = 192.168.0.10
[vnc]
enabled = true
server_listen = $my_ip
server_proxyclient_address = $my_ip
[glance]
api_servers = http://controller1:9292
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
该启动的服务都已经验证成功启动了。本篇初版到此结束。