openstack:安装 glance,执行glance index,Failed to show index. Got error

Posted 走自己的路-让别人也有路走

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openstack:安装 glance,执行glance index,Failed to show index. Got error相关的知识,希望对你有一定的参考价值。

今天在安装openstack glance 的时候,遇到了下面两个问题,定位了半天,回头再看一下,都是自己不注意埋下的坑。

1、Failed to show index. Got error:
The request returned 500 Internal Server Error

The response body:
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/eventlet/wsgi.py”, line 336, in handle_one_response
result = self.application(self.environ, start_response)
File “/usr/lib/python2.7/dist-packages/webob/dec.py”, line 147, in call
resp = self.call_func(req, *args, **self.kwargs)
File “/usr/lib/python2.7/dist-packages/webob/dec.py”, line 210, in call_func
return self.func(req, *args, **kwargs)
File “/usr/lib/python2.7/dist-packages/glance/common/wsgi.py”, line 284, in call
response = req.get_response(self.application)
File “/usr/lib/python2.7/dist-packages/webob/request.py”, line 1086, in get_response
application, catch_exc_info=False)
File “/usr/lib/python2.7/dist-packages/webob/request.py”, line 1055, in call_application
app_iter = application(self.environ, start_response)
File “/usr/lib/python2.7/dist-packages/webob/dec.py”, line 147, in call
resp = self.call_func(req, *args, **self.kwargs)
File “/usr/lib/python2.7/dist-packages/webob/dec.py”, line 210, in call_func
return self.func(req, *args, **kwargs)
File “/usr/lib/python2.7/dist-packages/glance/common/wsgi.py”, line 281, in call
response = self.process_request(req)
File “/usr/lib/python2.7/dist-packages/glance/common/context.py”, line 112, in process_request
raise exception.NotAuthenticated()
NotAuthenticated: You are not authenticated.

这个问题其实从错误信息上也能看到,是没有认证通过导致的,一开始总以为是认证用户名、密码没有设置对,经过再三确认的确是没问题,查了下安装手册,发现自己没有指定认证策略。
在/etc/glance/glance-registry.conf和/etc/glance/glance-api.conf配置文件末尾加入下面两行就行。
[paste_deploy]
flavor = keystone

2、Failed to show index. Got error:
Connect error/bad request to Auth service at URL http://localhost:5000/v2.0/tokens.

解决完第一个问题后,又出现第二个问题,在网上找了下资料都说没有export OS_AUTH_URL,但是查看环境变量自己都配置了。找了半天后,突然发现自己环境变量中的OS_AUTH_URL=” http://localhost:5000/v2.0/” ” http:/”多了个空格,删掉试一下,glance index执行成功了,果真是这个引起的问题,好大一个坑。

export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_AUTH_URL="http://localhost:5000/v2.0/"

以上是关于openstack:安装 glance,执行glance index,Failed to show index. Got error的主要内容,如果未能解决你的问题,请参考以下文章

OpenStack---M版---双节点搭建---Glance安装和配置

OpenStack Train:业务组件装 glances安装

OpenStack教程-04.在CentOS7.5上安装OpenStack-Rocky-安装Glance镜像服务组件

安装OpenStack QUEENS版本三:Glance

openstack -- glance

6.安装和配置OpenStack图片服务组件