1、使用数据库访问客户端以 root 用户身份连接到数据库服务器:
# mysql -uroot -p123
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.3.20-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
2、创建 placement 数据库
MariaDB [(none)]> CREATE DATABASE placement default character set utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' \
IDENTIFIED BY 'PLACEMENT_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' \
IDENTIFIED BY 'PLACEMENT_DBPASS';
3、创建 placement 用户
交互式:
# openstack user create --domain default --password-prompt placement
非交互式:
# openstack user create --domain default --password=placement placement
4、将 admin 角色添加到 placement 用户和 service 项目:
# openstack role add --project service --user placement admin
5、创建 placement 服务实体
# openstack service create --name placement \
--description "Placement API" placement
6、创建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
7、安装Placement软件包
# yum install openstack-placement-api -y
8、修改配置文件 /etc/placement/placement.conf
# cd /etc/placement/ && mv placement.conf placement.conf.source && cat placement.conf.source |grep -Ev "^#|^$" > placement.conf && chown root:placement placement.conf
# vi /etc/placement/placement.conf
在 [placement_database] “配置数据库访问”部分中:
[placement_database]
# ...
connection = mysql+pymysql://placement:PLACEMENT_DBPASS@controller/placement
在 [api] and [keystone_authtoken] 部分中,配置 Identity service 访问权限:
[api]
# ...
auth_strategy = keystone
[keystone_authtoken]
# ...
auth_url = http://controller:5000/v3
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = placement
password = placement
openstack-placement-api安装完成后会自动生成:/etc/httpd/conf.d/00-placement-api.conf文件
由于有个包的bug需要配置修改文件,需要修改nova虚拟主机配置文件,增加内容,完整的文件内容如下:
# vi /etc/httpd/conf.d/00-placement-api.conf
在三个#下面添加内容
#SSLEngine On
#SSLCertificateFile ...
#SSLCertificateKeyFile ...
<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</Directory>
</VirtualHost>
9、同步placement服务数据库
# su -s /bin/sh -c "placement-manage db sync" placement
10、重启httpd服务并验证Placement
# systemctl restart httpd
执行placement-status命令检查状态
# placement-status upgrade check
+----------------------------------+
| Upgrade Check Results |
+----------------------------------+
| Check: Missing Root Provider IDs |
| Result: Success |
| Details: None |
+----------------------------------+
| Check: Incomplete Consumers |
| Result: Success |
| Details: None |
+----------------------------------+
11、安装pip
# yum install -y epel-release
# yum install -y python-pip
# rm -rf /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo
配置国内pip源
# cat > /etc/pip.conf <<EOF
[global]
index-url = https://pypi.douban.com/simple/
[install]
trusted-host = https://pypi.douban.com
EOF
安装osc-placement插件
# pip install osc-placement==2.2.0
列出可用的资源类和特征
# openstack --os-placement-api-version 1.2 resource class list --sort-column name
# openstack --os-placement-api-version 1.6 trait list --sort-column name
/*
如果是CentOS8,则直接执行 yum install python3-osc-placement 或 pip3 install osc-placement
osc_placement-3.1.1-py3-none-any.whl
*/
placement.conf
[DEFAULT]
[api]
auth_strategy = keystone
[cors]
[keystone_authtoken]
auth_url = http://controller:5000/v3
memcached_servers = controller: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:PLACEMENT_DBPASS@controller/placement
[profiler]
00-placement-api.conf
Listen 8778
<VirtualHost *:8778>
WSGIProcessGroup placement-api
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess placement-api processes=3 threads=1 user=placement group=placement
WSGIScriptAlias / /usr/bin/placement-api
<IfVersion >= 2.4>
ErrorLogFormat "%M"
</IfVersion>
ErrorLog /var/log/placement/placement-api.log
#SSLEngine On
#SSLCertificateFile ...
#SSLCertificateKeyFile ...
<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</Directory>
</VirtualHost>
Alias /placement-api /usr/bin/placement-api
<Location /placement-api>
SetHandler wsgi-script
Options +ExecCGI
WSGIProcessGroup placement-api
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
</Location>