OpenStack-T version-Placement component deployment

1. Introduction to Placement

1. What does Placement provide?

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 in /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 each node node The available resources of the node, the resource statistics of the node node are written to mysql, and the Placement service will be called by the nova scheduler service. The listening port of the Placement service is 8778

2. The configuration file to be modified

1.placement.conf

Main modification ideas:
Keystone authentication related (url, HOST:PORT, domain, account password, etc.)

2. 00-placement-api.conf

Main revised ideas:
Apache permissions, access control

Second, the deployment process

1. Create a database instance and database user

[root@ct ~]# mysql -uroot -p
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;

2 Create an endpoint for Placement service users and API

● Create placement users

[root@ct ~]# openstack user create --domain default --password PLACEMENT_PASS placement
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 78fb711680be495e90cfdff48beadd13 |
| name                | placement                        |
| options             | {
    
    }                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

● Give placement users admin rights to the service project

[root@ct ~]# openstack role add --project service --user placement admin

● Create a placement service, the service type is placement

[root@ct ~]# openstack service create --name placement --description "Placement API" placement
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Placement API                    |
| enabled     | True                             |
| id          | a02747cae70c4c7b9a8996b176ab04e3 |
| name        | placement                        |
| type        | placement                        |
+-------------+----------------------------------+

● 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
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | e9523ccc3ae74c7c815ad61477abd254 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | a02747cae70c4c7b9a8996b176ab04e3 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://ct:8778                   |
+--------------+----------------------------------+

[root@ct ~]# openstack endpoint create --region RegionOne placement internal http://ct:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | d70cdec5113f4a30a1d0ef97359e6c38 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | a02747cae70c4c7b9a8996b176ab04e3 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://ct:8778                   |
+--------------+----------------------------------+

[root@ct~]# openstack endpoint create --region RegionOne placement admin http://ct:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 26d77b720e904dc392215b6cad78e2a5 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | a02747cae70c4c7b9a8996b176ab04e3 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://ct:8778                   |
+--------------+----------------------------------+

● Install placement service

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

3. Modify the placement configuration file

#Modify the configuration file, you can use the shell script to pass in the parameters

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@ct/placement
openstack-config --set /etc/placement/placement.conf api auth_strategy keystone
openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_url  http://ct:5000/v3
openstack-config --set /etc/placement/placement.conf keystone_authtoken memcached_servers ct: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
  • View placement configuration file through cat command
[root@ct placement]# cat /etc/placement/placement.conf
[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]

4. Import the database and modify the Apache configuration

4.1 Import the database

[root@ct ~]# su -s /bin/sh -c "placement-manage db sync" placement
  /usr/lib/python2.7/site-packages/pymysql/cursors.py:170: Warning: (1280, u"Name 'alembic_version_pkc' ignored for PRIMARY key.")
  result = self._query(query)

4.2 Modify Apache configuration file

00-placemenct-api.conf (this file will be created automatically after the placement service is installed-virtual host configuration) #Virtual
host configuration file

[root@ct ~]# cd /etc/httpd/conf.d/
[root@ct ~]# vim 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>

Insert picture description here

[root@ct conf.d]# cat 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 ...
</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>

4.3 Restart apache and test

[root@ct ~]# systemctl restart httpd
[root@ct ~]# curl ct:8778		# curl 测试访问
{
    
    "versions": [{
    
    "status": "CURRENT", "min_version": "1.0", "max_version": "1.36", "id": "v1.0", "links": [{
    
    "href": "", "rel": "self"}]}]}[root@ct conf.d]

[root@ct ~]#  netstat -natp | grep 8778       # 查看端口占用(netstat、lsof)
tcp        0      0 192.168.1.10:36708      192.168.1.10:8778       TIME_WAIT   -                   
tcp6       0      0 :::8778                 :::*                    LISTEN      36434/httpd   


[root@ct ~]# placement-status upgrade check		# 检查placement状态
+----------------------------------+
| Upgrade Check Results            |
+----------------------------------+
| Check: Missing Root Provider IDs |
| Result: Success                  |
| Details: None                    |
+----------------------------------+
| Check: Incomplete Consumers      |
| Result: Success                  |
| Details: None                    |
+----------------------------------+

Guess you like

Origin blog.csdn.net/F2001523/article/details/114368276