OpenStack T version-Placement component deployment

1. OpenStack-Placement component deployment

1.1. Create a database instance and database user

[root@ct ~]# mysql -uroot -p123456
MariaDB [(none)]> CREATE DATABASE placement;
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';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit

Insert picture description here

1.2. Create an endpoint for Placement service users and APIs

[root@ct ~]# openstack user create --domain default --password PLACEMENT_PASS placement
#创建placement用户
[root@ct ~]# openstack role add --project service --user placement admin
#给与placement用户对service项目拥有admin权限
[root@ct ~]# openstack service create --name placement --description "Placement API" placement
#创建一个placement服务,服务类型为placement

1.2.1. Register the API port to the placement service; the registered information will be written to mysql

[root@ct ~]# openstack endpoint create --region RegionOne placement public http://ct:8778
[root@ct ~]#  openstack endpoint create --region RegionOne placement internal http://ct:8778
[root@ct ~]# openstack endpoint create --region RegionOne placement admin http://ct:8778

Insert picture description here

1.3, install placement service

[root@ct ~]# yum -y install openstack-placement-api

1.4, modify the placement configuration file

[root@ct ~]# cp /etc/placement/placement.conf{
    
    ,.bak}
[root@ct ~]# grep -Ev '^$|#' /etc/placement/placement.conf.bak > /etc/placement/placement.conf
[root@ct ~]# openstack-config --set /etc/placement/placement.conf placement_database connection mysql+pymysql://placement:PLACEMENT_DBPASS@ct/placement
[root@ct ~]# openstack-config --set /etc/placement/placement.conf api auth_strategy keystone
[root@ct ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_url  http://ct:5000/v3
[root@ct ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken memcached_servers ct:11211
[root@ct ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_type password
[root@ct ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken project_domain_name Default
[root@ct ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken user_domain_name Default
[root@ct ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken project_name service
[root@ct ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken username placement
[root@ct ~]# openstack-config --set /etc/placement/placement.conf keystone_authtoken password PLACEMENT_PASS
[root@ct ~]# cd /etc/placement
[root@ct placement]# cat placement.conf          #查看placement配置文件
[DEFAULT]
[api]
auth_strategy = keystone
[cors]
[keystone_authtoken]
auth_url = http://ct:5000/v3				#指定keystone地址
memcached_servers = ct:11211			#session信息是缓存放到了memcached中
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = placement
password = PLACEMENT_PASS
[oslo_policy]
[placement]
[placement_database]
connection = mysql+pymysql://placement:PLACEMENT_DBPASS@ct/placement
[profiler]

Insert picture description here

[root@ct ~]# su -s /bin/sh -c "placement-manage db sync" placement     #导入数据库
[root@ct ~]# cd /etc/httpd/conf.d/
[root@ct conf.d]# cat 00-placement-api.conf 		#安装完placement会自动创建此文件
[root@ct conf.d]# vim 00-placement-api.conf   #修改Apache配置文件
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>

Insert picture description here

[root@ct ~]# systemctl restart httpd   #重新启动apache

1.5, test

1.5.1, curl test access

[root@ct ~]# curl ct:8778

1.5.2, view port occupation (netstat, lsof)

[root@ct ~]# netstat -natp | grep 8778

1.5.3, check placement status

[root@ct ~]# placement-status upgrade check

Insert picture description here

2. Summary

Placement provides placement-apiWSGI scripts for running services with Apache, nginx or other web servers that support WSGI (python entry proxy is implemented through nginx or apache).
According to the packaging solution used to deploy OpenStack, the WSGI script may be located in /usr/bin or /usr/local/bin. The
Placement service is a component separated from the S version and separated from the nova service. The function is to collect the information of each node node. Available resources, write the resource statistics of the node node to mysql, and the Placement service will be called by the nova scheduler service. The listening port of the Placement service is 8778

■ Configuration files to be modified:

Main modification ideas for placement.conf :
Keystone authentication related (url, HOST:PORT, domain, account password, etc.)
docking database (location)

Main modification ideas for 00-placement-api.conf :
Apache permissions ,Access control

Guess you like

Origin blog.csdn.net/weixin_50344814/article/details/113941133