我是靠谱客的博主 迅速小蝴蝶,最近开发中收集的这篇文章主要介绍OpenStack部署(四),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

部署版本:pike
部署环境:CentOS7.6
配置文件中所有controller可修改为控制节点ip地址
配置过程中使用 echo $? 验证命令执行情况
Compute service
计算服务NOVA
penStack Compute与OpenStack Identity进行交互以进行身份验证;用于磁盘和服务器映像的OpenStack映像服务;以及用于用户和管理界面的OpenStack仪表板。图像访问受到项目和用户的限制;每个项目的配额是有限的(例如,实例的数量)。OpenStack Compute组成:nova api服务、nova api元数据服务、nova计算服务、nova placement api服务、nova调度服务、Nova conductor模块、Nova console daemon、Nova novncproxy daemon、Nova-html5 proxy daemon、Nova xvpvncproxy daemon、The queue、SQL database

安装和配置控制节点
一、先决条件
1.创建数据库
使用数据库访问客户端以root用户身份连接到数据库服务器:

[root@controller /]# mysql -u root -p

创建nova_api, nova, nova_cell0数据库

MariaDB [(none)]> CREATE DATABASE nova_api;
Query OK, 1 row affected (0.01 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)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'controller' 
->
IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' 
->
IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'controller' 
->
IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' 
->
IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'controller' 
->
IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' 
->
IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.00 sec)

2.执行管理员脚本

[root@controller openrc]# source admin-openrc.sh 
[root@controller openrc]# echo $?
0

3.创建计算服务凭据
创建nova用户

[root@controller openrc]# openstack user create --domain default --password-prompt nova
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field
| Value
|
+---------------------+----------------------------------+
| domain_id
| default
|
| enabled
| True
|
| id
| 717a5aacffb348998f479f4a6dc2725b |
| name
| nova
|
| options
| {}
|
| password_expires_at | None
|
+---------------------+----------------------------------+

将admin角色添加到nova用户

[root@controller openrc]# openstack role add --project service --user nova admin
[root@controller openrc]# echo $?
0

创建nova服务实体

[root@controller openrc]# openstack service create --name nova 
>
--description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field
| Value
|
+-------------+----------------------------------+
| description | OpenStack Compute
|
| enabled
| True
|
| id
| 48a91d7353cb437789edef1cb07d1044 |
| name
| nova
|
| type
| compute
|
+-------------+----------------------------------+

创建计算API服务端点:

[root@controller openrc]# openstack endpoint create --region RegionOne 
>
compute public http://controller:8774/v2.1
+--------------+----------------------------------+
| Field
| Value
|
+--------------+----------------------------------+
| enabled
| True
|
| id
| 000e2276f31f4fadbd2c808951aaa7ad |
| interface
| public
|
| region
| RegionOne
|
| region_id
| RegionOne
|
| service_id
| 48a91d7353cb437789edef1cb07d1044 |
| service_name | nova
|
| service_type | compute
|
| url
| http://controller:8774/v2.1
|
+--------------+----------------------------------+
[root@controller openrc]# openstack endpoint create --region RegionOne 
>
compute internal http://controller:8774/v2.1
+--------------+----------------------------------+
| Field
| Value
|
+--------------+----------------------------------+
| enabled
| True
|
| id
| e54bf11e49a44d61b8307d406fa0cfdd |
| interface
| internal
|
| region
| RegionOne
|
| region_id
| RegionOne
|
| service_id
| 48a91d7353cb437789edef1cb07d1044 |
| service_name | nova
|
| service_type | compute
|
| url
| http://controller:8774/v2.1
|
+--------------+----------------------------------+
[root@controller openrc]# openstack endpoint create --region RegionOne 
>
compute admin http://controller:8774/v2.1
+--------------+----------------------------------+
| Field
| Value
|
+--------------+----------------------------------+
| enabled
| True
|
| id
| 47bc31f9fba64575ab2db08c656f9eb7 |
| interface
| admin
|
| region
| RegionOne
|
| region_id
| RegionOne
|
| service_id
| 48a91d7353cb437789edef1cb07d1044 |
| service_name | nova
|
| service_type | compute
|
| url
| http://controller:8774/v2.1
|
+--------------+----------------------------------+

5.创建一个Placement用户

[root@controller openrc]# openstack user create --domain default --password-prompt placement
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field
| Value
|
+---------------------+----------------------------------+
| domain_id
| default
|
| enabled
| True
|
| id
| 2e5c398224db48edb1e78d54e208ff1d |
| name
| placement
|
| options
| {}
|
| password_expires_at | None
|
+---------------------+----------------------------------+

6.将Placement用户添加到具有管理员角色的服务项目:

[root@controller openrc]# openstack role add --project service --user placement admin
[root@controller openrc]# echo $?
0

7.在服务目录中创建Placement API条目:

[root@controller openrc]# openstack service create --name placement --description "Placement API" placement
+-------------+----------------------------------+
| Field
| Value
|
+-------------+----------------------------------+
| description | Placement API
|
| enabled
| True
|
| id
| 5c6e5a73d8d94a0ba1b1abc1b626eb55 |
| name
| placement
|
| type
| placement
|
+-------------+----------------------------------+

8.创建Placement API服务端点:

[root@controller openrc]# openstack endpoint create --region RegionOne placement public http://controller:8778
+--------------+----------------------------------+
| Field
| Value
|
+--------------+----------------------------------+
| enabled
| True
|
| id
| f01817048cff453bbee39b2587c8f456 |
| interface
| public
|
| region
| RegionOne
|
| region_id
| RegionOne
|
| service_id
| 5c6e5a73d8d94a0ba1b1abc1b626eb55 |
| service_name | placement
|
| service_type | placement
|
| url
| http://controller:8778
|
+--------------+----------------------------------+
[root@controller openrc]# openstack endpoint create --region RegionOne placement internal http://controller:8778
+--------------+----------------------------------+
| Field
| Value
|
+--------------+----------------------------------+
| enabled
| True
|
| id
| febedb78f9f948ebb9186bcb97062fa0 |
| interface
| internal
|
| region
| RegionOne
|
| region_id
| RegionOne
|
| service_id
| 5c6e5a73d8d94a0ba1b1abc1b626eb55 |
| service_name | placement
|
| service_type | placement
|
| url
| http://controller:8778
|
+--------------+----------------------------------+
[root@controller openrc]# openstack endpoint create --region RegionOne placement admin http://controller:8778
+--------------+----------------------------------+
| Field
| Value
|
+--------------+----------------------------------+
| enabled
| True
|
| id
| 3b238ecf9d9943dbb27ac5981dfb1564 |
| interface
| admin
|
| region
| RegionOne
|
| region_id
| RegionOne
|
| service_id
| 5c6e5a73d8d94a0ba1b1abc1b626eb55 |
| service_name | placement
|
| service_type | placement
|
| url
| http://controller:8778
|
+--------------+----------------------------------+

二、安装和配置组件
1.安装对应的包

[root@controller openrc]# yum install openstack-nova-api openstack-nova-conductor 
>
openstack-nova-console openstack-nova-novncproxy 
>
openstack-nova-scheduler openstack-nova-placement-api

2.编辑 /etc/nova/nova.conf文件及修改文件内容

[root@controller openrc]# vim /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
[api_database]
connection = mysql+pymysql://nova:qwer1234@controller/nova_api
[database]
connection = mysql+pymysql://nova:qwer1234@controller/nova
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:qwer1234@controller
[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 = qwer1234
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:qwer1234@controller
my_ip = 10.0.0.11
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:qwer1234@controller
my_ip = 10.0.0.11
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[vnc]
enabled = true
# ...
vncserver_listen = $my_ip
vncserver_proxyclient_address = $my_ip
[glance]
api_servers = http://controller: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:35357/v3
username = placement
password = qwer1234

由于存在打包错误,您必须通过向中添加以下配置来启用对Placement API的访问

[root@controller openrc]# vim /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@controller openrc]# systemctl restart httpd
[root@controller openrc]# echo $?
0

3.填充nova api数据库:

[root@controller openrc]# su -s /bin/sh -c "nova-manage api_db sync" nova
[root@controller openrc]# echo $?
0

4.注册cell0数据库:

[root@controller openrc]# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
[root@controller openrc]# echo $?
0

5.创建cell1单元:

[root@controller openrc]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
4eae6503-2add-42ce-bdd0-60545f4c7a2a

6.填充nova数据库:

[root@controller openrc]# su -s /bin/sh -c "nova-manage db sync" nova
[root@controller openrc]# echo $?
0

7.验证nova的cell0和cell1已经正确注册

[root@controller openrc]# nova-manage cell_v2 list_cells
+-------+--------------------------------------+---------------------------------------+----------------------------------------------------+
|
Name |
UUID
|
Transport URL
|
Database Connection
|
+-------+--------------------------------------+---------------------------------------+----------------------------------------------------+
| cell0 | 00000000-0000-0000-0000-000000000000 |
none:/
| mysql+pymysql://nova:****@controller/nova_cell0 |
| cell1 | 4eae6503-2add-42ce-bdd0-60545f4c7a2a | rabbit://openstack:****@controller |
mysql+pymysql://nova:****@controller/nova
|
+-------+--------------------------------------+---------------------------------------+----------------------------------------------------+

三、完成安装
启动计算服务,并将其配置为在系统启动时启动:

[root@controller openrc]# 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.
[root@controller openrc]# systemctl start openstack-nova-api.service 
>
openstack-nova-consoleauth.service openstack-nova-scheduler.service 
>
openstack-nova-conductor.service openstack-nova-novncproxy.service
[root@controller openrc]# echo $?
0

安装并配置计算节点
一、安装和配置组件
1.安装软件包

[root@controller network-scripts]# yum install openstack-nova-compute

2.编辑/etc/nova/nova.conf文件及修改内容

[root@controller network-scripts]# vim /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
[api_database]
connection = mysql+pymysql://nova:qwer1234@controller/nova_api
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:qwer1234@controller
[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 = qwer1234
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:qwer1234@controller
my_ip = 10.0.0.11
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:qwer1234@controller
my_ip = 10.0.0.11
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[vnc]
enabled = true
# ...
vncserver_listen = 0.0.0.0
vncserver_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]
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 = qwer1234

二、完成安装
1.确定计算节点是否支持虚拟机的硬件加速:

[root@controller network-scripts]# egrep -c '(vmx|svm)' /proc/cpuinfo
0

如果此命令返回一个或更大的值,则计算节点支持硬件加速,通常不需要额外配置。
如果此命令返回的值为零,则计算节点不支持硬件加速,必须将libvirt配置为使用QEMU而不是KVM。

编辑/etc/nova/nova.conf文件中的[libvirt]部分:

[root@controller network-scripts]# vim /etc/nova/nova.conf
[libvirt]
virt_type = qemu

2.启动计算服务,包括其依赖项,并将其配置为在系统引导时自动启动:

[root@controller /]# systemctl enable libvirtd.service openstack-nova-compute.service
[root@controller /]# echo $?
0
[root@controller /]# systemctl start libvirtd.service openstack-nova-compute.service
[root@controller /]# echo $?
0

三、添加计算节点到cell数据库
1.获取管理员凭据以启用仅限管理员的CLI命令,然后确认数据库中有计算主机:

[root@controller openrc]# source admin-openrc.sh 
[root@controller openrc]# openstack compute service list --service nova-compute
+----+--------------+------------+------+---------+-------+----------------------------+
| ID | Binary
| Host
| Zone | Status
| State | Updated At
|
+----+--------------+------------+------+---------+-------+----------------------------+
|
8 | nova-compute | controller | nova | enabled | up
| 2022-02-23T03:10:06.000000 |
+----+--------------+------------+------+---------+-------+----------------------------+

2.发现compute hosts

[root@controller openrc]# 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': 4eae6503-2add-42ce-bdd0-60545f4c7a2a
Checking host mapping for compute host 'controller': 172300fb-478d-4710-af2f-bf6579252d79
Creating host mapping for compute host 'controller': 172300fb-478d-4710-af2f-bf6579252d79
Found 1 unmapped computes in cell: 4eae6503-2add-42ce-bdd0-60545f4c7a2a

可以通过
nova service-list
openstack hypervisor list
openstack compute service list
来查看服务运行情况

[root@controller openrc]# openstack compute service list
+----+------------------+-----------------------+----------+---------+-------+----------------------------+
| ID | Binary
| Host
| Zone
| Status
| State | Updated At
|
+----+------------------+-----------------------+----------+---------+-------+----------------------------+
|
1 | nova-consoleauth | controller
| internal | enabled | up
| 2022-02-23T03:11:29.000000 |
|
2 | nova-scheduler
| controller
| internal | enabled | up
| 2022-02-23T03:11:30.000000 |
|
3 | nova-conductor
| controller
| internal | enabled | up
| 2022-02-23T03:11:28.000000 |
|
7 | nova-consoleauth | controller.localdomain | internal | enabled | down
| None
|
|
8 | nova-compute
| controller
| nova
| enabled | up
| 2022-02-23T03:11:26.000000 |
+----+------------------+-----------------------+----------+---------+-------+----------------------------+
[root@controller openrc]# nova service-list
+--------------------------------------+------------------+-----------------------+----------+---------+-------+----------------------------+-----------------+-------------+
| Id
| Binary
| Host
| Zone
| Status
| State | Updated_at
| Disabled Reason | Forced down |
+--------------------------------------+------------------+-----------------------+----------+---------+-------+----------------------------+-----------------+-------------+
| 8b200290-1c5c-433d-8ad0-22adc0093f6e | nova-consoleauth | controller
| internal | enabled | up
| 2022-02-23T03:11:39.000000 | -
| False
|
| 18232a27-d8e8-4299-b5c9-80259a0bb638 | nova-scheduler
| controller
| internal | enabled | up
| 2022-02-23T03:11:40.000000 | -
| False
|
| 6147482e-3b2d-42cd-a496-b9bae07ae9a6 | nova-conductor
| controller
| internal | enabled | up
| 2022-02-23T03:11:38.000000 | -
| False
|
| aab04947-19f9-495d-9a46-9313d89fa3f9 | nova-consoleauth | controller.localdomain | internal | enabled | down
| -
| -
| False
|
| 051b94e5-f47b-47c5-ae56-8416b2185f2c | nova-compute
| controller
| nova
| enabled | up
| 2022-02-23T03:11:36.000000 | -
| False
|
+--------------------------------------+------------------+-----------------------+----------+---------+-------+----------------------------+-----------------+-------------+
[root@controller openrc]# openstack hypervisor list
+----+---------------------+-----------------+---------------+-------+
| ID | Hypervisor Hostname | Hypervisor Type | Host IP
| State |
+----+---------------------+-----------------+---------------+-------+
|
1 | controller
| QEMU
| controller | up
|
+----+---------------------+-----------------+---------------+-------+

验证操作
1.获取管理员凭据以启用仅限管理员的CLI命令,然后确认数据库中有计算主机:

[root@controller openrc]# source admin-openrc.sh 

2.列出服务组件以验证每个流程的成功启动和注册:

[root@controller openrc]# openstack compute service list
+----+------------------+-----------------------+----------+---------+-------+----------------------------+
| ID | Binary
| Host
| Zone
| Status
| State | Updated At
|
+----+------------------+-----------------------+----------+---------+-------+----------------------------+
|
1 | nova-consoleauth | controller
| internal | enabled | up
| 2022-02-23T03:15:29.000000 |
|
2 | nova-scheduler
| controller
| internal | enabled | up
| 2022-02-23T03:15:30.000000 |
|
3 | nova-conductor
| controller
| internal | enabled | up
| 2022-02-23T03:15:38.000000 |
|
7 | nova-consoleauth | controller.localdomain | internal | enabled | down
| None
|
|
8 | nova-compute
| controller
| nova
| enabled | up
| 2022-02-23T03:15:36.000000 |
+----+------------------+-----------------------+----------+---------+-------+----------------------------+

3.列出标识服务中的API端点,以验证与标识服务的连接:

[root@controller openrc]# openstack catalog list
+-----------+-----------+-----------------------------------------+
| Name
| Type
| Endpoints
|
+-----------+-----------+-----------------------------------------+
| keystone
| identity
| RegionOne
|
|
|
|
internal: http://controller:5000/v3/
|
|
|
| RegionOne
|
|
|
|
public: http://controller:5000/v3/
|
|
|
| RegionOne
|
|
|
|
admin: http://controller:35357/v3/
|
|
|
|
|
| nova
| compute
| RegionOne
|
|
|
|
public: http://controller:8774/v2.1
|
|
|
| RegionOne
|
|
|
|
admin: http://controller:8774/v2.1
|
|
|
| RegionOne
|
|
|
|
internal: http://controller:8774/v2.1 |
|
|
|
|
| placement | placement | RegionOne
|
|
|
|
admin: http://controller:8778
|
|
|
| RegionOne
|
|
|
|
public: http://controller:8778
|
|
|
| RegionOne
|
|
|
|
internal: http://controller:8778
|
|
|
|
|
| glance
| image
| RegionOne
|
|
|
|
internal: http://controller:9292
|
|
|
| RegionOne
|
|
|
|
admin: http://controller:9292
|
|
|
| RegionOne
|
|
|
|
public: http://controller:9292
|
|
|
|
|
+-----------+-----------+-----------------------------------------+

4.列出图像服务中的图像以验证与图像服务的连接(没有装镜像所以为空):

[root@controller openrc]# openstack image list
[root@controller openrc]# glance image-list
+----+------+
| ID | Name |
+----+------+
+----+------+

5.检查cell和placement API是否正常工作:

[root@controller openrc]# 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
|
+--------------------------------+

最后

以上就是迅速小蝴蝶为你收集整理的OpenStack部署(四)的全部内容,希望文章能够帮你解决OpenStack部署(四)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(32)

评论列表共有 0 条评论

立即
投稿
返回
顶部