使用OpenStack Compute来托管和管理云计算系统。OpenStack Compute是基础架构即服务(IaaS)系统的主要部分。主要模块用Python实现。
OpenStack Compute与OpenStack Identity进行身份验证,OpenStack Placement用于资源库存跟踪和选择,OpenStack Image服务用于磁盘和服务器映像,OpenStack Dashboard用于用户和管理界面。图像访问受项目和用户的限制; 配额是按项目限制的(例如,实例数)。OpenStack Compute可以在标准硬件上水平扩展,并将图像下载到启动实例。
https://docs.openstack.org/nova/stein/install/get-started-compute.html
对于nvoa的配置,我们需要从控制节点和计算节点两方面入手,接下来我们先对控制节点进行配置;
1.配置控制器节点,在安装和配置Compute服务之前,必须创建数据库,服务凭据和API端点;
mysql> CREATE DATABASE nova_api;
Query OK, 1 row affected (0.00 sec)
mysql> CREATE DATABASE nova;
Query OK, 1 row affected (0.00 sec)
mysql> CREATE DATABASE nova_cell0;
Query OK, 1 row affected (0.00 sec)
mysql>
2.对刚才创建的数据库进行授权;
mysql> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' \
-> IDENTIFIED BY '123';
Query OK, 0 rows affected, 1 warning (0.09 sec)
mysql> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' \
-> IDENTIFIED BY '123';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \
-> IDENTIFIED BY '123';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \
-> IDENTIFIED BY '123';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' \
-> IDENTIFIED BY '123';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' \
-> IDENTIFIED BY '123';
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql>
3.创建nova用户;(确保自己为admin身份)
[root@sxb1 ~]# openstack user create --domain default --password-prompt nova
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | ea12de2bc5dc4771bead156e5eb1285a |
| name | nova |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
4.将nova用户指定为admin角色;
[root@sxb1 ~]# openstack role add --project service --user nova admin
5.创建nova服务;
[root@sxb1 ~]# openstack service create --name nova \
> --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Compute |
| enabled | True |
| id | 9764c1dc1ae942d3ad34ccfd6c7f25cf |
| name | nova |
| type | compute |
+-------------+----------------------------------+
6.创建相关api(public、internal、admin)
[root@sxb1 ~]# openstack endpoint create --region RegionOne compute public http://192.168.88.101:8774/v2.1^C
[root@sxb1 ~]# openstack endpoint create --region RegionOne compute internal http://192.168.88.101:8774/v2.1^C
[root@sxb1 ~]# openstack endpoint create --region RegionOne compute admin http://192.168.88.101:8774/v2.1^C
7.安装nova相关软件;
yum install openstack-nova-api openstack-nova-conductor \
openstack-nova-novncproxy openstack-nova-scheduler
8.编辑nova配置文件;
[root@sxb1 ~]# vim /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:123@192.168.88.101
my_ip = 192.168.88.101
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api_database]
connection = mysql+pymysql://nova:123@192.168.88.101/nova_api
[database]
connection = mysql+pymysql://nova:123@192.168.88.101/nova
[api]
auth_strategy = keystone
[keystone_authtoken]
auth_url = http://192.168.88.101:5000/v3
memcached_servers = 192.168.88.101:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = 123
9.配置nova,neutron部分;
[root@sxb1 ~]# vim /etc/nova/nova.conf
[vnc]
enabled = true
# ...
server_listen = $my_ip
server_proxyclient_address = $my_ip
[glance]
api_servers = http://192.168.88.101: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://192.168.88.101:5000/v3
username = placement
password = 123
10.初始化nova.api数据库;
[root@sxb1 ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
11.注册cell0数据库;
[root@sxb1 ~]# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
12.创建一个cell1单元格;
[root@sxb1 ~]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
7f435e95-2ab0-41d6-a233-cf5f55c3375c
13.初始化nova数据库;(在这期间可能会出现一些warning的信息,请忽略;)
[root@sxb1 ~]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
14.验证nova cell0和cell1是否正确注册
[root@sxb1 ~]# 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:****@192.168.88.101/nova_cell0 | False |
| cell1 | 7f435e95-2ab0-41d6-a233-cf5f55c3375c | rabbit://openstack:****@192.168.88.101 | mysql+pymysql://nova:****@192.168.88.101/nova | False |
+-------+--------------------------------------+----------------------------------------+-----------------------------------------------------+----------+
15.启动Compute服务并将其配置为在系统引导时启动(可以使用status查看服务状态,如有未启动服务,需要进行解决)
[root@sxb1 ~]# systemctl enable openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
[root@sxb1 ~]# systemctl start openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
到这里我们的控制器节点的nova就算配置完成了,接下来我们进行计算节点nova的配置;
1.在计算节点安装软件;
yum install openstack-nova-compute
2.编辑计算节点nova配置文件;
[root@sxb2 ~]# vim /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:123@192.168.88.101
my_ip = 192.168.88.102 #填写自己主机IP
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api]
auth_strategy = keystone
[keystone_authtoken]
auth_url = http://192.168.88.101:5000/v3
memcached_servers = 192.168.88.101:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = 123
[vnc]
enabled = true
server_listen = 0.0.0.0
server_proxyclient_address = $my_ip
novncproxy_base_url = http://192.168.88.101:6080/vnc_auto.html
[glance]
api_servers = http://192.168.88.101: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://192.168.88.101:5000/v3
username = placement
password = 123
3.确定您的计算节点是否支持虚拟机的硬件加速;(0表示不支持,1、2表示支持)
可以关闭虚拟机,在设置>处理器>开启虚拟化>启动虚拟机
[root@sxb2 ~]# egrep -c '(vmx|svm)' /proc/cpuinfo
1
4.编辑文件中的[libvirt]
部分;
[root@sxb2 ~]# vim /etc/nova/nova.conf
[libvirt]
virt_type = qemu
5.启动Compute服务及其依赖项,并将它们配置为在系统引导时自动启动、查看服务状态;
[root@sxb2 ~]# systemctl enable libvirtd.service openstack-nova-compute.service
[root@sxb2 ~]# systemctl start libvirtd.service openstack-nova-compute.service
[root@sxb2 ~]# systemctl status libvirtd.service openstack-nova-compute.service
我们回到控制器节点进行验证;
1.获取管理员凭据以启用仅管理员CLI命令,然后确认数据库中是否存在计算主机;(确保以admin身份运行)
[root@sxb1 ~]# . admin-openrc
[root@sxb1 ~]# openstack compute service list --service nova-compute
+----+--------------+--------------+------+---------+-------+----------------------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+--------------+--------------+------+---------+-------+----------------------------+
| 5 | nova-compute | sxb2.102.com | nova | enabled | up | 2019-08-27T14:40:26.000000 |
+----+--------------+--------------+------+---------+-------+----------------------------+
2.发现计算主机;
[root@sxb1 ~]# 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': 7f435e95-2ab0-41d6-a233-cf5f55c3375c
Checking host mapping for compute host 'sxb2.102.com': becdce24-e21f-4c35-bca3-88cf6063a5ee
Creating host mapping for compute host 'sxb2.102.com': becdce24-e21f-4c35-bca3-88cf6063a5ee
Found 1 unmapped computes in cell: 7f435e95-2ab0-41d6-a233-cf5f55c3375c
3.列出服务组件以验证每个进程的成功启动和注册;
[root@sxb1 ~]# openstack compute service list
+----+----------------+--------------+----------+---------+-------+----------------------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+----------------+--------------+----------+---------+-------+----------------------------+
| 1 | nova-conductor | sxb1.101.com | internal | enabled | up | 2019-08-27T14:44:25.000000 |
| 2 | nova-scheduler | sxb1.101.com | internal | enabled | up | 2019-08-27T14:44:25.000000 |
| 5 | nova-compute | sxb2.102.com | nova | enabled | up | 2019-08-27T14:44:26.000000 |
+----+----------------+--------------+----------+---------+-------+----------------------------+
[root@sxb1 ~]# openstack catalog list
+-----------+-----------+---------------------------------------------+
| Name | Type | Endpoints |
+-----------+-----------+---------------------------------------------+
| glance | image | RegionOne |
| | | admin: http://192.168.88.101:9292 |
| | | RegionOne |
| | | internal: http://192.168.88.101:9292 |
| | | RegionOne |
| | | public: http://192.168.88.101:9292 |
| | | |
| nova | compute | RegionOne |
| | | admin: http://192.168.88.101:8774/v2.1 |
| | | RegionOne |
| | | internal: http://192.168.88.101:8774/v2.1 |
| | | RegionOne |
| | | public: http://192.168.88.101:8774/v2.1 |
| | | |
| keystone | identity | RegionOne |
| | | admin: http://192.168.88.101:5000/v3/ |
| | | RegionOne |
| | | internal: http://192.168.88.101:5000/v3/ |
| | | RegionOne |
| | | public: http://192.168.88.101:5000/v3/ |
| | | |
| placement | placement | RegionOne |
| | | internal: http://192.168.88.101:8778 |
| | | RegionOne |
| | | public: http://192.168.88.101:8778 |
| | | RegionOne |
| | | admin: http://192.168.88.101:8778 |
| | | |
+-----------+-----------+---------------------------------------------+
4.列出Image服务中的图像以验证与Image服务的连接;(在之前我们下载了一个测试镜像)
[root@sxb1 ~]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 939c5ec7-c8b1-487f-b817-607b874998a0 | cirros | active |
+--------------------------------------+--------+--------+
5.检查单元格和放置API是否正常运行以及其他必要的先决条件是否到位;
[root@sxb1 ~]# nova-status upgrade check
+--------------------------------+
| Upgrade Check Results |
+--------------------------------+
| Check: Cells v2 |
| Result: Success |
| Details: None |
+--------------------------------+
| Check: Placement API |
| Result: Success |
| Details: None |
+--------------------------------+
| Check: Ironic Flavor Migration |
| Result: Success |
| Details: None |
+--------------------------------+
| Check: Request Spec Migration |
| Result: Success |
| Details: None |
+--------------------------------+
| Check: Console Auths |
| Result: Success |
| Details: None |
+--------------------------------+
到这里我们的nova接搭建完成了,下一章我们进行对Networking service-neutron的搭建