IT/Openstack

[Openstack-rocky] Ubuntu에 Openstack 설치 하기(3) - Glance(image)설치

louky 2019. 8. 16. 11:55
반응형

Openstack service PKG install

 

code-name 

  •    keystone

  •    glance

  •    nova

  •    neutron 

 

공통 환경 변수 

controller_name="controller"
controller_ip="10.168.0.101"

DB_PW="maria.123"

KEYSTONE_PW="keystone.123"

GLANCE_PW="glance.123"

RABBIT_PW="rabbit.123"

NOVA_PW="nova.123"

PLACEMENT_PW="placement.123"

NEUTRON_PW="neutron.123"

 

 

 

Glance install (controller node)

1. glance database 생성 

- DB생성 전 확인 

root@rocky-osc:~# mysql -uroot -pmaria.123 -e "show databases;"
+--------------------+
| Database           |
+--------------------+
| information_schema |
| keystone           |
| mysql              |
| performance_schema |
+--------------------+

1-1.  DB 생성

root@rocky-osc:~# mysql -uroot -pmaria.123 -e "CREATE DATABASE glance;"

- DB생성 후 확인 

root@rocky-osc:~# mysql -uroot -pmaria.123 -e "show databases;"
+--------------------+
| Database           |
+--------------------+
| glance             |
| information_schema |
| keystone           |
| mysql              |
| performance_schema |
+--------------------+

1-2, glance database 권한 설정 

root@rocky-osc:~# mysql -uroot -pmaria.123 -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance.123';"
root@rocky-osc:~# mysql -uroot -pmaria.123 -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance.123';"

 

1-3. openstack glance user 생성 

- openstack admin 환경 변수 loading

root@rocky-osc:~# source /root/admin_openrc

- glance user  생성 

root@rocky-osc:~# openstack user create --domain default --password glance.123 glance
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 2690c175ca73424ba2d2e47f2f698014 |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

- admin role 에 glance user 추가 (출력 없음)

root@rocky-osc:~# openstack role add --project service --user glance admin

1-4. glance service  생성 

root@rocky-osc:~# openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | b01d4d985d3a40d2adcd1053661ecd73 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

 

1-5. glance endpoint 생성 

root@rocky-osc:~# openstack endpoint create --region RegionOne image public http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 7f9fe93a0687422cb56c8357778f07d0 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | b01d4d985d3a40d2adcd1053661ecd73 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
root@rocky-osc:~# openstack endpoint create --region RegionOne image internal http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | b6a0ec47b152469696c3238ff4226f1b |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | b01d4d985d3a40d2adcd1053661ecd73 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
root@rocky-osc:~# openstack endpoint create --region RegionOne image admin http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | ff5ec50939d849d38c79f8ff939d9948 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | b01d4d985d3a40d2adcd1053661ecd73 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

 

2. glance install 

2-1. PKG install 

root@rocky-osc:~# apt install glance -y

 

2-2. Config 원본 백업

root@rocky-osc:~# mv -f /etc/glance/glance-api.conf /etc/glance/glance-api.conf.orig
root@rocky-osc:~# mv -f /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.orig

 

2-3. Config 수정

  • /etc/glance/glance-api.conf

echo "[DEFAULT]
[cors]

[database]
#connection = sqlite:////var/lib/glance/glance.sqlite
connection = mysql+pymysql://glance:glance.123@controller/glance
backend = sqlalchemy

[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

[image_format]
disk_formats = ami,ari,aki,vhd,vhdx,vmdk,raw,qcow2,vdi,iso,ploop.root-tar

[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = glance.123

[matchmaker_redis]

[oslo_concurrency]

[oslo_messaging_amqp]

[oslo_messaging_kafka]

[oslo_messaging_notifications]

[oslo_messaging_rabbit]

[oslo_messaging_zmq]

[oslo_middleware]

[oslo_policy]

[paste_deploy]
flavor = keystone

[profiler]

[store_type_location_strategy]

[task]

[taskflow_executor]" > /etc/glance/glance-api.conf

 

  • /etc/glance/glance-registry.conf

echo "[DEFAULT]

[database]
#connection = sqlite:////var/lib/glance/glance.sqlite
connection = mysql+pymysql://glance:glance.123@controller/glance
backend = sqlalchemy

[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = glance.123

[matchmaker_redis]

[oslo_messaging_amqp]

[oslo_messaging_kafka]

[oslo_messaging_notifications]

[oslo_messaging_rabbit]

[oslo_messaging_zmq]

[oslo_policy]

[paste_deploy]
flavor = keystoneGLANCE_PW

[profiler]" > /etc/glance/glance-registry.conf

 

  • 퍼미션 변경 

root@rocky-osc:~# chown -R root.glance /etc/glance/

** 퍼미션 변경 확인 
root@rocky-osc:~# ls -al /etc/glance/glance-*.conf
-rw-r--r-- 1 root glance   953  3월  6 16:25 /etc/glance/glance-api.conf
-rw-r--r-- 1 root glance 85148  8월 30  2018 /etc/glance/glance-cache.conf
-rw-r--r-- 1 root glance  9511  8월 30  2018 /etc/glance/glance-manage.conf
-rw-r--r-- 1 root glance   659  3월  6 16:29 /etc/glance/glance-registry.conf
-rw-r--r-- 1 root glance 77774  8월 30  2018 /etc/glance/glance-scrubber.conf

 

2-4. glance databases tables 생성 

  • DB tables 생성 전 확인 

root@rocky-osc:~# mysql -uroot -pmaria.123 glance -e "show tables;"

 

  • DB tables  생성 

root@rocky-osc:~# su -s /bin/sh -c "glance-manage db_sync" glance
/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py:1352: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo_db.sqlalchemy.enginefacade
  expire_on_commit=expire_on_commit, _conf=conf)
2019-03-06 16:35:05.628 18185 INFO alembic.runtime.migration [-] Context impl MySQLImpl.
2019-03-06 16:35:05.629 18185 INFO alembic.runtime.migration [-] Will assume non-transactional DDL.
2019-03-06 16:35:05.635 18185 INFO alembic.runtime.migration [-] Context impl MySQLImpl.
2019-03-06 16:35:05.635 18185 INFO alembic.runtime.migration [-] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> liberty, liberty initial
INFO  [alembic.runtime.migration] Running upgrade liberty -> mitaka01, add index on created_at and updated_at columns of 'images' table
INFO  [alembic.runtime.migration] Running upgrade mitaka01 -> mitaka02, update metadef os_nova_server
INFO  [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_expand01, add visibility to images
INFO  [alembic.runtime.migration] Running upgrade ocata_expand01 -> pike_expand01, empty expand for symmetry with pike_contract01
INFO  [alembic.runtime.migration] Running upgrade pike_expand01 -> queens_expand01
INFO  [alembic.runtime.migration] Running upgrade queens_expand01 -> rocky_expand01, add os_hidden column to images table
INFO  [alembic.runtime.migration] Running upgrade rocky_expand01 -> rocky_expand02, add os_hash_algo and os_hash_value columns to images table
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Upgraded database to: rocky_expand02, current revision(s): rocky_expand02
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Database migration is up to date. No migration needed.
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_contract01, remove is_public from images
INFO  [alembic.runtime.migration] Running upgrade ocata_contract01 -> pike_contract01, drop glare artifacts tables
INFO  [alembic.runtime.migration] Running upgrade pike_contract01 -> queens_contract01
INFO  [alembic.runtime.migration] Running upgrade queens_contract01 -> rocky_contract01
INFO  [alembic.runtime.migration] Running upgrade rocky_contract01 -> rocky_contract02
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Upgraded database to: rocky_contract02, current revision(s): rocky_contract02
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Database is synced successfully.

 

  • DB tables  생성 후 확인 

root@rocky-osc:~# mysql -uroot -pmaria.123 glance -e "show tables;"
+----------------------------------+
| Tables_in_glance                 |
+----------------------------------+
| alembic_version                  |
| image_locations                  |
| image_members                    |
| image_properties                 |
| image_tags                       |
| images                           |
| metadef_namespace_resource_types |
| metadef_namespaces               |
| metadef_objects                  |
| metadef_properties               |
| metadef_resource_types           |
| metadef_tags                     |
| migrate_version                  |
| task_info                        |
| tasks                            |
+----------------------------------+

 

2-5. glance daemon 재시작 

root@rocky-osc:~# service glance-registry restart
root@rocky-osc:~# service glance-api restart

 

 

3. glance  확인 

3-1. test image download

root@rocky-osc:~# mkdir ~/glance_image

root@rocky-osc:~# wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img --progress=bar -O ~/glance_image/cirros-0.4.0-x86_64-disk.img

3-2.  admin 환경 변수 loading

root@rocky-osc:~# source admin_openrc

 

3-3. glance image 생성 

root@rocky-osc:~# openstack image create "cirros" \
 --file /root/glance_image/cirros-0.4.0-x86_64-disk.img \
 --disk-format qcow2 \
 --container-format bare  \
 --public
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                                                                                                      |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum         | 443b7623e27ecf03dc9e01ee93f67afe                                                                                                                                                           |
| container_format | bare                                                                                                                                                                                       |
| created_at       | 2019-03-06T07:45:13Z                                                                                                                                                                       |
| disk_format      | qcow2                                                                                                                                                                                      |
| file             | /v2/images/4d936711-fd88-4d79-b0fa-cb51c409ad16/file                                                                                                                                       |
| id               | 4d936711-fd88-4d79-b0fa-cb51c409ad16                                                                                                                                                       |
| min_disk         | 0                                                                                                                                                                                          |
| min_ram          | 0                                                                                                                                                                                          |
| name             | cirros                                                                                                                                                                                     |
| owner            | 321aff2a498a495283c761d264a41ba5                                                                                                                                                           |
| properties       | os_hash_algo='sha512', os_hash_value='6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e2161b5b5186106570c17a9e58b64dd39390617cd5a350f78', os_hidden='False' |
| protected        | False                                                                                                                                                                                      |
| schema           | /v2/schemas/image                                                                                                                                                                          |
| size             | 12716032                                                                                                                                                                                   |
| status           | active                                                                                                                                                                                     |
| tags             |                                                                                                                                                                                            |
| updated_at       | 2019-03-06T07:45:13Z                                                                                                                                                                       |
| virtual_size     | None                                                                                                                                                                                       |
| visibility       | public                                                                                                                                                                                     |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
root@rocky-osc:~#

 

 

 

3-4. glance image  생성 확인 

root@rocky-osc:~# openstack image list
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| 4d936711-fd88-4d79-b0fa-cb51c409ad16 | cirros | active |
+--------------------------------------+--------+--------+
반응형