操作系统使用centos7.5 1804
openstack 版本queens
修改/etc/glance/glance-api.conf
[glance_store]
#stores = file,http,swift
#default_store = file
#filesystem_store_datadir = /var/lib/glance/images/
stores = glance.store.swift.Store
default_store=swift
#修改后端存储使用swift
#swift_store_auth_version = 3
#swift_store_auth_address=http://controller:5000/v3.0/
swift_store_auth_address=http://controller:5000/v3.0
swift_store_endpoint_tyep=internalURL
swift_store_multi_tenant=True
swift_store_admin_tenants=service
#重点是这两条配置,Q版本试过很多配置这两条还是要配置的,不然会提示500错误,日志中提示认证问题
swift_store_user=glance
#不能写成<object:user>这样的配置
swift_store_key=000000
swift_store_container=glance
#后端存储容器,本来以为所有镜像都存储在这一个swift容器中,但是发现存储格式一个镜像一个容器,命令规则是glance_<imageID>
swift_store_create_container_on_put=True
swift_store_large_object_size=5120
swift_store_large_object_chunk_size=200
swift_store_region=RegionOne
重启glance服务
[root@controller ~]# systemctl restart openstack-glance-*
如果没有配置以下两条配置,日志中会提示认证错误,添加后重启服务即可
swift_store_multi_tenant=True
swift_store_admin_tenants=service
2020-10-27 15:29:42.941 404393 ERROR glance.api.v2.image_data [req-049c3d5b-eba7-4989-8a40-c01365fa0a40 c94599dccd76435aa28293a6f14a020c 48243b8e2b9d4ab2a37fcd4928bf8bce - 362fafdb6a4046f1874757d26e183b80 362fafdb6a4046f1874757d26e183b80] Failed to upload image data due to internal error: ClientException: Authorization Failure. Authorization Failed: (http://controller:5000/v3.0/tokens): The resource could not be found. (HTTP 404) (HTTP 404)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi [req-049c3d5b-eba7-4989-8a40-c01365fa0a40 c94599dccd76435aa28293a6f14a020c 48243b8e2b9d4ab2a37fcd4928bf8bce - 362fafdb6a4046f1874757d26e183b80 362fafdb6a4046f1874757d26e183b80] Caught error: Authorization Failure. Authorization Failed: (http://controller:5000/v3.0/tokens): The resource could not be found. (HTTP 404) (HTTP 404): ClientException: Authorization Failure. Authorization Failed: (http://controller:5000/v3.0/tokens): The resource could not be found. (HTTP 404) (HTTP 404)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi Traceback (most recent call last):
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance/common/wsgi.py", line 1227, in __call__
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi request, **action_args)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance/common/wsgi.py", line 1270, in dispatch
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi return method(*args, **kwargs)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance/common/utils.py", line 414, in wrapped
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi return func(self, req, *args, **kwargs)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance/api/v2/image_data.py", line 267, in upload
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi self._restore(image_repo, image)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi self.force_reraise()
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi six.reraise(self.type_, self.value, self.tb)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance/api/v2/image_data.py", line 132, in upload
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi image.set_data(data, size)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance/domain/proxy.py", line 195, in set_data
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi self.base.set_data(data, size)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance/notifier.py", line 480, in set_data
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi _send_notification(notify_error, 'image.upload', msg)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi self.force_reraise()
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi six.reraise(self.type_, self.value, self.tb)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance/notifier.py", line 427, in set_data
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi self.repo.set_data(data, size)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance/api/policy.py", line 193, in set_data
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi return self.image.set_data(*args, **kwargs)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance/quota/__init__.py", line 304, in set_data
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi self.image.set_data(data, size=size)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance/location.py", line 439, in set_data
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi verifier=verifier)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance_store/backend.py", line 453, in add_to_backend
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi verifier)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance_store/backend.py", line 426, in store_add_to_backend
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi verifier=verifier)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance_store/capabilities.py", line 225, in op_checker
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi return store_op_fun(store, *args, **kwargs)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance_store/_drivers/swift/store.py", line 889, in add
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi manager.get_connection())
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/glance_store/_drivers/swift/store.py", line 1090, in _create_container_if_missing
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi connection.head_container(container)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/swiftclient/client.py", line 1753, in head_container
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi return self._retry(None, head_container, container, headers=headers)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/swiftclient/client.py", line 1679, in _retry
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi self.url, self.token = self.get_auth()
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/swiftclient/client.py", line 1631, in get_auth
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi timeout=self.timeout)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/swiftclient/client.py", line 685, in get_auth
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi auth_version=auth_version)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi File "/usr/lib/python2.7/site-packages/swiftclient/client.py", line 597, in get_auth_keystone
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi raise ClientException('Authorization Failure. %s' % err)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi ClientException: Authorization Failure. Authorization Failed: (http://controller:5000/v3.0/tokens): The resource could not be found. (HTTP 404) (HTTP 404)
2020-10-27 15:29:42.969 404393 ERROR glance.common.wsgi
2020-10-27 15:29:43.001 404393 INFO eventlet.wsgi.server [req-049c3d5b-eba7-4989-8a40-c01365fa0a40 c94599dccd76435aa28293a6f14a020c 48243b8e2b9d4ab2a37fcd4928bf8bce - 362fafdb6a4046f1874757d26e183b80 362fafdb6a4046f1874757d26e183b80] 172.33.16.10 - - [27/Oct/2020 15:29:43] "PUT /v2/images/7680460e-10d7-4797-90a2-b2f5cfc8d758/file HTTP/1.1" 500 454 0.118801
上传image镜像
[root@controller ~]# source /etc/keystone/admin-openrc.sh
[root@controller ~]# glance image-create --name "test2" --disk-format qcow2 --container-format bare --progress < cirros-0.3.4-x86_64-disk.img
[=============================>] 100%
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2020-10-29T14:24:09Z |
| disk_format | qcow2 |
| id | 5f0dab8d-6d06-4b74-805e-aa97da6e5365 |
| min_disk | 0 |
| min_ram | 0 |
| name | test2 |
| owner | f3a4fbd6a85848be8aab2773fdbcaf2f |
| protected | False |
| size | 13287936 |
| status | active |
| tags | [] |
| updated_at | 2020-10-29T14:24:09Z |
| virtual_size | None |
| visibility | shared |
+------------------+--------------------------------------+
查看glance镜像列表
[root@controller ~]# openstack container list
+---------------------------------------------+
| Name |
+---------------------------------------------+
| glance |
| glance_24604bc2-90be-4fc1-84d3-1a6024668340 |
| glance_5f0dab8d-6d06-4b74-805e-aa97da6e5365 |
| glance_ac7386cf-a211-4be2-b0eb-8f937556df71 |
| glance_fa87370b-152e-4e8d-a703-8b857f9dd059 |
| test_segments |
+---------------------------------------------+
[root@controller ~]# openstack object list glance_5f0dab8d-6d06-4b74-805e-aa97da6e5365
+--------------------------------------------+
| Name |
+--------------------------------------------+
| 5f0dab8d-6d06-4b74-805e-aa97da6e5365 |
| 5f0dab8d-6d06-4b74-805e-aa97da6e5365-00001 |
+--------------------------------------------+
查看swift容器中glance镜像
使用swift存储中的image镜像创建云主机
做网络连通测试
λ ping 172.33.17.14
正在 Ping 172.33.17.14 具有 32 字节的数据:
来自 172.33.17.14 的回复: 字节=32 时间=1ms TTL=63
来自 172.33.17.14 的回复: 字节=32 时间<1ms TTL=63
来自 172.33.17.14 的回复: 字节=32 时间<1ms TTL=63
来自 172.33.17.14 的回复: 字节=32 时间<1ms TTL=63
172.33.17.14 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 1ms,平均 = 0ms