官方部署文档:https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/glance.html
1、控制端安装 glance:
[root@linux-host1 ~]# yum install -y openstack-glance
2、创建并初始化数据库:
#1:在 mysql 服务器创建 glance 数据库并授权:
[root@linux-host4 ~]# mysql -uroot -p123456
MariaDB [(none)]> create database glance;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on glance.* to 'glance'@'%' identified by 'glance';
Query OK, 0 rows affected (0.00 sec)
#2:在控制端验证 glance 用户远程连接 VIP:
3、编辑配置文件并同步数据库:
#1:编辑配置文件 glance-api.conf:
[root@linux-host1 ~]# vim /etc/glance/glance-api.conf
1826 connection = mysql+pymysql://glance:glance@192.168.10.100/glance
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
4268 flavor = keystone
1974 default_store = file
2293 filesystem_store_datadir = /var/lib/glance/images
#当前配置:
[root@linux-host1 ~]# grep -n "^[a-Z\[]" /etc/glance/glance-api.conf
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
#2:编辑配置文件 glance-registry.conf:
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
2162 flavor = keystone
#当前配置:
[root@linux-host1 ~]# grep -n "^[a-Z\[]" /etc/glance/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
#3:配置 haproxy 代理 glance:
[root@linux-host4 ~]# 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
#4:重启 haproxy 并验证端口:
[root@linux-host4 ~]# systemctl restart haproxy
#5:初始化 glance 数据库:
[root@linux-host1 ~]# 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
#6:验证数据库:
#7:启动 glance 并设置为开机启动:
[root@linux-host1 ~]# systemctl enable openstack-glance-api.service openstack-glance-registry.service
[root@linux-host1 ~]# systemctl start openstack-glance-api.service openstack-glance-registry.service
#8:验证 glance 端口:
#9:glance 服务日志:
#10:glance 服务注册:
[root@linux-host1 ~]# source admin-ocata.sh
#10.1:创建 glance 服务:
[root@linux-host1 ~]# openstack service create --name glance --description "OpenStack Image"
image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | d032525e64644c55a9e89a2fe4dfc950 |
| name | glance |
| type | image |
+-------------+----------------------------------+
#10.2:创建公有 endpoint:
[root@linux-host1 ~]# 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 |
+--------------+----------------------------------+
#10.3:创建私有 endpoint:
[root@linux-host1 ~]# 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 |
+--------------+----------------------------------+
#10.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 |
+--------------+----------------------------------+
#10.5:验证以上步骤:
#11:验证 glance 服务:
#12:测试 glance 上传镜像:
#在 glance 下载一个 0.3.4 版本的测试镜像
[root@linux-host1 ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-
disk.img
[root@linux-host1 ~]# source admin-ocata.sh
[root@linux-host1 ~]# 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 |
+------------------+------------------------------------------------------+
#13:验证 glance 镜像:
[root@linux-host1 ~]# glance image-list
[root@linux-host1 ~]# openstack image list
#14:查看指定镜像信息:
[root@linux-host1 ~]# openstack image show cirros
+------------------+------------------------------------------------------+
| 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 |
+------------------+------------------------------------------------------+