排错:Glance服务安装后HTTP 500解决

排错:Glance服务安装后HTTP 500解决

嚯嚯嚯www 39 2022-08-26

排错:Glance服务安装后HTTP 500解决

环境:
CentOS 6.6
Openstack安装版本icehouse

安装正常启动openstack-glance-api和registry服务,执行任何glance命令都报错HTTP500

[root@controller glance]# glance image-list
Request returned failure status.
HTTPInternalServerError (HTTP 500)

43125-w4ezvynl39j.png

查看glance-api的日志(没卵用)

2020-04-23 03:40:04.516 9568 INFO glance.wsgi.server [8a02a388-296b-4fbc-99ac-f8ed66791241 d5ef6bc6ee97471b85c25ef503d3c54b bf2e7476e4cf46889a7a421e66190e92 - - -] 192.168.1.31 - - [23/Apr/2020 03:40:04] "GET /v1/images/detail?sort_key=name&sort_dir=asc&limit=20 HTTP/1.1" 500 139 0.253583
2020-04-23 03:52:17.022 9568 INFO urllib3.connectionpool [-] Starting new HTTP connection (1): controller
2020-04-23 03:52:17.278 9568 INFO glance.registry.client.v1.client [ef0286ca-72fb-4b4b-88fc-317f13abcd4f d5ef6bc6ee97471b85c25ef503d3c54b bf2e7476e4cf46889a7a421e66190e92 - - -] Registry client request GET /images/detail raised ServerError
。。。。。。。。。。。。。。
ServerError: The request returned 500 Internal Server Error.
2020-04-23 03:52:17.287 9568 INFO glance.wsgi.server [ef0286ca-72fb-4b4b-88fc-317f13abcd4f d5ef6bc6ee97471b85c25ef503d3c54b bf2e7476e4cf46889a7a421e66190e92 - - -] 192.168.1.31 - - [23/Apr/2020 03:52:17] "GET /v1/images/detail?limit=10 HTTP/1.1" 500 139 0.272151

查看glance-api的日志(有点东西)

2020-04-23 03:40:04.515 1685 INFO glance.wsgi.server [a38e3fed-87cd-4bcf-8ca2-eaae138737c9 d5ef6bc6ee97471b85c25ef503d3c54b bf2e7476e4cf46889a7a421e66190e92 - - -] 192.168.1.31 - - [23/Apr/2020 03:40:04] "GET /images/detail?sort_key=name&sort_dir=asc&limit=20 HTTP/1.1" 500 139 0.151550
2020-04-23 03:52:17.128 1685 INFO urllib3.connectionpool [-] Starting new HTTP connection (1): controller
2020-04-23 03:52:17.274 1685 ERROR glance.registry.api.v1.images [ae27f8a2-282c-435a-a15b-f44ec623b4d6 d5ef6bc6ee97471b85c25ef503d3c54b bf2e7476e4cf46889a7a421e66190e92 - - -] Unable to get images
//这里显示报错Table 'glance.images' doesn't exist,说明报错涉及到数据库,且连接库没问题但查询不到相关的表
ProgrammingError: (ProgrammingError) (1146, "Table 'glance.images' doesn't exist")。。。。
。。。。。。。

分析解决

在确保openstack-config配置glance-api.conf和glance-registry.conf没有问题后

配置初始化glance数据库表的时候,官方给出的教程里用的是以下这条命令

[root@controller glance]# su -s /bin/sh -c "glance-manage db_sync" glance

95884-hsg7uxrbxa.png

此时进入查看glance库中只有一张表,这是不正确的
12365-0j6k8xtax6c.png

如何解决:
先清除以建的库表

[root@controller glance]# /usr/bin/openstack-db --drop --service glance
Please enter the password for the 'root' MySQL user: //输入数据库root密码
Verified connectivity to MySQL.
Dropping 'glance' database.
Complete!

68862-r4uag8tt2ds.png

使用这条命令重新创建glance使用的库表

[root@controller glance]# openstack-db --init --service glance --password 000000 --rootpw 000000
Verified connectivity to MySQL.
Creating 'glance' database.
Updating 'glance' database password in /etc/glance/glance-registry.conf /etc/glance/glance-api.conf
Initializing the glance database, please wait...
Complete!

21824-dlz5g23zn2f.png

再次进入数据库查询时,glance的表已经正常
57057-q27wdtepo5.png

之后glance运行正常了
成功创建镜像
84061-netrl61g0db.png

列出镜像也是正常
74806-45o61axtvnb.png