1.Controller node安装Compute service
1.1 安装前准备
1.1.1 数据库配置
1.创建 nova_api, nova, nova_cell0, placement数据库
mysql CREATE DATABASE nova_api; CREATE DATABASE nova; CREATE DATABASE nova_cell0; CREATE DATABASE placement;
2.为上述数据库创建用户及授权
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS'; GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS'; GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS'; GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS'; GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS'; GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS'; GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY 'PLACEMENT_DBPASS'; GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'PLACEMENT_DBPASS';
1.1.2 导入环境变量
. admin-openrc
1.1.3 Identity和api配置
1.新建一个nova用户
root@ubuntu-ControllerNode:/home/ubuntu# openstack user create --domain default --password-prompt nova User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 0e4173fb2fea40cab39b719dfd31f49c | | name | nova | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
2.将nova用户设置为admin权限
openstack role add --project service --user nova admin
3.创建nova服务的服务条目(Identity service提供的服务列表)
root@ubuntu-ControllerNode:/home/ubuntu# openstack service create --name nova --description "OpenStack Compute" compute +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Compute | | enabled | True | | id | 8b7ac23d80bc4129a25f2a6e68d089a7 | | name | nova | | type | compute | +-------------+----------------------------------+
4.创建Compute api的访问点
root@ubuntu-ControllerNode:/home/ubuntu# openstack endpoint create --region RegionOne \ > compute public http://controller:8774/v2.1 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 4e092cd93324414eb37f18400f0e9da3 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 8b7ac23d80bc4129a25f2a6e68d089a7 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2.1 | +--------------+----------------------------------+ root@ubuntu-ControllerNode:/home/ubuntu# openstack endpoint create --region RegionOne \ > compute internal http://controller:8774/v2.1 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | e4b8f7e0653544908c91c9cfd76776d0 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 8b7ac23d80bc4129a25f2a6e68d089a7 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2.1 | +--------------+----------------------------------+ root@ubuntu-ControllerNode:/home/ubuntu# openstack endpoint create --region RegionOne \ > compute admin http://controller:8774/v2.1 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 4f7e7e0275644631942508c45b168014 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 8b7ac23d80bc4129a25f2a6e68d089a7 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2.1 | +--------------+----------------------------------+
5.创建placement服务的用户
openstack user create --domain default --password-prompt placement
root@ubuntu-ControllerNode:/home/ubuntu# openstack user create --domain default --password-prompt placement User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 86e0a78c71c64dd0a1e549377678ecc2 | | name | placement | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
6.将placement用户设置为管理员
openstack role add --project service --user placement admin
7.在服务目录中创建Placement API的条目
root@ubuntu-ControllerNode:/home/ubuntu# openstack service create --name placement --description "Placement API" placement +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Placement API | | enabled | True | | id | dca77f1e87a7490a8b82e7ceed16fe0a | | name | placement | | type | placement | +-------------+----------------------------------+
8.创建Placement API的访问链接
root@ubuntu-ControllerNode:/home/ubuntu# openstack endpoint create --region RegionOne placement public http://controller:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | bbb01b7d79ee40398d358c2b4bb134e6 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | dca77f1e87a7490a8b82e7ceed16fe0a | | service_name | placement | | service_type | placement | | url | http://controller:8778 | +--------------+----------------------------------+ root@ubuntu-ControllerNode:/home/ubuntu# openstack endpoint create --region RegionOne placement internal http://controller:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | cd826ab7b53b4de3838e723f4ff1727d | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | dca77f1e87a7490a8b82e7ceed16fe0a | | service_name | placement | | service_type | placement | | url | http://controller:8778 | +--------------+----------------------------------+ root@ubuntu-ControllerNode:/home/ubuntu# openstack endpoint create --region RegionOne placement admin http://controller:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 7ce81328b9724a5f9d5fad256d166429 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | dca77f1e87a7490a8b82e7ceed16fe0a | | service_name | placement | | service_type | placement | | url | http://controller:8778 | +--------------+----------------------------------+
1.2 安装和配置
1.2.1 安装所需软件包
apt install nova-api nova-conductor nova-novncproxy nova-scheduler nova-placement-api
1.2.2 修改/etc/nova/nova.conf
1.修改数据库相关的节,NOVA_DBPASS等替换成之前设置好的
[api_database] # ... connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova_api [database] # ... connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova [placement_database] # ... connection = mysql+pymysql://placement:PLACEMENT_DBPASS@controller/placement
2.配置RabbitMQ访问,RABBIT_PASS
替换成之前设置的
[DEFAULT] # ... transport_url = rabbit://openstack:RABBIT_PASS@controller
3.设置api和keystone token,NOVA_PASS
替换成之前设置的
[api] # ... auth_strategy = keystone [keystone_authtoken] # ... auth_url = http://controller:5000/v3 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = NOVA_PASS
4.设置自身ip并启用网络服务
[DEFAULT] # ... my_ip = 10.0.0.11 [DEFAULT] # ... use_neutron = true firewall_driver = nova.virt.firewall.NoopFirewallDriver
5.配置vnc
[vnc] enabled = true # ... server_listen = $my_ip server_proxyclient_address = $my_ip
6.配置glance api
[glance] # ... api_servers = http://controller:9292
7.设置lock path
[oslo_concurrency] # ... lock_path = /var/lib/nova/tmp
8.删除default节当中的log_dir
[DEFAULT] log_dir = /var/log/nova #删除
9.设置placement的api,其中PLACEMENT_PASS
设置成之前设置的。
[placement] # ... region_name = RegionOne project_domain_name = Default project_name = service auth_type = password user_domain_name = Default auth_url = http://controller:5000/v3 username = placement password = PLACEMENT_PASS
1.2.3.迁移nova-api和placement的数据库
su -s /bin/sh -c "nova-manage api_db sync" nova
1.2.4 注册cell0 数据库
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
1.2.5 创建一个名为cell1的cell
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
1.2.6 迁移nova数据库
su -s /bin/sh -c "nova-manage db sync" nova
1.2.7 确认cell0和cell1是否已注册成功
root@ubuntu-ControllerNode:/home/ubuntu# su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova +-------+--------------------------------------+------------------------------------+-------------------------------------------------+----------+ | Name | UUID | Transport URL | Database Connection | Disabled | +-------+--------------------------------------+------------------------------------+-------------------------------------------------+----------+ | cell0 | 00000000-0000-0000-0000-000000000000 | none:/ | mysql+pymysql://nova:****@controller/nova_cell0 | False | | cell1 | 34ab3fb6-388b-4d1a-99df-1356731d563f | rabbit://openstack:****@controller | mysql+pymysql://nova:****@controller/nova | False | +-------+--------------------------------------+------------------------------------+-------------------------------------------------+----------+
1.2.8 重启全部服务使配置生效
service nova-api restart service nova-scheduler restart service nova-conductor restart service nova-novncproxy restart
2. Compute node安装Compute service
2.1安装与设置
2.1.1 安装所需软件包
apt install nova-compute
2.1.2 修改/etc/nova/nova.conf
1.修改RabbitMQ 配置,RABBIT_PASS
替换成自己的
[DEFAULT] # ... transport_url = rabbit://openstack:RABBIT_PASS@controller
2.修改api和身份认证,NOVA_PASS替换成之前设置的
[api] # ... auth_strategy = keystone [keystone_authtoken] # ... auth_url = http://controller:5000/v3 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = NOVA_PASS
3.修改my_ip ,这个MANAGEMENT_INTERFACE_IP_ADDRESS
要替换成这台compute节点在管理网络中的ip地址,本次搭建中使用的地址为10.0.0.31
。
[DEFAULT] # ... my_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
4.开启network service支持
[DEFAULT] # ... use_neutron = true firewall_driver = nova.virt.firewall.NoopFirewallDriver
5.配置vnc
[vnc] # ... enabled = true server_listen = 0.0.0.0 server_proxyclient_address = $my_ip novncproxy_base_url = http://controller:6080/vnc_auto.html
6.配置glance api
[glance] # ... api_servers = http://controller:9292
7.配置oslo_concurrency的lock path
[oslo_concurrency] # ... lock_path = /var/lib/nova/tmp
8.删除[DEFAULT]节中的log_dir 9.设置placement认证
[placement] # ... region_name = RegionOne project_domain_name = Default project_name = service auth_type = password user_domain_name = Default auth_url = http://controller:5000/v3 username = placement password = PLACEMENT_PASS
2.2 确认安装
1.在compute节点上使用如下命令
egrep -c '(vmx|svm)' /proc/cpuinfo
如果返回结果不是0那么说明你的计算节点cpu支持硬件加速,如果返回结果是0,如下,那么需要额外配置。
root@ubuntu-ComputeNode:/home/ubuntu# egrep -c '(vmx|svm)' /proc/cpuinfo 0 root@ubuntu-ComputeNode:/home/ubuntu#
修改/etc/nova/nova-compute.conf
[libvirt] # ... virt_type = qemu
2.重启服务
service nova-compute restart
3.将计算节点添加到cell数据库中
以下操作均在controller node上执行
1.导入环境变量,确认一下compute节点是否在数据库里
root@ubuntu-ControllerNode:/home/ubuntu# . admin.opensrc root@ubuntu-ControllerNode:/home/ubuntu# openstack compute service list --service nova-compute +----+--------------+--------------------+------+---------+-------+----------------------------+ | ID | Binary | Host | Zone | Status | State | Updated At | +----+--------------+--------------------+------+---------+-------+----------------------------+ | 5 | nova-compute | ubuntu-ComputeNode | nova | enabled | up | 2019-01-10T03:40:20.000000 | +----+--------------+--------------------+------+---------+-------+----------------------------+
2.发现计算节点
su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
注:这个操作需要在每次添加计算节点后都执行一次。如果觉得麻烦也可以在/etc/nova/nova.conf
中添加自动扫描:
[scheduler] discover_hosts_in_cells_interval = 300