OpenStack-liberty版Glance服务部署

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenStack-liberty版Glance服务部署相关的知识,希望对你有一定的参考价值。

Glance镜像服务:
技术分享图片
Glance主要由三部分构成:glance-api、glance-registry以及image store
Glance-api:接受系统镜像的创建、删除、读取请求。
Glance-Registry:云系统的镜像注册服务

Glance安装:

[[email protected] ~]# yum -y install openstack-glance python-glance python-glanceclient
[[email protected] ~]# vim /etc/glance/glance-api.conf 
[database]
connection=mysql://glance:[email protected]/glance
[[email protected] ~]# vim /etc/glance/glance-registry.conf 
[database]
connection=mysql://glance:[email protected]/glance

同步数据库:

[[email protected] ~]# su -s /bin/sh -c "glance-manage db_sync" glance
No handlers could be found for logger "oslo_config.cfg"(可以忽略)
[[email protected] ~]# 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用户:

[[email protected] ~]# openstack user create --domain default --password=glance glance
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | default                          |
| enabled   | True                             |
| id        | 85b0cebbbb9f4cc890cdeff577ee0989 |
| name      | glance                           |
+-----------+----------------------------------+

将glance用户加入到service项目并赋予admin权限;
[[email protected] ~]# openstack role add --project service --user glance admin

配置glance:

[[email protected] ~]# 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/
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# 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服务:

[[email protected] ~]# 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.
[[email protected] ~]# 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.
[[email protected] ~]# systemctl start openstack-glance-api
[[email protected] ~]# systemctl start openstack-glance-registry

openstack-glance-api监听端口9292,openstack-glance-registry监听端口9191;

[[email protected] ~]# 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服务:

[[email protected] ~]# openstack service create --name glance --description "OpenStack Image service" image 
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image service          |
| enabled     | True                             |
| id          | d7f04da42efc4c6c8b75c1848385598c |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

外网注册:

[[email protected] ~]# 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        |
+--------------+----------------------------------+

内网注册:

[[email protected] ~]# 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注册:

[[email protected] ~]# 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环境变量:

[[email protected] ~]# echo "export OS_IMAGE_API_VERSION=2" >  | tee -a admin-openrc.sh demo-openrc.sh
export OS_IMAGE_API_VERSION=2
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# glance image-list
+----+------+
| ID | Name |
+----+------+
+----+------+

下载镜像:
[[email protected] ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

上传镜像:

[[email protected] ~]# 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                               |
+------------------+--------------------------------------+
[[email protected] ~]# glance image-list
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| 0297b83c-f9d7-4c19-ab05-762fd4616c49 | cirros |
+--------------------------------------+--------+
[[email protected] ~]# cd /var/lib/glance/images/
[[email protected] images]# ll
总用量 12980
-rw-r-----. 1 glance glance 13287936 10月  7 17:56 0297b83c-f9d7-4c19-ab05-762fd4616c49
[[email protected] images]# file 0297b83c-f9d7-4c19-ab05-762fd4616c49 
0297b83c-f9d7-4c19-ab05-762fd4616c49: QEMU QCOW Image (v2), 41126400 bytes

以上是关于OpenStack-liberty版Glance服务部署的主要内容,如果未能解决你的问题,请参考以下文章

OpenStack-liberty版Neutron服务部署

OpenStack-liberty版创建第一台虚拟机

OpenStack-liberty版虚拟机创建流程

OpenStack-liberty版Nova服务部署

OpenStack-liberty版Nova计算节点部署服务部署

OpenStack-liberty版Ciner部署