CentOS7安装OpenStack(Queens版)——(四)nova计算服务

nova计算服务(控制节点

  1. 创建数据库
mysql -uroot -p
CREATE DATABASE nova_api;
CREATE DATABASE nova;
CREATE DATABASE nova_cell0;
  1. 授权访问数据库,设置用户密码为:nova/nova
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'nova';

GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'nova';

GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'nova';

FLUSH PRIVILEGES;
  1. 在keystone上注册nova服务

– 创建nova用户,密码自定义为nova

openstack user create --domain default --password-prompt nova
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | cf5b4a1ac9284483a8601ce212b2150b |
| name                | nova                             |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+
  • 为nova用户的service项目添加admin角色权限,命令无输出
openstack role add --project service --user nova admin
  • 创建nova服务实体
openstack service create --name nova --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Compute                |
| enabled     | True                             |
| id          | 91ef7780ac984136ac0a98a8382f97f0 |
| name        | nova                             |
| type        | compute                          |
+-------------+----------------------------------+
  1. 创建nova API服务端点(endpoint)
openstack endpoint create --region RegionOne compute public http://controller-01:8774/v2.1
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 70039fd4b0434a79a3da46135a594e40 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 91ef7780ac984136ac0a98a8382f97f0 |
| service_name | nova                             |
| service_type | compute                          |
| url          | http://controller-01:8774/v2.1   |
+--------------+----------------------------------+

openstack endpoint create --region RegionOne compute internal http://controller-01:8774/v2.1
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 71103854136c433e80868ed03405b3e3 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 91ef7780ac984136ac0a98a8382f97f0 |
| service_name | nova                             |
| service_type | compute                          |
| url          | http://controller-01:8774/v2.1   |
+--------------+----------------------------------+

openstack endpoint create --region RegionOne compute admin http://controller-01:8774/v2.1
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 54f013b9691d4e7d88e6d49334e7d16b |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 91ef7780ac984136ac0a98a8382f97f0 |
| service_name | nova                             |
| service_type | compute                          |
| url          | http://controller-01:8774/v2.1   |
+--------------+----------------------------------+
  1. 创建Placement服务用户,密码自定义为placement
openstack user create --domain default --password-prompt placement
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 46cd680656344258993928db3717f8ff |
| name                | placement                        |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

  1. 为placement用户的service项目添加admin角色权限,命令无输出
openstack role add --project service --user placement admin
  1. 创建placement API实体服务器
openstack service create --name placement --description "Placement API" placement
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Placement API                    |
| enabled     | True                             |
| id          | 10fc9bc017b04b74b7e2e26336cd29d4 |
| name        | placement                        |
| type        | placement                        |
+-------------+----------------------------------+
  1. 创建Placement API服务端点(endpoint)
openstack endpoint create --region RegionOne placement public http://controller-01:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 1e8c63189fb641e6869ce1b2dc76d43c |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 10fc9bc017b04b74b7e2e26336cd29d4 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller-01:8778        |
+--------------+----------------------------------+

openstack endpoint create --region RegionOne placement internal http://controller-01:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | b5540b49e3cc42e698bdc70949ed939f |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 10fc9bc017b04b74b7e2e26336cd29d4 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller-01:8778        |
+--------------+----------------------------------+

openstack endpoint create --region RegionOne placement admin http://controller-01:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | d3c848643e754bab9abeee225afb4603 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 10fc9bc017b04b74b7e2e26336cd29d4 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller-01:8778        |
+--------------+----------------------------------+

安装nova服务并配置

  1. 安装nova
yum install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api
  1. 编辑/etc/nova/nova.conf修改如下配置,注意修改为对应用户密码
[DEFAULT]
enabled_apis = osapi_compute,metadata

[api_database]
connection = mysql+pymysql://nova:nova@controller-01/nova_api

[database]
connection = mysql+pymysql://nova:nova@controller-01/nova

[DEFAULT]
transport_url = rabbit://openstack:openstack@controller-01

[api]
auth_strategy = keystone

[keystone_authtoken]
auth_url = http://controller-01:5000/v3
memcached_servers = controller-01:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova

[DEFAULT]
my_ip = 192.168.1.10

[DEFAULT]
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver

[vnc]
enabled = true
server_listen = 192.168.1.10
server_proxyclient_address = 192.168.1.10

[glance]
api_servers = http://controller-01:9292

[oslo_concurrency]
lock_path = /var/lib/nova/tmp

[placement]
os_region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller-01:5000/v3
username = placement
password = placement

配置较多,检查修改是否正确

egrep -v "^$|^#" /etc/nova/nova.conf
  • 编辑/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服务
systemctl restart httpd
  1. 初始化同步nova_api数据库,命令结果无输出
su -s /bin/sh -c "nova-manage api_db sync" nova
  • 验证同步是否成功,输出有显示表信息
mysql -unova -pnova nova_api -e "show tables;"
  1. 注册cell0数据库
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
Cell0 is already setup
  1. 创建cell1单元
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
77a4cf9d-b07d-4c30-9f3b-f94a3c06d35c
  1. 初始化同步nova数据库
su -s /bin/sh -c "nova-manage db sync" nova
/usr/lib/python2.7/site-packages/pymysql/cursors.py:166: Warning: (1831, u'Duplicate index `block_device_mapping_instance_uuid_virtual_name_device_name_idx`. This is deprecated and will be disallowed in a future release.')
  result = self._query(query)
/usr/lib/python2.7/site-packages/pymysql/cursors.py:166: Warning: (1831, u'Duplicate index `uniq_instances0uuid`. This is deprecated and will be disallowed in a future release.')
  result = self._query(query)
  • 验证同步是否成功,输出有显示表信息
mysql -unova -pnova nova -e "show tables;"
mysql -unova -pnova nova_cell0 -e "show tables;"
  1. 验证cell0和cell1注册情况
nova-manage cell_v2 list_cells
+-------+--------------------------------------+---------------------------------------+----------------------------------------------------+
|  Name |                 UUID                 |             Transport URL             |                Database Connection                 |
+-------+--------------------------------------+---------------------------------------+----------------------------------------------------+
| cell0 | 00000000-0000-0000-0000-000000000000 |                 none:/                | mysql+pymysql://nova:****@controller-01/nova_cell0 |
| cell1 | 77a4cf9d-b07d-4c30-9f3b-f94a3c06d35c | rabbit://openstack:****@controller-01 |    mysql+pymysql://nova:****@controller-01/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

安装配置计算节点(计算节点

  1. 包安装
yum install openstack-nova-compute
  1. 编辑/etc/nova/nova.conf修改如下配置
[DEFAULT]
enabled_apis = osapi_compute,metadata

[DEFAULT]
transport_url = rabbit://openstack:openstack@controller-01

[api]
auth_strategy = keystone

[keystone_authtoken]
auth_url = http://controller-01:5000/v3
memcached_servers = controller-01:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova

[DEFAULT]
my_ip = 192.168.1.11     # 根据当前计算节点修改IP

[DEFAULT]
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver

[vnc]
enabled = True
server_listen = 0.0.0.0
server_proxyclient_address = $my_ip
novncproxy_base_url = http://controller-01:6080/vnc_auto.html

[glance]
api_servers = http://controller-01:9292

[oslo_concurrency]
lock_path = /var/lib/nova/tmp

[placement]
os_region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller-01:5000/v3
username = placement
password = placement

完成安装

  1. 检查硬件加速
egrep -c '(vmx|svm)' /proc/cpuinfo

结果返回值大于等于1表示节点支持硬件加速,配置/etc/nova/nova.conf文件[libvirt]部分virt_type = kvm
结果返回值等于0表示节点不支持硬件加速,配置/etc/nova/nova.conf文件[libvirt]部分virt_type = qemu

  1. 检查配置修改
egrep -v "^$|#" /etc/nova/nova.conf
  1. 启动并设置开机自启动服务
systemctl enable libvirtd.service openstack-nova-compute.service
systemctl start libvirtd.service openstack-nova-compute.service

添加计算节点到cell数据库(控制节点

  1. 加载环境变量,确认计算主机已在数据库存在
. keystonerc_admin

[root@controller-01 ~]# openstack compute service list --service nova-compute
+----+--------------+------------+------+---------+-------+----------------------------+
| ID | Binary       | Host       | Zone | Status  | State | Updated At                 |
+----+--------------+------------+------+---------+-------+----------------------------+
|  6 | nova-compute | compute-01 | nova | enabled | up    | 2022-12-18T09:35:49.000000 |
+----+--------------+------------+------+---------+-------+----------------------------+
  1. 发现计算主机
[root@controller-01 ~]# 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': 77a4cf9d-b07d-4c30-9f3b-f94a3c06d35c
Checking host mapping for compute host 'compute-01': bc007e34-4003-42d0-8a06-72bc36709e0a
Creating host mapping for compute host 'compute-01': bc007e34-4003-42d0-8a06-72bc36709e0a
Found 1 unmapped computes in cell: 77a4cf9d-b07d-4c30-9f3b-f94a3c06d35c
  1. 设置自动发现计算主机
    以上发现计算主机为手动操作,每次添加计算节点都需要执行操作,也可以通过修改配置参数自动发现计算主机
    编辑/etc/nova/nova.conf文件,修改如下配置
[scheduler]
discover_hosts_in_cells_interval = 300

验证操作(控制节点)

  1. 加载环境变量
. keystonerc_admin
  1. 列表查看安装的nova服务组件是否启动了每个进程
[root@controller-01 ~]# openstack compute service list
+----+------------------+---------------+----------+---------+-------+----------------------------+
| ID | Binary           | Host          | Zone     | Status  | State | Updated At                 |
+----+------------------+---------------+----------+---------+-------+----------------------------+
|  1 | nova-scheduler   | controller-01 | internal | enabled | up    | 2022-12-18T10:30:31.000000 |
|  2 | nova-consoleauth | controller-01 | internal | enabled | up    | 2022-12-18T10:30:30.000000 |
|  3 | nova-conductor   | controller-01 | internal | enabled | up    | 2022-12-18T10:30:29.000000 |
|  6 | nova-compute     | compute-01    | nova     | enabled | up    | 2022-12-18T10:30:33.000000 |
+----+------------------+---------------+----------+---------+-------+----------------------------+
  1. 列表查看API端点在身份认证服务及其验证连接性
[root@controller-01 ~]# openstack catalog list
+-----------+-----------+--------------------------------------------+
| Name      | Type      | Endpoints                                  |
+-----------+-----------+--------------------------------------------+
| placement | placement | RegionOne                                  |
|           |           |   public: http://controller-01:8778        |
|           |           | RegionOne                                  |
|           |           |   internal: http://controller-01:8778      |
|           |           | RegionOne                                  |
|           |           |   admin: http://controller-01:8778         |
|           |           |                                            |
| keystone  | identity  | RegionOne                                  |
|           |           |   internal: http://controller-01:5000/v3/  |
|           |           | RegionOne                                  |
|           |           |   admin: http://controller-01:5000/v3/     |
|           |           | RegionOne                                  |
|           |           |   public: http://controller-01:5000/v3/    |
|           |           |                                            |
| nova      | compute   | RegionOne                                  |
|           |           |   admin: http://controller-01:8774/v2.1    |
|           |           | RegionOne                                  |
|           |           |   public: http://controller-01:8774/v2.1   |
|           |           | RegionOne                                  |
|           |           |   internal: http://controller-01:8774/v2.1 |
|           |           |                                            |
| glance    | image     | RegionOne                                  |
|           |           |   internal: http://controller-01:9292      |
|           |           | RegionOne                                  |
|           |           |   public: http://controller-01:9292        |
|           |           | RegionOne                                  |
|           |           |   admin: http://controller-01:9292         |
|           |           |                                            |
+-----------+-----------+--------------------------------------------+
  1. 列表查看镜像服务在身份认证服务及其验证连接性
[root@controller-01 ~]# openstack image list 
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| 8fe2a430-6e12-4de9-b9e6-202094bd6c2f | cirros | active |
+--------------------------------------+--------+--------+
  1. 检查cell跟placement API工作状态
[root@controller-01 ~]# nova-status upgrade check
Option "os_region_name" from group "placement" is deprecated. Use option "region-name" from group "placement".
+--------------------------------+
| Upgrade Check Results          |
+--------------------------------+
| Check: Cells v2                |
| Result: Success                |
| Details: None                  |
+--------------------------------+
| Check: Placement API           |
| Result: Success                |
| Details: None                  |
+--------------------------------+
| Check: Resource Providers      |
| Result: Success                |
| Details: None                  |
+--------------------------------+
| Check: Ironic Flavor Migration |
| Result: Success                |
| Details: None                  |
+--------------------------------+
| Check: API Service Version     |
| Result: Success                |
| Details: None                  |
+--------------------------------+

提示Option “os_region_name” from group “placement” is deprecated. Use option “region-name” from group “placement”.这是Queens版问题,编辑/etc/nova/nova.conf文件,修改[placement]域下的参数os_region_name = RegionOne为region_name = RegionOne

nova计算服务安装完成。

参考文档

https://docs.openstack.org/queens/index.html

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据