OpenStack 安装:nova服务

时间:2023-03-08 16:26:51

上一篇介绍了glance,并且成功创建了一个镜像,这一篇介绍Nova。

  • 首先创建Nova用户,需要记得先source环境变量,然后创建Nova用户,并设置密码为nova
[root@linux-node1 ~]# source admin-openstack.sh
[root@linux-node1 ~]# openstack user create --domain default --password-
prompt nova
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 34c7be4d612a45b4830304af29eb010e |
| name | nova |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
  • 给Nova用户添加admin角色
[root@linux-node1 ~]# openstack role add --project service --user nova admin
[root@linux-node1 ~]#
  • 创建Nova服务实例
openstack service create --name nova \
--description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Compute |
| enabled | True |
| id | bf254b3182e04256897e925632f171d0 |
| name | nova |
| type | compute |
+-------------+----------------------------------+
  • 创建NovaAPI服务端点
openstack endpoint create --region RegionOne \
compute public http://192.168.56.11:8774/v2.1

+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 06541267fb014c7f9b0be6748366fdba |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | bf254b3182e04256897e925632f171d0 |
| service_name | nova |
| service_type | compute |
| url | http://192.168.56.11:8774/v2.1 |
+--------------+----------------------------------+openstack endpoint create --region RegionOne \
compute internal http://192.168.56.11:8774/v2.1

+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | d9da327e665645fb9766dea107e13bf1 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | bf254b3182e04256897e925632f171d0 |
| service_name | nova |
| service_type | compute |
| url | http://192.168.56.11:8774/v2.1 |
+--------------+----------------------------------+openstack endpoint create --region RegionOne \
compute admin http://192.168.56.11:8774/v2.1

+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 805cd45ded6841d0acd3335ccfdc29ef |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | bf254b3182e04256897e925632f171d0 |
| service_name | nova |
| service_type | compute |
| url | http://192.168.56.11:8774/v2.1 |
+--------------+----------------------------------+
  • 创建placement服务,并将密码设置为placement
[root@linux-node1 ~]# openstack user create --domain default --password-prompt placement
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 27080769990347169fdc6bf81fe9ebd1 |
| name | placement |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
  • 给placement用户添加admin角色
[root@linux-node1 ~]# openstack role add --project service --user placement admin
  • 在服务目录中创建placement API实例
[root@linux-node1 ~]# openstack service create --name placement --description "Placement API" placement
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Placement API |
| enabled | True |
| id | 344d25c79f1b412cb0c5958bd8242b2c |
| name | placement |
| type | placement |
+-------------+----------------------------------+
  • 创建placement API 服务端点
[root@linux-node1 ~]# openstack endpoint create --region RegionOne placement public http://192.168.56.11:8778
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | a70af939c7ed4d899da5675ade2b3a33 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 344d25c79f1b412cb0c5958bd8242b2c |
| service_name | placement |
| service_type | placement |
| url | http://192.168.56.11:8778 |
+--------------+----------------------------------+
[root@linux-node1 ~]# openstack endpoint create --region RegionOne placement internal http://192.168.56.11:877
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | cfb1efaae8bd4022b4d0b8aebb286935 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 344d25c79f1b412cb0c5958bd8242b2c |
| service_name | placement |
| service_type | placement |
| url | http://192.168.56.11:8778 |
+--------------+----------------------------------+
[root@linux-node1 ~]# openstack endpoint create --region RegionOne placement admin http://192.168.56.11:8778
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 48718fc25ef344b2a20622d091387f9c |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 344d25c79f1b412cb0c5958bd8242b2c |
| service_name | placement |
| service_type | placement |
| url | http://192.168.56.11:8778 |
+--------------+----------------------------------+
  • 验证Nova与placement服务是否创建
[root@linux-node1 ~]# openstack endpoint list
+----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+
| ID | Region | Service Name | Service Type | Enabled | Interface | URL |
+----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+
| 06541267fb014c7f9b0be6748366fdba | RegionOne | nova | compute | True | public | http://192.168.56.11:8774/v2.1 |
| 16964c23761c428b909e9a8617d8146e | RegionOne | keystone | identity | True | internal | http://192.168.56.11:5000/v3/ |
| 223775040aaf460da4f275ebbcd01ae1 | RegionOne | glance | image | True | admin | http://192.168.56.11:9292 |
| 36fb4b5b955d471783a982ea455cf58d | RegionOne | keystone | identity | True | public | http://192.168.56.11:5000/v3/ |
| 47e8d9659f70422487cf600405f518bf | RegionOne | glance | image | True | public | http://192.168.56.11:9292 |
| 48718fc25ef344b2a20622d091387f9c | RegionOne | placement | placement | True | admin | http://192.168.56.11:8778 |
| 62766176a40f43bbbb40d4b986b4400e | RegionOne | keystone | identity | True | admin | http://192.168.56.11:35357/v3/ |
| 805cd45ded6841d0acd3335ccfdc29ef | RegionOne | nova | compute | True | admin | http://192.168.56.11:8774/v2.1 |
| 859936e9632642d58517d9ac6a2c3176 | RegionOne | glance | image | True | internal | http://192.168.56.11:9292 |
| a70af939c7ed4d899da5675ade2b3a33 | RegionOne | placement | placement | True | public | http://192.168.56.11:8778 |
| cfb1efaae8bd4022b4d0b8aebb286935 | RegionOne | placement | placement | True | internal | http://192.168.56.11:8778 |
| d9da327e665645fb9766dea107e13bf1 | RegionOne | nova | compute | True | internal | http://192.168.56.11:8774/v2.1 |
+----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+
  • 编辑/etc/nova/nova.conf,并做如下修改
[DEFAULT]
enabled_apis=osapi_compute,metadata 
transport_url=rabbit://openstack:openstack@192.168.56.11
my_ip = 192.168.56.11
use_neutron=true
firewall_driver=nova.virt.firewall.NoopFirewallDriver
[api]
auth_strategy=keystone 
[api_database]
connection=mysql+pymysql://nova:nova@192.168.56.11/nova_api 
[database]
connection=mysql+pymysql://nova:nova@192.168.56.11/nova 
[glance]
api_servers=192.168.56.11: 
[keystone_authtoken]

auth_uri = http://192.168.56.11:5000 
auth_url = http://192.168.56.11:35357 
memcached_servers = 192.168.56.11:
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://192.168.56.11:35357/v3
username = placement
password = placement
[vnc]
enabled=true
vncserver_listen=192.168.56.11
vncserver_proxyclient_address=192.168.56.11
[oslo_concurrency]
lock_path=/var/lib/nova/tmp 
  • 因为一个packaging bug,必须通过在/etc/httpd/conf.d/00-nova-placement-api.conf添加如下配置来是能placement API的接入:
<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
  • 同步nova-api数据库:
[root@linux-node1 ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
[root@linux-node1 ~]#
  • 登记cell0数据库
[root@linux-node1 ~]# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
[root@linux-node1 ~]#
  • 创建cell1
[root@linux-node1 ~]# nova-manage cell_v2 list_cells
+-------+--------------------------------------+---------------------------------------+----------------------------------------------------+
| Name | UUID | Transport URL | Database Connection |
+-------+--------------------------------------+---------------------------------------+----------------------------------------------------+
| cell0 | ---- | none:/ | mysql+pymysql://nova:****@192.168.56.11/nova_cell0 |
| cell1 | 9f317433-ab20---a9faa94d5825 | rabbit://openstack:****@192.168.56.11 | mysql+pymysql://nova:****@192.168.56.11/nova |
+-------+--------------------------------------+---------------------------------------+----------------------------------------------------+
[root@linux-node1 ~]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
9f317433-ab20---a9faa94d5825
[root@linux-node1 ~]#
  • 同步Nova数据库
[root@linux-node1 ~]# su -s /bin/sh -c "nova-manage db sync" nova
/usr/lib/python2./site-packages/pymysql/cursors.py:: Warning: (,
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./site-packages/pymysql/cursors.py:: Warning: (,
u'Duplicate index `uniq_instances0uuid`. This is deprecated and will be
disallowed in a future release.') result = self._query(query)
  • 验证Nova cell0 和cell1是否登记正确
[root@linux-node1 ~]# nova-manage cell_v2 list_cells
+-------+--------------------------------------+---------------------------------------+----------------------------------------------------+
| Name | UUID | Transport URL | Database Connection |
+-------+--------------------------------------+---------------------------------------+----------------------------------------------------+
| cell0 | ---- | none:/ | mysql+pymysql://nova:****@192.168.56.11/nova_cell0 |
| cell1 | 9f317433-ab20---a9faa94d5825 | rabbit://openstack:****@192.168.56.11 | mysql+pymysql://nova:****@192.168.56.11/nova |
+-------+--------------------------------------+---------------------------------------+----------------------------------------------------+
  • 启动Nova服务并设置为开机启动
systemctl enable openstack-nova-api.service \
openstack-nova-consoleauth.service openstack-nova-scheduler.service \
openstack-nova-conductor.service openstack-nova-
novncproxy.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-
api.service to /usr/lib/systemd/system/openstack-nova-api.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-
consoleauth.service to /usr/lib/systemd/system/openstack-nova-
consoleauth.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-
scheduler.service to /usr/lib/systemd/system/openstack-nova-scheduler.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-
conductor.service to /usr/lib/systemd/system/openstack-nova-conductor.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-
novncproxy.service to /usr/lib/systemd/system/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

在计算节点安装Nova

  • 编辑/etc/nova/nova.conf并作出如下修改

[DEFAULT]
use_neutron=true 
firewall_driver=nova.virt.firewall.NoopFirewallDriver
enabled_apis=osapi_compute,metadata
transport_url=rabbit://openstack:openstack@192.168.56.11
[api]
auth_strategy=keystone 
[glance]
api_servers=192.168.56.11: 

[keystone_authtoken]
auth_uri = http://192.168.56.11:5000 
auth_url = http://192.168.56.11:35357
memcached_servers = 192.168.56.11:
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova
[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://192.168.56.11:35357/v3
username = placement
password = placement
[vnc]
enabled=true 
vncserver_listen=192.168.56.12
vncserver_proxyclient_address=192.168.56.12
novncproxy_base_url=http://192.168.56.11:6080/vnc_auto.html [libvirt]
# 暂时设置为qemu,生产应为
kvm virt_type = qemu
  • 启动Nova服务并设置为开机启动
[root@linux-node2 nova]# systemctl enable libvirtd.service openstack-nova-compute.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-
compute.service to /usr/lib/systemd/system/openstack-nova-compute.service.
[root@linux-node2 nova]# systemctl start libvirtd.service openstack-nova-compute.service
  • 确认计算节点已经在数据库:
[root@linux-node1 ~]# source admin-openstack.sh
[root@linux-node1 ~]# openstack compute service list --service nova-compute
+----+--------------+-------------------------+------+---------+-------+----------------------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+--------------+-------------------------+------+---------+-------+----------------------------+
| | nova-compute | linux-node2.example.com | nova | enabled | up | --12T04::19.000000 |
+----+--------------+-------------------------+------+---------+-------+----------------------------+
  • 发现计算节点
[root@linux-node1 ~]# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
Found cell mappings.
Skipping cell0 since it does not contain hosts.
Getting compute nodes from cell 'cell1': 9f317433-ab20---a9faa94d5825
Found unmapped computes in cell: 9f317433-ab20---a9faa94d5825
Checking host mapping for compute host 'linux-node2.example.com': a9a6dc8c-41f3-4b44-ac5c-2d8b081bc77e
Creating host mapping for compute host 'linux-node2.example.com': a9a6dc8c-41f3-4b44-ac5c-2d8b081bc77e

至此,Nova服务配置完毕