openstack-placement服务安装

发布时间:2023年12月20日

概述

Before the Stein release the placement code was in Nova alongside the compute REST API code (nova-api). Make sure that the release version of this document matches the release version you want to deploy.
在Stein版本之前,placement代码存在于计算节点Nova的REST API的代码中。

安装和配置placement

先决条件

Before you install and configure the placement service, you must create a database, service credentials, and API endpoints.
在安装和配置placement之前,你必须创建一个数据库,服务凭证,和api服务端口。

创建数据库

To create the database, complete these steps:

Use the database access client to connect to the database server as the root user:

$ mysql -u root -p

Create the placement database:

MariaDB [(none)]> CREATE DATABASE placement;
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| glance             |
| information_schema |
| keystone           |
| mysql              |
| performance_schema |
| placement          |
+--------------------+
6 rows in set (0.014 sec)

Grant proper access to the database:

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';

Configure User and Endpoints

Source the admin credentials to gain access to admin-only CLI commands:

增加admin命令行权限
$ . admin-openrc

Create a Placement service user using your chosen PLACEMENT_PASS:

创建一个placement 服务用户,名字为placement,口令为给定口令。
$ openstack user create --domain default --password-prompt placement

User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | fa742015a6494a949f67629884fc7ec8 |
| name                | placement                        |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

结果

[root@controller ~]# openstack user create --domain default --password-prompt placement
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 1a96e4b649cb474da9506226a56ca7d6 |
| name                | placement                        |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

查看用户

[root@controller ~]# openstack user list
+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| a6a881a6089843b9999b2a0a7397c5d7 | admin     |
| 62623ccda6ce4e4c82b10cd51521aad8 | myuser    |
| a24c9f7cffd740afbd1a4388fecadc34 | glance    |
| 1a96e4b649cb474da9506226a56ca7d6 | placement |
+----------------------------------+-----------+

Add the Placement user to the service project with the admin role:

把placement用户添加admin角色,并添加到services项目中。
$ openstack role add --project service --user placement admin

Create the Placement API entry in the service catalog:

创建一个名字为placement的placement API服务。
$ openstack service create --name placement \
  --description "Placement API" placement

+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Placement API                    |
| enabled     | True                             |
| id          | 2d1a27022e6e4185b86adac4444c495f |
| name        | placement                        |
| type        | placement                        |
+-------------+----------------------------------+

结果

[root@controller ~]# openstack role add --project service --user placement admin
[root@controller ~]# openstack service create --name placement \
>   --description "Placement API" placement
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Placement API                    |
| enabled     | True                             |
| id          | e380dba4387a41e09d63f359248798f1 |
| name        | placement                        |
| type        | placement                        |
+-------------+----------------------------------+

查看服务


[root@controller ~]# openstack service list
+----------------------------------+-----------+-----------+
| ID                               | Name      | Type      |
+----------------------------------+-----------+-----------+
| 125478add9754a8182936f04f2175c0e | keystone  | identity  |
| 824b05bbfbca4fe7abc376ad9b0b5ec4 | glance    | image     |
| e380dba4387a41e09d63f359248798f1 | placement | placement |
+----------------------------------+-----------+-----------+

Create the Placement API service endpoints:

创建placement API服务端口
$ openstack endpoint create --region RegionOne \
  placement public http://controller:8778

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 2b1b2637908b4137a9c2e0470487cbc0 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 2d1a27022e6e4185b86adac4444c495f |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+

$ openstack endpoint create --region RegionOne \
  placement internal http://controller:8778

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 02bcda9a150a4bd7993ff4879df971ab |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 2d1a27022e6e4185b86adac4444c495f |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+

$ openstack endpoint create --region RegionOne \
  placement admin http://controller:8778

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 3d71177b9e0f406f98cbff198d74b182 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 2d1a27022e6e4185b86adac4444c495f |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+

结果

[root@controller ~]# openstack endpoint create --region RegionOne \
>   placement public http://controller:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 66025531e4e747bf8c7aecab421da838 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | e380dba4387a41e09d63f359248798f1 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
>   placement internal http://controller:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | e4ab36ff450d40c6bc997f8e04093413 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | e380dba4387a41e09d63f359248798f1 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
>   placement admin http://controller:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | ed03940afbb444f48d9a8041ce7b971d |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | e380dba4387a41e09d63f359248798f1 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+

查看已有的endpoint

[root@controller ~]# openstack endpoint list
+----------------------------------+-----------+--------------+--------------+---------+-----------+----------------------------+
| ID                               | Region    | Service Name | Service Type | Enabled | Interface | URL                        |
+----------------------------------+-----------+--------------+--------------+---------+-----------+----------------------------+
| 270167f7978b458da1110a0e2db815ff | RegionOne | keystone     | identity     | True    | admin     | http://controller:5000/v3/ |
| 463b426aad584e9ea6d011cd0a6c527e | RegionOne | keystone     | identity     | True    | internal  | http://controller:5000/v3/ |
| 6051331a74b74ecd92fd9cf05bb61979 | RegionOne | glance       | image        | True    | internal  | http://controller:9292     |
| 66025531e4e747bf8c7aecab421da838 | RegionOne | placement    | placement    | True    | public    | http://controller:8778     |
| 90b589816dd14b77814928f67e42a601 | RegionOne | glance       | image        | True    | public    | http://controller:9292     |
| 99c92cfc2b27431a95167b4113f4a5b4 | RegionOne | keystone     | identity     | True    | public    | http://controller:5000/v3/ |
| d2f34737a14a4b55ad948f68b2fd5272 | RegionOne | glance       | image        | True    | admin     | http://controller:9292     |
| e4ab36ff450d40c6bc997f8e04093413 | RegionOne | placement    | placement    | True    | internal  | http://controller:8778     |
| ed03940afbb444f48d9a8041ce7b971d | RegionOne | placement    | placement    | True    | admin     | http://controller:8778     |
+----------------------------------+-----------+--------------+--------------+---------+-----------+----------------------------+

查看role,user,project三者关系
[root@controller ~]# openstack role assignment list
+----------------------------------+----------------------------------+-------+----------------------------------+--------+--------+-----------+
| Role                             | User                             | Group | Project                          | Domain | System | Inherited |
+----------------------------------+----------------------------------+-------+----------------------------------+--------+--------+-----------+
| db335b47ae26492e9da33881087e80c6 | 1a96e4b649cb474da9506226a56ca7d6 |       | cfd7929faa4d456ba0633f4934ed0106 |        |        | False     |
| dea0722037a346b9a5dc790e39b0d017 | 62623ccda6ce4e4c82b10cd51521aad8 |       | d33724f9baf9444e9622d102d9541826 |        |        | False     |
| db335b47ae26492e9da33881087e80c6 | a24c9f7cffd740afbd1a4388fecadc34 |       | cfd7929faa4d456ba0633f4934ed0106 |        |        | False     |
| db335b47ae26492e9da33881087e80c6 | a6a881a6089843b9999b2a0a7397c5d7 |       | faf1dd393fae450b8afc29ebc9d9b6d1 |        |        | False     |
| db335b47ae26492e9da33881087e80c6 | a6a881a6089843b9999b2a0a7397c5d7 |       |                                  |        | all    | False     |
+----------------------------------+----------------------------------+-------+----------------------------------+--------+--------+-----------+
[root@controller ~]# openstack role list
+----------------------------------+--------+
| ID                               | Name   |
+----------------------------------+--------+
| 0d6def14a0df408f8834bd82065856a5 | member |
| 5feb9c7b483b46cf897af25ba7d8fa5a | reader |
| db335b47ae26492e9da33881087e80c6 | admin  |
| dea0722037a346b9a5dc790e39b0d017 | myrole |
+----------------------------------+--------+
[root@controller ~]# openstack user list
+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| a6a881a6089843b9999b2a0a7397c5d7 | admin     |
| 62623ccda6ce4e4c82b10cd51521aad8 | myuser    |
| a24c9f7cffd740afbd1a4388fecadc34 | glance    |
| 1a96e4b649cb474da9506226a56ca7d6 | placement |
+----------------------------------+-----------+
[root@controller ~]# openstack project list
+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| cfd7929faa4d456ba0633f4934ed0106 | service   |
| d33724f9baf9444e9622d102d9541826 | myproject |
| faf1dd393fae450b8afc29ebc9d9b6d1 | admin     |
+----------------------------------+-----------+

安装和配置组件

Install and configure components

安装包

Install the packages:

# yum install openstack-placement-api

编辑配置文件

Edit the /etc/placement/placement.conf file and complete the following actions:

In the [placement_database] section, configure database access:

[placement_database]
# ...
connection = mysql+pymysql://placement:PLACEMENT_DBPASS@controller/placement

In the [api] and [keystone_authtoken] sections, configure Identity service access:

[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_PASS

Populate the placement database:

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

结果

[root@controller ~]# 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)

完成安装

重启服务

# systemctl restart httpd

验证安装

增加admin命令行权限

$ . admin-openrc

执行状态检查,确保正确安装

$ placement-status upgrade check
+----------------------------------+
| Upgrade Check Results            |
+----------------------------------+
| Check: Missing Root Provider IDs |
| Result: Success                  |
| Details: None                    |
+----------------------------------+
| Check: Incomplete Consumers      |
| Result: Success                  |
| Details: None                    |
+----------------------------------+

结果

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

Run some commands against the placement API:

Install the osc-placement plugin:
先安装pip

[root@controller ~]# yum -y install epel-release
[root@controller ~]# yum -y install python-pip

再安装

$ pip install osc-placement

结果

[root@controller ~]# pip install osc-placement
Collecting osc-placement
  Downloading https://files.pythonhosted.org/packages/ed/06/0ae76da24c9ac10dbf802bc3629bba59b6c8ba41627bc5cc728a84dab793/osc-placement-3.2.0.tar.gz (56kB)
    100% |████████████████████████████████| 61kB 518kB/s
Requirement already satisfied (use --upgrade to upgrade): pbr>=2.0.0 in /usr/lib/python2.7/site-packages (from osc-placement)
Requirement already satisfied (use --upgrade to upgrade): six>=1.10.0 in /usr/lib/python2.7/site-packages (from osc-placement)
Requirement already satisfied (use --upgrade to upgrade): keystoneauth1>=3.3.0 in /usr/lib/python2.7/site-packages (from osc-placement)
Requirement already satisfied (use --upgrade to upgrade): simplejson>=3.16.0 in /usr/lib64/python2.7/site-packages (from osc-placement)
Requirement already satisfied (use --upgrade to upgrade): osc-lib>=1.2.0 in /usr/lib/python2.7/site-packages (from osc-placement)
Requirement already satisfied (use --upgrade to upgrade): oslo.utils>=3.37.0 in /usr/lib/python2.7/site-packages (from osc-placement)
Installing collected packages: osc-placement
  Running setup.py install for osc-placement ... done
Successfully installed osc-placement-3.2.0
You are using pip version 8.1.2, however version 22.0.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

List available resource classes and traits:

$ openstack --os-placement-api-version 1.2 resource class list --sort-column name
+----------------------------+
| name                       |
+----------------------------+
| DISK_GB                    |
| IPV4_ADDRESS               |
| ...                        |

$ openstack --os-placement-api-version 1.6 trait list --sort-column name
+---------------------------------------+
| name                                  |
+---------------------------------------+
| COMPUTE_DEVICE_TAGGING                |
| COMPUTE_NET_ATTACH_INTERFACE          |
| ...                                   |

结果
报错

[root@controller ~]#  openstack --os-placement-api-version 1.2 resource class list --sort-column name
Expecting value: line 1 column 1 (char 0)

应该是有个bug,文档上没有说明,根据网上说法是

chmod 640 /etc/placement/placement.conf
chown root:placement /etc/placement/placement.conf
以上权限应该本来就有

下面是关键,增加到VirtualHost的最后位置。
/etc/httpd/conf.d/00-placement-api.conf
<VirtualHost *:8778>
… 增加执行权限
<Directory /usr/bin>
    <IfVersion >= 2.4>
        Require all granted
    </IfVersion>
    <IfVersion < 2.4>
        Order allow,deny
        Allow from all
    </IfVersion>
</Directory>
</VirtualHost>

重启下httpd服务
重新执行

[root@controller placement]# openstack --os-placement-api-version 1.2 resource class list --sort-column name
+----------------------------+
| name                       |
+----------------------------+
| DISK_GB                    |
| FPGA                       |
| IPV4_ADDRESS               |
| MEMORY_MB                  |
| MEM_ENCRYPTION_CONTEXT     |
| NET_BW_EGR_KILOBIT_PER_SEC |
| NET_BW_IGR_KILOBIT_PER_SEC |
| NUMA_CORE                  |
| NUMA_MEMORY_MB             |
| NUMA_SOCKET                |
| NUMA_THREAD                |
| PCI_DEVICE                 |
| PCPU                       |
| PGPU                       |
| SRIOV_NET_VF               |
| VCPU                       |
| VGPU                       |
| VGPU_DISPLAY_HEAD          |
+----------------------------+
[root@controller placement]# openstack --os-placement-api-version 1.6 trait list --sort-column name
+---------------------------------------+
| name                                  |
+---------------------------------------+
| COMPUTE_DEVICE_TAGGING                |
| COMPUTE_GRAPHICS_MODEL_CIRRUS         |
| COMPUTE_GRAPHICS_MODEL_GOP            |
| COMPUTE_GRAPHICS_MODEL_NONE           |
| COMPUTE_GRAPHICS_MODEL_QXL            |

修改完整的配置文件

/etc/placement/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 = 123456

[oslo_policy]

[placement]

[placement_database]

connection = mysql+pymysql://placement:123456@controller/placement 

[profiler]

文章来源:https://blog.csdn.net/gsl371/article/details/123902098
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。