[原][openstack-pike][controller node][issue-2][glance] Could not parse rfc1738 URL from string 'mysql+pymysql=http://glance:glance@controller/glance'

时间:2021-11-03 15:31:52

问题点

在手动上传镜像的时候:出现错误

Could not parse rfc1738 URL from string 'mysql+pymysql=http://glance:glance@controller/glance'

查看错误应该是配置文件配错了

查看/etc/glance/glance-api.conf (红色标记的地方为错误点)

connection = mysql+pymysql=http://glance:glance@controller/glance

改为:

connection = mysql+pymysql://glance:glance@controller/glance

期间还遇到一个问题(查看glance 的api.log):

 u"Table 'glance.images' doesn't exist"
 ProgrammingError: (pymysql.err.ProgrammingError) (, u"Table 'glance.images' doesn't exist") 
[SQL: u'INSERT INTO images (created_at, updated_at, deleted_at, deleted, id, name, disk_format,
container_format, size, virtual_size, status, visibility, checksum, min_disk, min_ram, owner, protected)
VALUES (%(created_at)s, %(updated_at)s, %(deleted_at)s, %(deleted)s, %(id)s, %(name)s, %(disk_format)s,
%(container_format)s, %(size)s, %(virtual_size)s, %(status)s, %(visibility)s, %(checksum)s, %(min_disk)s,
%(min_ram)s, %(owner)s, %(protected)s)'] [parameters: {'status': 'queued', 'deleted_at': None, 'name': u'cirros', 'deleted': , 'container_format': u'bare', 'created_at': datetime.datetime(, , , , , , ), 'disk_format': u'qcow2', 'updated_at': datetime.datetime(, , , , , , ), 'visibility': 'shared', 'min_disk': , 'protected': , 'min_ram': , 'checksum': None, 'owner': u'620c7268112f447c87829781b5e96c7f', 'virtual_size': None, 'id': '7de71ffa-d84c-4874-b762-9118cc910258',
'size': None}]

上面的错误一看就可以推断是数据库里没有创建相应的表,所以只需要执行同步数据库的操作就可以了。

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

查看相应的表:

MariaDB [glance]> show tables;
+----------------------------------+
| Tables_in_glance |
+----------------------------------+
| alembic_version |
| 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 |
+----------------------------------+
rows in set (0.00 sec)

再次测试上传,问题解决

[root@controller glance]# glance image-create --name cirros --disk-format=qcow2 --container-format=bare --file=/root/cirros-0.4.-x86_64-disk.img --progress
[=============================>] %
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | 443b7623e27ecf03dc9e01ee93f67afe |
| container_format | bare |
| created_at | --04T07::33Z |
| disk_format | qcow2 |
| id | 824cb9aa-710d-4e76-afcf-6062b7e899cc |
| min_disk | |
| min_ram | |
| name | cirros |
| owner | 620c7268112f447c87829781b5e96c7f |
| protected | False |
| size | |
| status | active |
| tags | [] |
| updated_at | --04T07::33Z |
| virtual_size | None |
| visibility | shared |
+------------------+--------------------------------------+