가상 서버들의 OS 이미지나 디스크들을 관리하는 서비스로 코드명은 glance이다.

glance 설치전에 먼저 환경 설정부터 하며 glance 환경설정 및 설치도 controller 노드에서만 수행한다.

우선 glance DB를 만들고 glance 계정 생성 및 접근권한을 부여한다. 계정의 패스워드는 GLANCE_DBPASS 부분을 변경해주면 된다.

 

[root@controller ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 43
Server version: 5.5.44-MariaDB MariaDB Server

 

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

MariaDB [(none)]> CREATE DATABASE glance;
Query OK, 1 row affected (0.00 sec)

 

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
    IDENTIFIED BY 'GLANCE_DBPASS';
Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'controller' \
    IDENTIFIED BY 'GLANCE_DBPASS';
Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
    IDENTIFIED BY 'GLANCE_DBPASS';
Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]> quit
Bye

 

openstack command를 cli에서 원할하게 수행하기 위해 identity에서 만들었던 스크립트를 수행한다.

identity에서 그대로 이어지면 생략해도 됨.

[root@controller ~]# source admin-openrc.sh

 

 

glance 유저를 생성 후 service project 및 admin role을 부여한다.

[root@controller ~]# openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | default                          |
| enabled   | True                             |
| id        | a8628bbd61b14dbfa7b4129882da4751 |
| name      | glance                           |
+-----------+----------------------------------+

[root@controller ~]# openstack role add --project service --user glance admin
 

 

glance 서비스 entity를 만든다.

[root@controller ~]# openstack service create --name glance \
   --description "OpenStack Image service" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image service          |
| enabled     | True                             |
| id          | 9dd21e6f93a0419eafef90bc35db9a86 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

 

 

identity 서비스와 마찬가지로 public, internal, admin으로 접근시 사용할 endpoint를 생성한다.

[root@controller ~]# openstack endpoint create --region RegionOne \
   image public http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | d54bdb0434294a8b867fdbad08dec3ae |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 9dd21e6f93a0419eafef90bc35db9a86 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
   image internal http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 3163e3d3732a4ce2b05246a34ddaeb2e |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 9dd21e6f93a0419eafef90bc35db9a86 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
   image admin http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | a6eab47cba534e3d84269ea111f8c5ea |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 9dd21e6f93a0419eafef90bc35db9a86 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

 

 

glance환경 설정이 다 되었으면 glance를 설치한다.

 

[root@controller ~]# yum install -y openstack-glance python-glance python-glanceclient
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.neowiz.com
 * extras: ftp.neowiz.com
 * updates: ftp.neowiz.com

Package 1:python-glanceclient-1.1.0-1.el7.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check

...(중략)...

  suitesparse.x86_64 0:4.0.2-10.el7
  tbb.x86_64 0:4.1-9.20130314.el7

Complete!
[root@controller ~]#

 

/etc/glance/glance-api.conf 파일을 열어 다음과 같이 변경한다.

[database] 섹션을 찾아 아래와 같이 수정한다. glance DB 패스워드 변경시는 아래 GLANCE_DBPASS을 변경한다.

[keystone_authtoken] 과 [paste_deploy] 섹션을 찾아 identity 서비스에 접근할수 있게 수정한다. glance 패스워드 변경시는 GLANCE_PASS 을 변경한다.

[glance_store] 섹션에서 이미지 파일들이 저장되는 파일시스템을 지정한다. /var/lib/glance/images/ 가 default

[default] 에서 notification_driver를 noop으로 설정

(옵션)[DEFAULT] 섹션에서 트러블슈팅시 도움이 될수 있게 verbose를 활성화한다.

[DEFAULT]
...
notification_driver = noop

...
verbose = True 


 

[database]
...

connection=mysql://glance:GLANCE_DBPASS@controller/glance

 

[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = GLANCE_PASS

[paste_deploy]
...
flavor = keystone

 

[glance_store]
...
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

 

 

 

/etc/glance/glance-registry.conf 파일을 열어 glance_store 섹션 제외하고 위와 동일하게 변경한다.

 

[DEFAULT]
...
notification_driver = noop

 

[database]
...

connection=mysql://glance:GLANCE_DBPASS@controller/glance

 

[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = GLANCE_PASS

[paste_deploy]
...
flavor = keystone

 

glance DB의 테이블을 만든다.

[root@controller ~]# su -s /bin/sh -c "glance-manage db_sync" glance
No handlers could be found for logger "oslo_config.cfg"
[root@controller ~]#

 

glance 서비스 시작 및 부팅시 시작 서비스로 등록

[root@controller ~]# systemctl enable openstack-glance-api.service openstack-glance-registry.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service to /usr/lib/systemd/system/openstack-glance-registry.service.
[root@controller ~]# systemctl start openstack-glance-api.service openstack-glance-registry.service

 

 

설치가 끝났으면 확인을 한다.

우선 환경설정 스크립트에 이미지 서비스에 관한 내용을 추가하고 다시 적용한다.

 

[root@controller ~]# echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh
export OS_IMAGE_API_VERSION=2
[root@controller ~]# source admin-openrc.sh

 

이미지 서비스가 잘 작동하는지 테스트를 위해 OS 이미지를 필요함.

가벼운 cirros 이미지로 다운 받는다.

wget이 없다면 yum을 이용해 다운 받는다.

 

[root@controller ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
--2016-02-27 22:53:50--  http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
Resolving download.cirros-cloud.net (download.cirros-cloud.net)... 69.163.241.114
Connecting to download.cirros-cloud.net (download.cirros-cloud.net)|69.163.241.114|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13287936 (13M) [text/plain]
Saving to: ‘cirros-0.3.4-x86_64-disk.img.1’

100%[================================================================>] 13,287,936  4.16MB/s   in 3.0s

2016-02-27 22:53:54 (4.16 MB/s) - ‘cirros-0.3.4-x86_64-disk.img.1’ saved [13287936/13287936]

 

 

다운 받은 이미지를 grance에 등록한다.

[root@controller ~]# glance image-create --name "cirros" \
  --file cirros-0.3.4-x86_64-disk.img \
  --disk-format qcow2 --container-format bare \
  --visibility public --progress
[=============================>] 100%
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6     |
| container_format | bare                                 |
| created_at       | 2016-03-01T22:09:23Z                 |
| disk_format      | qcow2                                |
| id               | 49338c63-033c-40a3-abdd-d6410799de24 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | cirros                               |
| owner            | 94f9c25aaa4246b0915afacca2d65c22     |
| protected        | False                                |
| size             | 13287936                             |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2016-03-01T22:09:23Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+

 

 

이미지가 잘 등록되었는지 확인한다.

[root@controller ~]# glance image-list
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| 49338c63-033c-40a3-abdd-d6410799de24 | cirros |
+--------------------------------------+--------+

 

 

 

 

 

+ Recent posts