IT/Openstack

[Openstack - Train] Centos에 설치하기(4) - Placement

louky 2019. 11. 4. 14:28
반응형

placement service는 Compute node의  인벤토리 및 사용량을 추적하는 데 사용되는 HTTP API를 제공한다. 

 

1) DB생성 및 권한 설정 

## DB 생성 전 확인 
[root@controller ~]# mysql -u${DB_USER} -p${DB_PASSWD} -e "show databases;"
+--------------------+
| Database           |
+--------------------+
| glance             |
| information_schema |
| keystone           |
| mysql              |
| performance_schema |
+--------------------+

## DB 생성
[root@controller ~]# mysql -u${DB_USER} -p${DB_PASSWD} -e "CREATE DATABASE placement;"

## DB 생성 후 확인
[root@controller ~]# mysql -u${DB_USER} -p${DB_PASSWD} -e "show databases;"
+--------------------+
| Database           |
+--------------------+
| glance             |
| information_schema |
| keystone           |
| mysql              |
| performance_schema |
| placement          |
+--------------------+

## DB권한 설정 전 확인 
[root@controller ~]# mysql -u${DB_USER} -p${DB_PASSWD} mysql -e "select Host,User,PASSWORD from user where User='placement';"

## DB권한 설정
[root@controller ~]# mysql -u${DB_USER} -p${DB_PASSWD} -e "GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY 'placement.123';"
[root@controller ~]# mysql -u${DB_USER} -p${DB_PASSWD} -e "GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'placement.123';"

## DB 권한 적용
[root@controller ~]# mysql -u${DB_USER} -p${DB_PASSWD} -e "Flush Privileges;"

## DB권한 확인
[root@controller ~]# mysql -u${DB_USER} -p${DB_PASSWD} mysql -e "select Host,User,PASSWORD from user where User='placement';"
+-----------+-----------+-------------------------------------------+
| Host      | User      | PASSWORD                                  |
+-----------+-----------+-------------------------------------------+
| localhost | placement | *21E1B44A110506D08AB9C591323BE23D6C122233 |
| %         | placement | *21E1B44A110506D08AB9C591323BE23D6C122233 |
+-----------+-----------+-------------------------------------------+
[root@controller ~]#

2) Service User 생성 및 role 권한 설정

## Service User 생성
[root@controller ~] (admin-openrc):~# openstack user create --domain default --password placement.123 placement
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | f2bc49422c66429492a00e0912a38a81 |
| name                | placement                        |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

## role 권한 설정
[root@controller ~] (admin-openrc):~# openstack role add --project service --user placement admin

3) Service 생성

[root@controller ~] (admin-openrc):~# openstack service create --name placement --description "Placement API" placement
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Placement API                    |
| enabled     | True                             |
| id          | cecf149f7c5944a1b59d41b1689bdc12 |
| name        | placement                        |
| type        | placement                        |
+-------------+----------------------------------+

4) endpoint 생성

[root@controller ~] (admin-openrc):~# openstack endpoint create --region RegionOne placement public http://controller:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 47d6ca05a9474d3482bc727368f39f86 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | cecf149f7c5944a1b59d41b1689bdc12 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+
[root@controller ~] (admin-openrc):~# openstack endpoint create --region RegionOne placement internal http://controller:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 09c509c49be942739aab1935c15c1e44 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | cecf149f7c5944a1b59d41b1689bdc12 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+
[root@controller ~] (admin-openrc):~# openstack endpoint create --region RegionOne placement admin http://controller:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | c2019e2fb09e440e975c94eac8b6f15d |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | cecf149f7c5944a1b59d41b1689bdc12 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+

5) PKG 설치

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

 

6) config 백업

## config 원본파일 백업(파일명 변경)
[root@controller ~]# mv  /etc/placement/placement.conf  /etc/placement/placement.conf.orig

## 주석을 제외한 필요한  필드만 파일로 리다이렉션
[root@controller ~]# cat /etc/placement/placement.conf.orig  | grep -Ev "^#|^$" | sed -e "s/\[/\n\[/g" > /etc/placement/placement.conf

## 이전 파일의 퍼미션 확인
[root@controller ~]# ls -al /etc/placement/placement.conf.orig
-rw-r----- 1 root placement 25512 10월 16 22:51 /etc/placement/placement.conf.orig

## 이전파일과 동일한 퍼미션 설정
[root@controller ~]# chown root.placement /etc/placement/placement.conf
[root@controller ~]# chmod 640 /etc/placement/placement.conf

7) config 수정 

[root@controller ~]# cat /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 = placement.123

[oslo_policy]

[placement]

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

[profiler]

 

 

/etc/httpd/conf.d/00-placement-api.conf 파일에 config 추가 
/etc/httpd/conf.d/00-placement-api.conf 파일이 없다면 "/etc/httpd/conf.d"하위의 placement-api.conf와 비슷한 파일이 있는지 확인하고 있을 경우 해당 파일에 추가 한다. 

 

실행 Command!!!

[root@controller ~] # echo '<Directory /usr/bin>

   <IfVersion >= 2.4>
      Require all granted
   </IfVersion>

   <IfVersion < 2.4>
      Order allow,deny
      Allow from all
   </IfVersion>
</Directory>' >> /etc/httpd/conf.d/00-placement-api.conf

 

실제 파일 내용!!!!

[root@controller ~] (admin-openrc):~# cat /etc/httpd/conf.d/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>

   <IfVersion >= 2.4>
      Require all granted
   </IfVersion>

   <IfVersion < 2.4>
      Order allow,deny
      Allow from all
   </IfVersion>
</Directory>

 

 

8) Placement DB내 table생성

## Table 생성 전 확인
[root@ibcontroller ~]# mysql -u${DB_USER} -p${DB_PASSWD} placement -e "show tables;"


## Table 생성 
[root@ibcontroller ~]# su -s /bin/sh -c "placement-manage db sync" placement


## Table 생성  후 확인 
[root@ibcontroller ~]# mysql -u${DB_USER} -p${DB_PASSWD} placement -e "show tables;"
+------------------------------+
| Tables_in_placement          |
+------------------------------+
| alembic_version              |
| allocations                  |
| consumers                    |
| inventories                  |
| placement_aggregates         |
| projects                     |
| resource_classes             |
| resource_provider_aggregates |
| resource_provider_traits     |
| resource_providers           |
| traits                       |
| users                        |
+------------------------------+

 

9) Apach Daemon  재시작

[root@controller ~]# systemctl restart httpd

 

 

 

 

 

 

 

 

 

반응형