先放个链接,万一有人关注呢
优质文章推荐
↓ ↓ ↓ ↓ ↓
书接上回:OpenStack部署4.0——定位服务(Placement)
创建数据库
进入控制节点的数据库中
mysql -uroot -p123创建nova_api、nova和nova_cell0数据库
create database nova_api;create database nova;create database nova_cell0;
授权数据库
grant all privileges on nova_api.* to 'nova'@'localhost' identified by '123';grant all privileges on nova_api.* to 'nova'@'%' identified by '123';grant all privileges on nova.* to 'nova'@'localhost' identified by '123';grant all privileges on nova.* to 'nova'@'%' identified by '123';grant all privileges on nova_cell0.* to 'nova'@'localhost' identified by '123';grant all privileges on nova_cell0.* to 'nova'@'%' identified by '123';
退出数据库
配置用户与终端节点
获得admin凭证用于获取管理员权限
source admin-openrc创建计算服务用户
openstack user create --domain default --password-prompt nova输出两次密码,创建成功。输出如下
User Password:Repeat User Password:+---------------------+----------------------------------+| Field | Value |+---------------------+----------------------------------+| domain_id | default || enabled | True || id | 5d1f5b025ea34576881a4f7a6ea936fd || name | nova || options | {} || password_expires_at | None |+---------------------+----------------------------------+
将计算服务用户添加到具有admin角色的服务项目
openstack role add --project service --user nova admin在服务目录中创建计算服务API
openstack service create --name nova --description "OpenStack Compute" compute输出如下
+-------------+----------------------------------+| Field | Value |+-------------+----------------------------------+| description | OpenStack Compute || enabled | True || id | 3f35504eeb644a2bbd212c5eda95563f || name | nova || type | compute |+-------------+----------------------------------+
openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1输出如下
+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 9078ff88ef114665aeeecd7d6b48f0b9 || interface | public || region | RegionOne || region_id | RegionOne || service_id | 3f35504eeb644a2bbd212c5eda95563f || service_name | nova || service_type | compute || url | http://controller:8774/v2.1 |+--------------+----------------------------------+
openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1输出如下
+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 3f35504eeb644a2bbd212c5eda95563f || interface | internal || region | RegionOne || region_id | RegionOne || service_id | 3f35504eeb644a2bbd212c5eda95563f || service_name | nova || service_type | compute || url | http://controller:8774/v2.1 |+--------------+----------------------------------+
openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1输出如下
+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 92cbbc96ac97439facf497a46885c7a3 || interface | admin || region | RegionOne || region_id | RegionOne || service_id | 3f35504eeb644a2bbd212c5eda95563f || service_name | nova || service_type | compute || url | http://controller:8774/v2.1 |+--------------+----------------------------------+
在控制节点安装与配置计算服务
安装计算服务相关组件
yum install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler编辑/etc/nova/nova.conf文件
vi /etc/nova/nova.con仅启用计算和元数据API
[DEFAULT]# ...enabled_apis = osapi_compute,metadata
在api_database和database模块,配置数据库访问
[api_database]# ...connection = mysql+pymysql://nova:123@controller/nova_api[database]# ...connection = mysql+pymysql://nova:123@controller/nova
在DEFAULT模块,配置RabbitMQ消息队列访问
[DEFAULT]# ...transport_url = rabbit://openstack:123@controller:5672/
在api和keystone_authtoken模块,配置身份认证服务访问
[api]# ...auth_strategy = keystone[keystone_authtoken]# ...www_authenticate_uri = http://controller:5000/auth_url = http://controller:5000/memcached_servers = controller:11211auth_type = passwordproject_domain_name = Defaultuser_domain_name = Defaultproject_name = serviceusername = nova#配置密码password = 123
在DEFAULT模块中,配置my_ip选项以使用控制器节点的管理接口IP地址
[DEFAULT]# ...#修改为本地IP地址my_ip = 192.168.2.161
在DEFAULT模块中,启用对网络服务的支持
[DEFAULT]# ...use_neutron = truefirewall_driver = nova.virt.firewall.NoopFirewallDriver
在vnc模块中,配置VNC代理使用控制节点的管理接口IP地址
[vnc]enabled = true# ...#修改为本地IP地址server_listen = 192.168.2.161server_proxyclient_address = 192.168.2.161
在glance模块中,配置镜像服务API的位置
[glance]# ...api_servers = http://controller:9292
在oslo_concurrency模块中,配置锁路径
[oslo_concurrency]# ...lock_path = /var/lib/nova/tmp
在placement模块中,配置对Placement服务的访问
[placement]# ...region_name = RegionOneproject_domain_name = Defaultproject_name = serviceauth_type = passworduser_domain_name = Defaultauth_url = http://controller:5000/v3username = placement#配置密码password = 123
将信息同步到nova_api数据库
su -s /bin/sh -c "nova-manage api_db sync" nova注册cell0数据库
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova创建cell1单元格
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova将信息同步到nova数据库
su -s /bin/sh -c "nova-manage db sync" nova验证nova cell0和cell1是否被正确注册
su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova输出如下
+-------+--------------------------------------+------------------------------------------+-------------------------------------------------+----------+| 名称 | UUID | Transport URL | 数据库连接 | Disabled |+-------+--------------------------------------+------------------------------------------+-------------------------------------------------+----------+| cell0 | 00000000-0000-0000-0000-000000000000 | none:/ | mysql+pymysql://nova:****@controller/nova_cell0 | False || cell1 | 9f3edfcf-5108-4472-9415-820db3960828 | rabbit://openstack:****@controller:5672/ | mysql+pymysql://nova:****@controller/nova | False |+-------+--------------------------------------+------------------------------------------+-------------------------------------------------+----------+
启动服务
systemctl enable openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.servicesystemctl start openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
在计算节点安装与配置计算服务
在计算节点安装计算服务软件包
yum install openstack-nova-compute -y编辑配置文件/etc/nova/nova.conf
vim /etc/nova/nova.conf在DEFAULT模块中,仅启用计算和元数据API
[DEFAULT]# ...enabled_apis = osapi_compute,metadata
在DEFAULT模块,配置RabbitMQ消息队列访问
[DEFAULT]# ...transport_url = rabbit://openstack:123@controller
在api和keystone_authtoken模块,配置身份认证服务访问
[api]# ...auth_strategy = keystone[keystone_authtoken]# ...www_authenticate_uri = http://controller:5000/auth_url = http://controller:5000/memcached_servers = controller:11211auth_type = passwordproject_domain_name = Defaultuser_domain_name = Defaultproject_name = serviceusername = novapassword = 123
在DEFAULT模块中,配置my_ip选项
[DEFAULT]# ...my_ip = 192.168.2.162
在DEFAULT模块中,启用对网络服务的支持
[DEFAULT]# ...use_neutron = truefirewall_driver = nova.virt.firewall.NoopFirewallDriver
在vnc模块中,启用和配置远程控制台访问
[vnc]# ...enabled = trueserver_listen = 0.0.0.0server_proxyclient_address = 192.168.2.162novncproxy_base_url = http://controller:6080/vnc_auto.html
在glance模块中,配置镜像服务API的位置
[glance]# ...api_servers = http://controller:9292
在oslo_concurrency模块中,配置锁定路径
[oslo_concurrency]# ...lock_path = /var/lib/nova/tmp
在placement模块中,配置Placement API
[placement]# ...region_name = RegionOneproject_domain_name = Defaultproject_name = serviceauth_type = passworduser_domain_name = Defaultauth_url = http://controller:5000/v3username = placementpassword = 123
在终端执行以下命令,验证计算节点是否支持虚拟机的硬件加速
egrep -c '(vmx|svm)' /proc/cpuinfo如果上述命令返回了一个或多个值,说明计算节点支持硬件加速并且不需要额外的配置;如果返回了0值,说明计算节点不支持硬件加速,需要配置libvirt(虚拟化管理软件)模块声明使用QEMU(虚拟操作系统模拟器)去代替KVM(多计算机切换器)。
编辑配置文件/etc/nova/nova.conf中的libvirt模块
[libvirt]# ...virt_type = qemu
启动计算服务及其依赖项,并配置为在系统启动时自启动
systemctl enable libvirtd.service openstack-nova-compute.servicesystemctl start libvirtd.service openstack-nova-compute.service
在控制节点获得admin凭证,将计算服务添加到cell数据库中
source admin-openrcopenstack compute service list --service nova-compute
输出如下
+----+--------------+---------+------+---------+-------+----------------------------+| ID | Binary | Host | Zone | Status | State | Updated At |+----+--------------+---------+------+---------+-------+----------------------------+| 5 | nova-compute | compute | nova | enabled | up | 2021-09-05T08:03:40.000000 |+----+--------------+---------+------+---------+-------+----------------------------+
控制主机寻找计算主机
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': 8cb364c6-72ca-4efe-95d6-7ecf046c6f4bChecking host mapping for compute host 'compute': ac28333b-c374-42de-ae7a-886b29e95ccfCreating host mapping for compute host 'compute': ac28333b-c374-42de-ae7a-886b29e95ccfFound 1 unmapped computes in cell: 8cb364c6-72ca-4efe-95d6-7ecf046c6f4b
验证操作
获取管理员权限
source admin-openrc列出服务组件用于验证每个进程是否成功启动和注册
openstack compute service list输出如下
+----+----------------+------------+----------+---------+-------+----------------------------+| ID | Binary | Host | Zone | Status | State | Updated At |+----+----------------+------------+----------+---------+-------+----------------------------+| 1 | nova-conductor | controller | internal | enabled | up | 2021-09-05T08:38:40.000000 || 2 | nova-scheduler | controller | internal | enabled | up | 2021-09-05T08:38:41.000000 || 5 | nova-compute | compute | nova | enabled | up | 2021-09-05T08:38:41.000000 |+----+----------------+------------+----------+---------+-------+----------------------------+
列出身份认证服务中的API端点,用于验证是否与身份认证服务连接
openstack catalog list输出如下
+-----------+-----------+-----------------------------------------+| Name | Type | Endpoints |+-----------+-----------+-----------------------------------------+| keystone | identity | RegionOne || | | public: http://controller:5000/v3/ || | | RegionOne || | | internal: http://controller:5000/v3/ || | | RegionOne || | | admin: http://controller:5000/v3/ || | | || placement | placement | RegionOne || | | public: http://controller:8778 || | | RegionOne || | | internal: http://controller:8778 || | | RegionOne || | | admin: http://controller:8778 || | | || nova | compute | RegionOne || | | internal: http://controller:8774/v2.1 || | | RegionOne || | | public: http://controller:8774/v2.1 || | | RegionOne || | | admin: http://controller:8774/v2.1 || | | || glance | image | RegionOne || | | internal: http://controller:9292 || | | RegionOne || | | public: http://controller:9292 || | | RegionOne || | | admin: http://controller:9292 || | | |+-----------+-----------+-----------------------------------------+
列出镜像服务中的图像,用于验证是否与镜像服务连接
openstack image list输出如下
+--------------------------------------+--------+--------+| ID | Name | Status |+--------------------------------------+--------+--------+| 188c4529-300c-4872-9a05-99ab91c0a189 | cirros | active |+--------------------------------------+--------+--------+
检查单元和定位API是否成功运行,以及其他必要的先决条件是否到位
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: Cinder API || Result: Success || Details: None |+--------------------------------+
来不及解释了,快上车!(进群看公告)

欢迎新的小伙伴加入!在这里,我们鼓励大家积极参与群内讨论和交流,分享自己的见解和经验,一起学习和成长。同时,也欢迎大家提出问题和建议,让我们不断改进和完善这个平台。
↓↓↓ 点个在看,你最好看!