Nova 计算服务 (老王笔记)
作者:互联网
Nova 计算服务
控制节点和计算节点1
安装配置控制节点
1、为了创建数据库,必须完成这些步骤:
-
用数据库连接客户端以
root
用户连接到数据库服务器:$ mysql -u root -p
-
创建
nova_api
、nova
和nova_cell0
数数据库:MariaDB [(none)]> CREATE DATABASE nova_api; MariaDB [(none)]> CREATE DATABASE nova; MariaDB [(none)]> CREATE DATABASE nova_cell0;
-
对数据库进行正确的授权:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
用合适的密码代替
NOVA_DBPASS
。 -
退出数据库客户端。
2、要创建服务证书,完成这些步骤:
-
创建
nova
用户:$ openstack user create --domain default --password NOVA_PASS nova
-
给
nova
用户添加admin
角色:$ openstack role add --project service --user nova admin
-
创建
nova
服务实体:$ openstack service create --name nova --description "OpenStack Compute" compute
3、创建 Compute 服务 API 端点 :
$ openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1
$ openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1
$ openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1
4、创建Placement 服务用户
-
创建一个Placement服务用户 密码为
PLACEMENT_PASS
:$ openstack user create --domain default --password PLACEMENT_PASS placement
-
将Placement用户添加到具有管理角色的服务项目中:
$ openstack role add --project service --user placement admin
-
在服务目录中创建Placement API条目:
$ openstack service create --name placement --description "Placement API" placement
-
创建Placement API服务端点:
$ openstack endpoint create --region RegionOne placement public http://controller:8778 $ openstack endpoint create --region RegionOne placement internal http://controller:8778 $ openstack endpoint create --region RegionOne placement admin http://controller:8778
5、安装软件包:
$ yum install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api -y
6、编辑/etc/nova/nova.conf
归档并完成以下操作:
-
在
[DEFAULT]
节中,只启用计算和元数据API:[DEFAULT] enabled_apis = osapi_compute,metadata transport_url = rabbit://openstack:openstack@controller my_ip = 192.168.100.41 use_neutron = True firewall_driver = nova.virt.firewall.NoopFirewallDriver
(用你在
RabbitMQ
中为openstack
选择的密码替换RABBIT_PASS
) -
在
[api_database]
和[database]
各节,配置数据库访问:[api_database] connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova_api [database] connection = mysql+pymysql://nova:NOVA_DBPASS@controller/nova
(用你为 Compute 数据库选择的密码来代替
NOVA_DBPASS
。) -
在
[api]
和[keystone_authtoken]
各节,配置身份服务访问:[api] auth_strategy = keystone [keystone_authtoken] auth_uri = http://controller:5000 auth_url = http://controller:35357 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = NOVA_PASS
(使用你在身份认证服务中设置的
nova
用户的密码替换NOVA_PASS
。) -
在
[vnc]
节中,配置VNC代理以使用控制器节点的管理接口IP地址:[vnc] enabled = true vncserver_listen = $my_ip vncserver_proxyclient_address = $my_ip
-
在
[glance]
节中,配置图像服务API的位置:[glance] api_servers = http://controller:9292
-
在
[oslo_concurrency]
节中,配置锁路径:[oslo_concurrency lock_path = /var/lib/nova/tmp
-
在
[placement]
节中,配置Placement API:[placement] os_region_name = RegionOne project_domain_name = Default project_name = service auth_type = password user_domain_name = Default auth_url = http://controller:35357/v3 username = placement password = PLACEMENT_PASS
取代PLACEMENT_PASS
使用您为placement
身份服务中的用户。中的任何其他选项注释掉。[placement]
部分。
-
因包装缺陷,必须将以下配置添加到Placement API中,从而启用对Placement API的访问
/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
7、填充nova-api数据库:
$ su -s /bin/sh -c "nova-manage api_db sync" nova
8、注册cell0
数据库:
$ su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
9、创建cell1
牢房:
$ su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
10、填充nova数据库:
$ su -s /bin/sh -c "nova-manage db sync" nova
11、验证nova cell 0和cell 1是否正确注册:
$ nova-manage cell_v2 list_cells
+--------------------------------------+------------------+------------+----------+---------+-------+----------------------------+-----------------+-------------+
| Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason | Forced down |
+--------------------------------------+------------------+------------+----------+---------+-------+----------------------------+-----------------+-------------+
| 0a271a84-951c-4d72-a103-c6490342e8f0 | nova-scheduler | controller | internal | enabled | up | 2020-10-16T11:44:31.000000 | - | False |
| 7be59081-6995-4d73-a81f-c222fd29c503 | nova-consoleauth | controller | internal | enabled | up | 2020-10-16T11:44:31.000000 | - | False |
| a7e81fab-62ba-41c8-bebb-49423caec863 | nova-conductor | controller | internal | enabled | up | 2020-10-16T11:44:35.000000 | - | False |
+--------------------------------------+------------------+------------+----------+---------+-------+----------------------------+-----------------+-------------+
12、服务启动
启动 Compute 服务并将其设置为随系统启动:
$ 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
验证
netstat -lntp
安装和配置计算节点
1、安装软件包
$ yum install openstack-nova-compute -y
2、编辑/etc/nova/nova.conf
归档并完成以下操作:
-
在
[DEFAULT]
节中,只启用计算和元数据API:[DEFAULT] enabled_apis = osapi_compute,metadata transport_url = rabbit://openstack:openstack@controller my_ip = 192.168.100.143 use_neutron = True firewall_driver = nova.virt.firewall.NoopFirewallDriver
-
在
[api]
和[keystone_authtoken]
各节,配置身份服务访问:[api] auth_strategy = keystone [keystone_authtoken] auth_uri = http://controller:5000 auth_url = http://controller:35357 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = NOVA_PASS
-
在
[vnc]
节中,启用和配置远程控制台访问:[vnc] enabled = True vncserver_listen = 0.0.0.0 vncserver_proxyclient_address = $my_ip novncproxy_base_url = http://controller:6080/vnc_auto.html
(如果要访问远程控制台的web浏览器驻留在无法解析controller
主机名,您必须替换controller
具有控制器节点的管理接口IP地址。)
-
在
[glance]
节中,配置图像服务API的位置:[glance] api_servers = http://controller:9292
-
在
[oslo_concurrency]
节中,配置锁路径:[oslo_concurrency] lock_path = /var/lib/nova/tmp
-
在
[placement]
节中,配置Placement API:[placement] os_region_name = RegionOne project_domain_name = Default project_name = service auth_type = password user_domain_name = Default auth_url = http://controller:35357/v3 username = placement password = PLACEMENT_PASS
取代PLACEMENT_PASS
使用您为placement
身份服务中的用户。中的任何其他选项注释掉。[placement]
部分。
3、确定计算节点是否支持虚拟机的硬件加速:(可跳过)
$ egrep -c '(vmx|svm)' /proc/cpuinfo
如果此命令返回值为1 或者更大
,您的计算节点支持硬件加速,这通常不需要额外的配置。
如果此命令返回值为0
,您的计算节点不支持硬件加速,您必须配置libvirt
使用QEMU而不是KVM。
-
编辑
[libvirt]
部分/etc/nova/nova.conf
档案如下:[libvirt] virt_type = qemu
4、启动Compute服务,包括其依赖项,并将其配置为在系统启动时自动启动:
$ systemctl enable libvirtd.service openstack-nova-compute.service
$ systemctl start libvirtd.service openstack-nova-compute.service
(如果nova-compute
服务启动失败,请检查/var/log/nova/nova-compute.log
。错误信息AMQP server on controller:5672 isunreachable
可能表示控制器节点上的防火墙正在阻止对端口5672的访问。将防火墙配置为在控制器节点上打开端口5672并重新启动nova-compute
计算节点上的服务。)
5、将计算节点添加到单元数据库中
以下命令在运行在控制器节点。
-
获取管理凭据以启用只管理的CLI命令,然后确认数据库中有计算主机:
$ . admin-openrc $ openstack hypervisor list +----+---------------------+-----------------+-----------+-------+ | ID | Hypervisor Hostname | Hypervisor Type | Host IP | State | +----+---------------------+-----------------+-----------+-------+ | 1 | compute1 | QEMU | 10.0.0.31 | up | +----+---------------------+-----------------+-----------+-------+
-
发现计算主机:
$ su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
添加新的计算节点时,必须在控制器节点上运行
nova-manage cell_v2 discover_hosts
注册这些新的计算节点。或者,您可以在/etc/nova/nova.conf
:[scheduler] discover_hosts_in_cells_interval = 300 # 下面不知道要不要改 [filter_scheduler] discover_hosts_in_cells_interval = 300
来配置周期性任务,以使Nova自动发现新主机。
6、验证
$ openstack service list
+----------------------------------+-----------+-----------+
| ID | Name | Type |
+----------------------------------+-----------+-----------+
| 6eeb352a9cc74557a5dd679d4f90df0a | glance | image |
| 743401be43c948f2981163f41e0ad7e9 | keystone | identity |
| aabf05adda5b417f96fc15a0d6897756 | placement | placement |
| b0c73a07749745cab6aded4a7cef4efd | nova | compute |
+----------------------------------+-----------+-----------+
$ openstack compute service list
+----+------------------+------------+----------+---------+-------+----------------------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+------------------+------------+----------+---------+-------+----------------------------+
| 1 | nova-scheduler | controller | internal | enabled | up | 2020-11-06T04:03:55.000000 |
| 2 | nova-consoleauth | controller | internal | enabled | up | 2020-11-06T04:03:56.000000 |
| 3 | nova-conductor | controller | internal | enabled | up | 2020-11-06T04:03:55.000000 |
| 7 | nova-compute | compute1 | nova | enabled | up | 2020-11-06T04:03:50.000000 |
+----+------------------+------------+----------+---------+-------+----------------------------+
$ openstack compute service list --service nova-compute
+----+--------------+----------+------+---------+-------+----------------------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+--------------+----------+------+---------+-------+----------------------------+
| 7 | nova-compute | compute1 | nova | enabled | up | 2020-11-06T04:04:10.000000 |
+----+--------------+----------+------+---------+-------+----------------------------+
标签:Nova,placement,service,--,老王,nova,controller,笔记,openstack 来源: https://www.cnblogs.com/lyjx/p/14249311.html