一、创建数据库实例和数据库用户
mysql -uroot -p123456
create database placement;
grant all privileges on placement.* to 'placement'@'localhost' identified by 'placement_dbpass';
grant all privileges on placement.* to 'placement'@'%' identified by 'placement_dbbpass';
flush privileges;
exit;
二、创建Placement服务用户和API的endpoint
创建placement用户
openstack user create --domain default --password placement_pass placement
给与placement用户对service项目拥有admin权限
openstack role add --project service --user placement admin
创建一个placement服务,服务类型为placement
openstack service create --name placement --description "Placement API" placement
注册API端口到placement的service中;注册的信息会写入到mysql中
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
安装placement服务
yum -y install openstack-placement-api
修改placement配置文件
cp /etc/placement/placement.conf{,.bak}
grep -Ev '^$|#' /etc/placement/placement.conf.bak > /etc/placement/placement.conf
openstack-config --set /etc/placement/placement.conf placement_database connection mysql+pymysql://placement:placement_dbpass@controller/placement
openstack-config --set /etc/placement/placement.conf api auth_strategy keystone
openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_url http://controller:5000/v3
openstack-config --set /etc/placement/placement.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_type password
openstack-config --set /etc/placement/placement.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/placement/placement.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/placement/placement.conf keystone_authtoken project_name service
openstack-config --set /etc/placement/placement.conf keystone_authtoken username placement
openstack-config --set /etc/placement/placement.conf keystone_authtoken password placement_pass
导入数据库
su -s /bin/sh -c "placement-manage db sync" placement
修改Apache配置文件:00-placemenct-api.conf
安装完placement服务后会自动创建该文件-虚拟主机配置
cd /etc/httpd/conf.d/
cat 00-placement-api.conf #安装完placement会自动创建此文件
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 ...
</VirtualHost>
Alias /placement-api /usr/bin/placement-api
<Location /placement-api>
SetHandler wsgi-script
Options +ExecCGI
WSGIProcessGroup placement-api
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
</Location>
<Directory /usr/bin> #此处是bug,必须添加下面的配置来启用对placement api的访问,否则在访问apache的
<IfVersion >= 2.4> #api时会报403;添加在文件的最后即可
Require all granted
</IfVersion>
<IfVersion < 2.4> #apache版本;允许apache访问/usr/bin目录;否则/usr/bin/placement-api将不允许被访问
Order allow,deny
Allow from all #允许apache访问
</IfVersion>
</Directory>
重新启动apache
systemctl restart httpd.service
三、测试
curl 测试访问
curl controller:8778
查看端口占用(netstat、lsof)
netstat -natp | grep 8778
检查placement状态
placement-status upgrade check
小结
Placement提供了placement-apiWSGI脚本,用于与Apache,nginx或其他支持WSGI的Web服务器一起运行服务(通过nginx或apache实现python入口代理)。
根据用于部署OpenStack的打包解决方案,WSGI脚本可能位于/usr/bin 或中/usr/local/bin
Placement服务是从 S 版本,从nova服务中拆分出来的组件,作用是收集各个node节点的可用资源,把node节点的资源统计写入到mysql,Placement服务会被nova scheduler服务进行调用 Placement服务的监听端口是8778
需修改的配置文件:
① placement.conf
主要修改思路:
Keystone认证相关(url、HOST:PORT、域、账号密码等)
对接数据库(位置)
② 00-placement-api.conf
主要修改思路:
Apache权限、访问控制