1. 创建compute节点所需的数据库
[root@openstack-controller ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 37
Server version: 10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE nova_api;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> CREATE DATABASE nova;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> CREATE DATABASE nova_cell0;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> CREATE DATABASE placement;
Query OK, 1 row affected (0.00 sec)
授予对这些数据库的访问权限
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' \
-> IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'nova';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY 'placement';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'placement';
Query OK, 0 rows affected (0.00 sec)
2. 切换为管理员身份以使用CLI命令
[root@openstack-controller ~]# source ~/.admin.openstack
3. 创建计算服务认证
# 创建nova用户
[root@openstack-controller ~]# openstack user create --domain default --password-prompt nova
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | e232614bf6ed496d8c5c4ac99cae0da1 |
| name | nova |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
# 授予nova用户管理员身份
[root@openstack-controller ~]# openstack role add --project service --user nova admin
# 创建nova服务实体
[root@openstack-controller ~]# openstack service create --name nova \
--description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Compute |
| enabled | True |
| id | 060d59eac51b4594815603d75a00aba2 |
| name | nova |
| type | compute |
+-------------+----------------------------------+
4. 创建计算API服务端点endpoints
[root@openstack-controller ~]# openstack endpoint create --region RegionOne \
compute public http://192.168.245.137:8774/v2.1
+--------------+-------------------------------------------+
| Field | Value |
+--------------+-------------------------------------------+
| enabled | True |
| id | 3c1caa473bfe4390a11e7177894bcc7b |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 060d59eac51b4594815603d75a00aba2 |
| service_name | nova |
| service_type | compute |
| url | http://controller:8774/v2.1 |
+--------------+-------------------------------------------+
[root@openstack-controller ~]# openstack endpoint create --region RegionOne \
compute internal http://controller:8774/v2.1
+--------------+-------------------------------------------+
| Field | Value |
+--------------+-------------------------------------------+
| enabled | True |
| id | e3c918de680746a586eac1f2d9bc10ab |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 060d59eac51b4594815603d75a00aba2 |
| service_name | nova |
| service_type | compute |
| url | http://controller:8774/v2.1 |
+--------------+-------------------------------------------+
[root@openstack-controller ~]# openstack endpoint create --region RegionOne \
compute admin http://controller:8774/v2.1
+--------------+-------------------------------------------+
| Field | Value |
+--------------+-------------------------------------------+
| enabled | True |
| id | 38f7af91666a47cfb97b4dc790b94424 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 060d59eac51b4594815603d75a00aba2 |
| service_name | nova |
| service_type | compute |
| url | http://controller:8774/v2.1 |
+--------------+-------------------------------------------+
5. 创建Placement服务用户
[root@openstack-controller ~]# openstack user create --domain default --password-prompt placement
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | fa742015a6494a949f67629884fc7ec8 |
| name | placement |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
6. 将Placement用户以管理员身份添加到服务项目中
[root@openstack-controller ~]# openstack role add --project service --user placement admin
7. 在服务目录中创建Placement API实体
[root@openstack-controller ~]# openstack service create --name placement \
--description "Placement API" placement
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Placement API |
| enabled | True |
| id | 2d1a27022e6e4185b86adac4444c495f |
| name | placement |
| type | placement |
+-------------+----------------------------------+
8. 创建Placement API服务端点
[root@openstack-controller ~]# openstack endpoint create --region RegionOne \
placement public http://192.168.245.137:8778
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 2b1b2637908b4137a9c2e0470487cbc0 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 2d1a27022e6e4185b86adac4444c495f |
| service_name | placement |
| service_type | placement |
| url | http://controller:8778 |
+--------------+----------------------------------+
[root@openstack-controller ~]# openstack endpoint create --region RegionOne \
placement internal http://controller:8778
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 02bcda9a150a4bd7993ff4879df971ab |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 2d1a27022e6e4185b86adac4444c495f |
| service_name | placement |
| service_type | placement |
| url | http://controller:8778 |
+--------------+----------------------------------+
[root@openstack-controller ~]# openstack endpoint create --region RegionOne \
placement admin http://controller:8778
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 3d71177b9e0f406f98cbff198d74b182 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 2d1a27022e6e4185b86adac4444c495f |
| service_name | placement |
| service_type | placement |
| url | http://controller:8778 |
+--------------+----------------------------------+
9. 安装包
[root@openstack-controller ~]# yum install openstack-nova-api openstack-nova-conductor \
openstack-nova-console openstack-nova-novncproxy \
openstack-nova-scheduler openstack-nova-placement-api
10. 配置/etc/nova/nova.conf
文件:
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:openstack@controller
my_ip = 172.16.10.2
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api_database]
connection = mysql+pymysql://nova:nova@controller/nova_api
[database]
connection = mysql+pymysql://nova:nova@controller/nova
[placement_database]
connection = mysql+pymysql://placement:placement@controller/placement
[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
[vnc]
enabled = true
server_listen = 192.168.245.137
server_proxyclient_address = 192.168.245.137
[glance]
api_servers = http://controller:9292
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
[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
修改/etc/httpd/conf.d/00-nova-placement-api.conf
文件,添加:
<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</Directory>
重新启动httpd服务
[root@openstack-controller ~]# systemctl restart httpd
[root@openstack-controller ~]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:9191 0.0.0.0:* LISTEN 76350/python2
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 62084/beam.smp
tcp 0 0 172.16.10.2:3306 0.0.0.0:* LISTEN 61962/mysqld
tcp 0 0 172.16.10.2:11211 0.0.0.0:* LISTEN 63270/memcached
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 63270/memcached
tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 76349/python2
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 18939/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 19119/master
tcp6 0 0 :::5000 :::* LISTEN 79942/httpd
tcp6 0 0 :::5672 :::* LISTEN 62084/beam.smp
tcp6 0 0 :::8778 :::* LISTEN 79942/httpd
tcp6 0 0 :::80 :::* LISTEN 79942/httpd
tcp6 0 0 :::22 :::* LISTEN 18939/sshd
tcp6 0 0 ::1:25 :::* LISTEN 19119/master
11. 填充nova-api
和placement
数据库
[root@openstack-controller ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
12. 注册cell0
数据库
[root@openstack-controller ~]# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
13. 创建cell1
cell
[root@openstack-controller ~]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
14. 填充nova数据库
[root@openstack-controller ~]# su -s /bin/sh -c "nova-manage db sync" nova
15. 验证nova cell0和cell1被正确注册
[root@openstack-controller ~]# su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova
+-------+--------------------------------------+
| Name | UUID |
+-------+--------------------------------------+
| cell1 | 109e1d4b-536a-40d0-83c6-5f121b82b650 |
| cell0 | 00000000-0000-0000-0000-000000000000 |
+-------+--------------------------------------+
16. 开启Compute服务并设置为开机即启动
[root@openstack-controller ~]# systemctl enable openstack-nova-api.service \
openstack-nova-consoleauth openstack-nova-scheduler.service \
openstack-nova-conductor.service openstack-nova-novncproxy.service
[root@openstack-controller ~]# systemctl start openstack-nova-api.service \
openstack-nova-consoleauth openstack-nova-scheduler.service \
openstack-nova-conductor.service openstack-nova-novncproxy.service
下面配置Compute节点
1. 安装包
[root@openstack-compute1 ~]# yum install openstack-nova-compute
注意这句话会报两个错,
其中一个错参考https://blog.csdn.net/Qmilumilu/article/details/121330274;
另一个错添加一个yum源即可
[root@openstack-compute1 ~]# cat /etc/yum.repos.d/virt-aliyun.repo
[virt]
name=Vrit Repo on Aliyun
baseurl=https://mirrors.aliyun.com/centos/7/virt/x86_64/kvm-common/
enable=1
gpgcheck=0
2. 配置/etc/nova/nova.conf
文件
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:openstack@controller
my_ip = 172.16.10.11
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[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
[vnc]
enabled = true
server_listen = 0.0.0.0
server_proxyclient_address = $my_ip
novncproxy_base_url = http://controller:6080/vnc_auto.html
[glance]
api_servers = http://controller:9292
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
[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
3. 决定你的计算节点是否支持硬件加速
[root@openstack-compute1 ~]# egrep -c '(vmx|svm)' /proc/cpuinfo
编辑/etc/nova/nova.conf
文件(与官方文档不同)
[libvirt]
virt_type = kvm
cpu_mode=host-passthrough
hw_machine_type = x86_64=pc-i440fx-rhe17.2.0
4. 开启Compute服务并设置为开机即启动
[root@openstack-compute1 ~]# systemctl enable libvirtd.service openstack-nova-compute.service
[root@openstack-compute1 ~]# systemctl start libvirtd.service openstack-nova-compute.service
这时换到controller节点
5. 使用管理员权限,接着确认在数据库中有计算hosts
[root@openstack-controller ~]# source ~/.admin.openstack
[root@openstack-controller ~]# openstack compute service list --service nova-compute
+----+--------------+--------------------+------+---------+-------+------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+--------------+--------------------+------+---------+-------+------------+
| 9 | nova-compute | openstack-compute1 | nova | enabled | down | None |
+----+--------------+--------------------+------+---------+-------+------------+
发现计算hosts
[root@openstack-controller ~]# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
Found 2 cell mappings.
Skipping cell0 since it does not contain hosts.
Getting computes from cell 'cell1': 4ba8d0ac-1809-4f2b-b3a2-570d51ec458e
Checking host mapping for compute host 'openstack-compute1': 323f73f0-f815-4c0a-8d35-36d3957f6149
Creating host mapping for compute host 'openstack-compute1': 323f73f0-f815-4c0a-8d35-36d3957f6149
Found 1 unmapped computes in cell: 4ba8d0ac-1809-4f2b-b3a2-570d51ec458e
注意,每次添加计算节点都需要在控制节点的cell_database
数据库中添加,且需要执行nova-manage cell_v2 discover_hosts --verbose
来注册使用这些新节点,如果想要自动发现,可以通过设置
[scheduler]
discover_hosts_in_cells_interval = 300
让每隔一段时间自动发现注册,但是因为我们节点在测试阶段比较少,所以不用设置时间间隔自动注册,默认值为-1
表示不自动注册
6. 验证操作
1)列出服务组件
[root@openstack-controller ~]# openstack compute service list
+----+------------------+----------------------+----------+---------+-------+----------------------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+------------------+----------------------+----------+---------+-------+----------------------------+
| 1 | nova-consoleauth | openstack-controller | internal | enabled | up | 2022-04-14T15:48:58.000000 |
| 2 | nova-scheduler | openstack-controller | internal | enabled | up | 2022-04-14T15:49:01.000000 |
| 6 | nova-conductor | openstack-controller | internal | enabled | up | 2022-04-14T15:48:55.000000 |
| 9 | nova-compute | openstack-compute1 | nova | enabled | up | 2022-04-14T15:48:59.000000 |
+----+------------------+----------------------+----------+---------+-------+----------------------------
2)列出API端点
[root@openstack-controller ~]# openstack catalog list
+-----------+-----------+--------------------------------------------+
| Name | Type | Endpoints |
+-----------+-----------+--------------------------------------------+
| nova | compute | RegionOne |
| | | public: http://192.168.245.137:8774/v2.1 |
| | | RegionOne |
| | | admin: http://controller:8774/v2.1 |
| | | RegionOne |
| | | internal: http://controller:8774/v2.1 |
| | | |
| keystone | identity | RegionOne |
| | | admin: http://controller:5000/v3/ |
| | | RegionOne |
| | | internal: http://controller:5000/v3/ |
| | | RegionOne |
| | | public: http://192.168.245.137:5000/v3/ |
| | | |
| placement | placement | RegionOne |
| | | admin: http://controller:8778 |
| | | RegionOne |
| | | public: http://192.168.245.137:8778 |
| | | RegionOne |
| | | internal: http://controller:8778 |
| | | |
| glance | image | RegionOne |
| | | admin: http://controller:9292 |
| | | RegionOne |
| | | internal: http://controller:9292 |
| | | RegionOne |
| | | public: http://192.168.245.137:9292 |
| | | |
+-----------+-----------+--------------------------------------------+
3)列出镜像
[root@openstack-controller ~]# openstack image list
+--------------------------------------+-------------+-------------+
| ID | Name | Status |
+--------------------------------------+-------------+-------------+
| 9a76d9f9-9620-4f2e-8c69-6c5691fae163 | cirros | active |
+--------------------------------------+-------------+-------------+
4)查看cells和placement API是否正常工作
[root@openstack-controller ~]# nova-status upgrade check
+---------------------------+
| Upgrade Check Results |
+---------------------------+
| Check: Cells v2 |
| Result: Success |
| Details: None |
+---------------------------+
| Check: Placement API |
| Result: Success |
| Details: None |
+---------------------------+
| Check: Resource Providers |
| Result: Success |
| Details: None |
+---------------------------+
官方文档参见:
https://docs.openstack.org/nova/rocky/install/controller-install-rdo.html
https://docs.openstack.org/nova/rocky/install/compute-install-rdo.html
https://docs.openstack.org/nova/rocky/install/verify.html