Openstack(八)部署鏡像服務glance

 

8.1glance鏡像服務介紹

Glance是OpenStack鏡像服務組件,glance服務默認監聽在9292端口,其接收REST API請求,而後經過其餘模塊(glance-registry及image store)來完成諸如鏡像的獲取、上傳、刪除等操做,Glance提供restful API能夠查詢虛擬機鏡像的metadata,而且能夠得到鏡像,經過Glance,虛擬機鏡像能夠被存儲到多種存儲上,好比簡單的文件存儲或者對象存儲(好比OpenStack中swift項目)是在建立虛擬機的時候,須要先把鏡像上傳到glance,對鏡像的列出鏡像、刪除鏡像和上傳鏡像都是經過glance進行理,glance有兩個主要的服務,一個是glace-api接收鏡像的刪除上傳和讀取,一個是glance-Registry。html

glance-registry負責與mysql數據交互,用於存儲或獲取鏡像的元數據(metadata),提供鏡像元數據相關的REST接口,經過glance-registry能夠向數據庫中寫入或獲取鏡像的各類數據,glance-registyr監聽的端口是9191,glance數據庫中有兩張表,一張是glance表,一張是imane property表,image表保存了鏡像格式、大小等信息,image property表保存了鏡像的定製化信息。python

image store 是一個存儲的接口層,經過這個接口glance能夠獲取鏡像,image store支持的存儲有Amazon的S三、openstack自己的swift、還有ceph、glusterFS、sheepdog等分佈式存儲,image store是鏡像保存與讀取的接口,可是它只是一個接口,具體的實現須要外部的支持,glance不須要配置消息隊列,可是須要配置數據庫和keystone。mysql

官方部署文檔:https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/glance.htmllinux

8.2控制端安裝glance

# yum install -y openstack-glancesql

8.3配置glance服務

8.3.1建立並初始化數據庫

# mysql數據庫

> create database glance;swift

>  grant all on glance.* to 'glance'@'%' identified by 'glance';vim

8.3.2使用VIP驗證數據庫

 

 

8.3.3編輯配置文件

#  vim /etc/glance/glance-api.confapi

1798:[database]服務器

1826:connection = mysql+pymysql://glance:glance@192.168.10.100/glance

1915:[glance_store]

1942:stores = file,http

1974:default_store = file

2293:filesystem_store_datadir = /var/lib/glance/images

3282:[keystone_authtoken]

3283:auth_uri = http://192.168.10.100:5000

3284:auth_url = http://192.168.10.100:35357

3285:memcached_servers = 192.168.10.100:11211

3286:auth_type = password

3287:project_domain_name = default

3288:user_domain_name = default

3289:project_name = service

3290:username = glance

3291:password = glance

4243:[paste_deploy]

4268:flavor = keystone

 

# vim glance-registry.conf

1088:[database]

1116:connection = mysql+pymysql://glance:glance@192.168.10.100/glance

1205:[keystone_authtoken]

1206:auth_uri = http://192.168.10.100:5000

1207:auth_url = http://192.168.10.100:35357

1208:memcached_servers = 192.168.10.100:11211

1209:auth_type = password

1210:project_domain_name = default

1211:user_domain_name = default

1212:project_name = service

1213:username = glance

1214:password = glance

2137:[paste_deploy]

2162:flavor = keystone

 

8.3.4初始化glance數據庫

# su -s /bin/sh -c "glance-manage db_sync" glance

Option "verbose" from group "DEFAULT" is deprecated for removal.  Its value may be silently ignored in the future.

/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py:1241: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo

_db.sqlalchemy.enginefacade  expire_on_commit=expire_on_commit, _conf=conf)

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 -> ocata01, add visibility to and remove is_public from images

INFO  [alembic.runtime.migration] Context impl MySQLImpl.

INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

Upgraded database to: ocata01, current revision(s): ocata01

 

8.3.5配置haproxy代理glance

#負載服務器

# vim  /etc/haproxy/haproxy.cfg

listen glance-api

    bind 192.168.10.100:9292

    mode tcp

    log global

    balance source

    server glance-api1 192.168.10.201:9292 check inter 5000 rise 3 fall 3

 

listen glance

    bind 192.168.10.100:9191

    mode tcp

    log global

    balance source

server glance1 192.168.10.201:9191 check inter 5000 rise 3 fall 3

8.3.6驗證haproxy端口

# systemctl  restart haproxy

8.4啓動glance並設置爲開機啓動

# systemctl enable openstack-glance-api.service openstack-glance-registry.service

# systemctl start openstack-glance-api.service openstack-glance-registry.service

8.5驗證glance端口

8.6 glance服務日誌

8.7glance服務註冊

#控制端配置

# source  admin-ocata.sh

8.7.1建立glance服務:

#  openstack service create --name glance --description "OpenStack Image" image

+-------------+----------------------------------+

| Field       | Value                            |

+-------------+----------------------------------+

| description | OpenStack Image                  |

| enabled     | True                             |

| id          | d032525e64644c55a9e89a2fe4dfc950 |

| name        | glance                           |

| type        | image                            |

+-------------+----------------------------------+

8.7.2建立公有endpoint:

# openstack endpoint create --region RegionOne image public   http://192.168.10.100:9292

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           | 222519c9932c4a6cb63a6aaab0b31533 |

| interface    | public                           |

| region       | RegionOne                        |

| region_id    | RegionOne                        |

| service_id   | d032525e64644c55a9e89a2fe4dfc950 |

| service_name | glance                           |

| service_type | image                            |

| url          | http://192.168.10.100:9292       |

+--------------+----------------------------------+

8.7.3建立私有endpoint:

# openstack endpoint create --region RegionOne image internal http://192.168.10.100:9292

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           | 7b5e62d0c32d4947b8e726fcd4a1472f |

| interface    | internal                         |

| region       | RegionOne                        |

| region_id    | RegionOne                        |

| service_id   | d032525e64644c55a9e89a2fe4dfc950 |

| service_name | glance                           |

| service_type | image                            |

| url          | http://192.168.10.100:9292       |

+--------------+----------------------------------+

8.7.4建立管理endpoint:

[root@linux-host1 ~]# openstack endpoint create --region RegionOne image admin   http://192.168.10.100:9292

+--------------+----------------------------------+

| Field        | Value                            |

+--------------+----------------------------------+

| enabled      | True                             |

| id           | 2d4ed97d78cf4117bb7b57c020379ec5 |

| interface    | admin                            |

| region       | RegionOne                        |

| region_id    | RegionOne                        |

| service_id   | d032525e64644c55a9e89a2fe4dfc950 |

| service_name | glance                           |

| service_type | image                            |

| url          | http://192.168.10.100:9292       |

+--------------+----------------------------------+

8.7.5驗證glance服務註冊

8.8驗證glance服務

8.9測試glance上傳鏡像:

#  wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

# source  admin-ocata.sh

# openstack image create "cirros"   --file  /root/cirros-0.3.5-x86_64-disk.img   --disk-format qcow2 --container-format bare   --public

 

+------------------+------------------------------------------------------+

| Field            | Value                                                |

+------------------+------------------------------------------------------+

| checksum         | f8ab98ff5e73ebab884d80c9dc9c7290                     |

| container_format | bare                                                 |

| created_at       | 2017-09-14T14:16:56Z                                 |

| disk_format      | qcow2                                                |

| file             | /v2/images/172ac611-38b5-4ac5-8b04-b64ab6ee4481/file |

| id               | 172ac611-38b5-4ac5-8b04-b64ab6ee4481                 |

| min_disk         | 0                                                    |

| min_ram          | 0                                                    |

| name             | cirros                                               |

| owner            | 62577e15f178420ba85eda9fce49db86                     |

| protected        | False                                                |

| schema           | /v2/schemas/image                                    |

| size             | 13267968                                             |

| status           | active                                               |

| tags             |                                                      |

| updated_at       | 2017-09-14T14:16:57Z                                 |

| virtual_size     | None                                                 |

| visibility       | public                                               |

+------------------+------------------------------------------------------+

8.10驗證glance鏡像

#  glance image-list

#  openstack image list

相關文章
相關標籤/搜索