OpenStack-liberty版Glance服務部署(二)
阿新 • • 發佈:2018-10-07
c4c symlink 用戶 服務 NPU store use upd ken Glance鏡像服務:
Glance主要由三部分構成:glance-api、glance-registry以及image store
Glance-api:接受系統鏡像的創建、刪除、讀取請求。
Glance-Registry:雲系統的鏡像註冊服務
Glance主要由三部分構成:glance-api、glance-registry以及image store
Glance-api:接受系統鏡像的創建、刪除、讀取請求。
Glance-Registry:雲系統的鏡像註冊服務
Glance安裝:
[root@hostnamelinux-node1 ~]# yum -y install openstack-glance python-glance python-glanceclient [root@hostnamelinux-node1 ~]# vim /etc/glance/glance-api.conf [database] connection=mysql://glance:[email protected]/glance [root@hostnamelinux-node1 ~]# vim /etc/glance/glance-registry.conf [database] connection=mysql://glance:[email protected]/glance
同步數據庫:
[root@hostnamelinux-node1 ~]# su -s /bin/sh -c "glance-manage db_sync" glance
No handlers could be found for logger "oslo_config.cfg"(可以忽略)
[root@hostnamelinux-node1 ~]# mysql -uglance -pglance -h192.168.56.11 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 10.1.20-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. MariaDB [(none)]> use glance; Database changed MariaDB [glance]> show tables; +----------------------------------+ | Tables_in_glance | +----------------------------------+ | artifact_blob_locations | | artifact_blobs | | artifact_dependencies | | artifact_properties | | artifact_tags | | artifacts | | 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 | +----------------------------------+ 20 rows in set (0.00 sec) MariaDB [glance]> exit Bye
創建glance用戶:
[root@hostnamelinux-node1 ~]# openstack user create --domain default --password=glance glance +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | default | | enabled | True | | id | 85b0cebbbb9f4cc890cdeff577ee0989 | | name | glance | +-----------+----------------------------------+
將glance用戶加入到service項目並賦予admin權限;[root@hostnamelinux-node1 ~]# openstack role add --project service --user glance admin
配置glance:
[root@hostnamelinux-node1 ~]# vim /etc/glance/glance-api.conf
[keystone_authtoken]
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance
[paste_deploy]
flavor=keystone
[DEFAULT]
verbose=True
notification_driver = noop
[glance_store]
default_store=file
filesystem_store_datadir=/var/lib/glance/images/
[root@hostnamelinux-node1 ~]# vim /etc/glance/glance-registry.conf
[keystone_authtoken]
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance
[paste_deploy]
flavor=keystone
[root@hostnamelinux-node1 ~]# grep ‘^[a-z]‘ /etc/glance/glance-api.conf
verbose=True
notification_driver = noop
connection=mysql://glance:[email protected]/glance
default_store=file
filesystem_store_datadir=/var/lib/glance/images/
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance
flavor=keystone
[root@hostnamelinux-node1 ~]# grep ‘^[a-z]‘ /etc/glance/glance-registry.conf
connection=mysql://glance:[email protected]/glance
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = glance
flavor=keystone
啟動glance服務:
[root@hostnamelinux-node1 ~]# systemctl enable openstack-glance-api
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service.
[root@hostnamelinux-node1 ~]# systemctl enable openstack-glance-registry
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service to /usr/lib/systemd/system/openstack-glance-registry.service.
[root@hostnamelinux-node1 ~]# systemctl start openstack-glance-api
[root@hostnamelinux-node1 ~]# systemctl start openstack-glance-registry
openstack-glance-api監聽端口9292,openstack-glance-registry監聽端口9191;
[root@hostnamelinux-node1 ~]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 970/beam.smp
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1427/master
tcp 0 0 0.0.0.0:9191 0.0.0.0:* LISTEN 13004/python2
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 970/beam.smp
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 2105/memcached
tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 12983/python2
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 969/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1427/master
tcp6 0 0 :::35357 :::* LISTEN 3754/httpd
tcp6 0 0 :::5000 :::* LISTEN 3754/httpd
tcp6 0 0 :::5672 :::* LISTEN 970/beam.smp
tcp6 0 0 :::3306 :::* LISTEN 1250/mysqld
tcp6 0 0 ::1:11211 :::* LISTEN 2105/memcached
tcp6 0 0 :::80 :::* LISTEN 3754/httpd
tcp6 0 0 :::22 :::* LISTEN 969/sshd
keytone註冊glance服務:
創建glance服務:
[root@hostnamelinux-node1 ~]# openstack service create --name glance --description "OpenStack Image service" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image service |
| enabled | True |
| id | d7f04da42efc4c6c8b75c1848385598c |
| name | glance |
| type | image |
+-------------+----------------------------------+
外網註冊:
[root@hostnamelinux-node1 ~]# openstack endpoint create --region RegionOne image public http://192.168.56.11:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 08ee7445c6094fcaa8499f6223cd055f |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | d7f04da42efc4c6c8b75c1848385598c |
| service_name | glance |
| service_type | image |
| url | http://192.168.56.11:9292 |
+--------------+----------------------------------+
內網註冊:
[root@hostnamelinux-node1 ~]# openstack endpoint create --region RegionOne image internal http://192.168.56.11:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 95134907b0b547f9a1e2c0cbf2a10137 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | d7f04da42efc4c6c8b75c1848385598c |
| service_name | glance |
| service_type | image |
| url | http://192.168.56.11:9292 |
+--------------+----------------------------------+
admin註冊:
[root@hostnamelinux-node1 ~]# openstack endpoint create --region RegionOne image admin http://192.168.56.11:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | b8892b9813bc4f43af23bfeb373534b7 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | d7f04da42efc4c6c8b75c1848385598c |
| service_name | glance |
| service_type | image |
| url | http://192.168.56.11:9292 |
+--------------+----------------------------------+
glance環境變量:
[root@hostnamelinux-node1 ~]# echo "export OS_IMAGE_API_VERSION=2" > | tee -a admin-openrc.sh demo-openrc.sh
export OS_IMAGE_API_VERSION=2
[root@hostnamelinux-node1 ~]# cat admin-openrc.sh
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_AUTH_URL=http://192.168.56.11:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
[root@hostnamelinux-node1 ~]# cat demo-openrc.sh
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=demo
export OS_TENANT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=demo
export OS_AUTH_URL=http://192.168.56.11:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
[root@hostnamelinux-node1 ~]# glance image-list
+----+------+
| ID | Name |
+----+------+
+----+------+
下載鏡像:[root@hostnamelinux-node1 ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
上傳鏡像:
[root@hostnamelinux-node1 ~]# 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 | 2018-10-07T09:56:40Z |
| disk_format | qcow2 |
| id | 0297b83c-f9d7-4c19-ab05-762fd4616c49 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | d7064a9e91934300b28cccc787161fdb |
| protected | False |
| size | 13287936 |
| status | active |
| tags | [] |
| updated_at | 2018-10-07T09:56:41Z |
| virtual_size | None |
| visibility | public |
+------------------+--------------------------------------+
[root@hostnamelinux-node1 ~]# glance image-list
+--------------------------------------+--------+
| ID | Name |
+--------------------------------------+--------+
| 0297b83c-f9d7-4c19-ab05-762fd4616c49 | cirros |
+--------------------------------------+--------+
[root@hostnamelinux-node1 ~]# cd /var/lib/glance/images/
[root@hostnamelinux-node1 images]# ll
總用量 12980
-rw-r-----. 1 glance glance 13287936 10月 7 17:56 0297b83c-f9d7-4c19-ab05-762fd4616c49
[root@hostnamelinux-node1 images]# file 0297b83c-f9d7-4c19-ab05-762fd4616c49
0297b83c-f9d7-4c19-ab05-762fd4616c49: QEMU QCOW Image (v2), 41126400 bytes
OpenStack-liberty版Glance服務部署(二)