OpenStack运维之安装Placement服务

Placement概述

Placement服务跟踪资源(比如计算节点,存储资源池,网络资源池等)的使用情况,提供自定义资源的能力,为分配资源提供服务。

Placement在openstack的Stein版本之前,属于Nova组件的一部分。该组件应该在Nova之前安装。

Placement API作为一个标准的WSGI脚本,为WSGI服务器提供了模块级的应用程序属性。支持部署在多种服务器上,如:

这种情况下,Placement的地址、端口和安装路径(或前缀)由web服务器的配置控制,而不是placement.conf文件。

Placement API服务使用http的80端口,和/placement的路径来访问。

安装部署

创建数据库

1
2
3
4
5
CREATE DATABASE placement;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' \
IDENTIFIED BY '123456';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' \
IDENTIFIED BY '123456';

创建用户

获得 admin 凭证来获取只有管理员能执行的命令的访问权限:

1
2
3
4
5
6
7
8
export OS_USERNAME=admin
export OS_PASSWORD=keystone
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://master01.boysec.cn:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2

注意:如果加入到.bashrc下则不需要再次执行!

创建placement用户

1
2
3
4
5
6
7
8
# 非交互式(密码:placement)
openstack user create --domain default --password placement placement

# 交互式
openstack user create --domain default --password-prompt placement

# 添加project
openstack role add --project service --user placement admin

服务配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 为openstack添加placement服务
openstack service create --name placement \
--description "Placement API" placement

# 创建公共接口的端点,端口不同的操作系统不一样,8780和80也有可能
openstack endpoint create --region RegionOne \
placement public http://master01.boysec.cn:8778
# 创建内部接口的端点
openstack endpoint create --region RegionOne \
placement internal http://master01.boysec.cn:8778

# 创建管理接口的端点
openstack endpoint create --region RegionOne \
placement admin http://master01.boysec.cn:8778

安装服务

1
yum install openstack-placement-api

配置服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@master01 ~]# cp /etc/placement/placement.conf{,.bak}
[root@master01 ~]# grep -Ev "^$|#" > /etc/placement/placement.conf.bak > /etc/placement/placement.conf
[root@master01 ~]# cat /etc/placement/placement.conf
[DEFAULT]
[api]
auth_strategy = keystone
[cors]
[keystone_authtoken]
auth_url = http://master01.boysec.cn:5000/v3
memcached_servers = master01.boysec.cn:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = placement
password = placement
[oslo_policy]
[placement]
[placement_database]
connection = mysql+pymysql://placement:123456@master01.boysec.cn/placement
[profiler]

初始化数据库

1
su -s /bin/sh -c "placement-manage db sync" placement

启动服务

1
systemctl restart httpd    # 重启httpd服务

验证

1
2
3
4
5
6
7
8
9
10
11
12
[root@master01 ~]# placement-status upgrade check
+----------------------------------+
| Upgrade Check Results |
+----------------------------------+
| Check: Missing Root Provider IDs |
| Result: Success |
| Details: None |
+----------------------------------+
| Check: Incomplete Consumers |
| Result: Success |
| Details: None |
+----------------------------------+

小bug解决

相关报错信息

在整个集群都安装完成创建实例时会出现以下报错:

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@master01.boysec.cn ~]# openstack server delete 951436c5-674d-46db-9c26-9b88267b8439
Failed to delete allocations for consumer 951436c5-674d-46db-9c26-9b88267b8439. Error: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /allocations/951436c5-674d-46db-9c26-9b88267b8439
on this server.</p>
</body></html>
(HTTP 409) (Request-ID: req-8b28ecc0-fe12-4179-aab4-b10a1b1a9b01)

# nova相关日志都会有403(拒绝访问)信息
2022-01-19 03:46:23.974 1759 WARNING keystoneauth.discover [req-53807e2f-b456-4b4f-a408-7d38ad49e895 d8cd16895f8d4421975a3e22396af49a e40a3e215adc41fa89b7c6ddf9443dc3 - default default] Failed to contact the endpoint at http://master01.boysec.cn:8778 for discovery. Fallback to using that endpoint as the base url.: Forbidden: Forbidden (HTTP 403)

解决问题

修改placement配置文件中添加以下信息:

1
2
3
4
5
6
7
8
9
10
11
12
cat /etc/httpd/conf.d/00-placement-api.conf 
···
<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</Directory>
···

重启http

1
systemctl restart httpd