关于keystone,错误
前言
这几天open stack实训,用的M版,可能是自己倒霉把,六天实训,光keystone就弄了4天,开头就卡住了一两天,害
前面或多或少都遇到了问题,主要遇到的是:密钥,身份认证和数据库连接这些问题,但都弄完了
什么
401基本就是身份认证有问题,
404是找不到资源 那就是要看下api网址,也就是路径这方面的问题
500是说一个意外操作,导致出错,我的触发是删除数据库,看日志说是找不到keystone数据库,重新同步数据库的时候出来的。解决办法是,重新初始化fernet keys,
-
前面问题解决忘记记录了,思路是:
- 环境变量配置问题,一般报错会模糊指向这一块,多注意下
- 配置文件问题,环境变量里的token,就是keystone.conf里的token,两者相等的
- 数据库同步问题:创建数据库后,给数据库授权的时候,最后写的就是连接数据库密码
open grant all privileges on keystone.* to 'keystone'@'localhost' identified by '000000';
#例如,后面的000000就是连接数据的密码
#配置文件里的[database]选项,就应该写
[database]
connection = mysql+pymysql://keystone:000000@controopenller/keystone
- 报找不到资源,URL啥的:检查endpoint创建的服务API(url)、还有相关命令检查,日志,用浏览器访问url看看是否会返回报错。避免url拼写错误
干货开始:
这是我实训结束倒数第二天遇到的问题,也就是这时想起来记录方便查看
Failed to contact the endpoint at http://controller:35357/3 for discovery. Fallback to using that endpoint as the base url. The resource could not be found. (HTTP 404)·
翻译以下就知道了,大致说的是,未能发现这个url,基于这个URL,找不到资源
这段报错说的是,找不到这个资源,刚开始没有任何头绪,后面尝试用浏览器放这个url(controller记得换回IP地址才能访问到
),发现返回的是报错
{"error": {"message": "The resource could not be found.", "code": 404, "title": "Not Found"}}
再看一遍url:http://controller:35357/3
;发现少个v,加上这个v就能正常访问了http://controller:35357/v3
{"version": {"status": "stable", "updated": "2016-04-04T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v3+json"}], "id": "v3.6", "links": [{"href": "http://192.168.200.21:35357/v3/", "rel": "self"}]}}
后面删除这个endpoint的时候又遇到问题了,删不了,报错显示基于这个url找不到资源,没错,找不到资源,何谈删除;到这的时候就卡住了,后面就是一通百度冲浪。看到一篇文章说,显示的这些url是存在数据库里的;那改数据库不就行了
MariaDB [keystone]> select * from endpoint;
+----------------------------------+--------------------+-----------+----------------------------------+-------- -------------------+-------+---------+-----------+
| id | legacy_endpoint_id | interface | service_id | url | extra | enabled | region_id |
+----------------------------------+--------------------+-----------+----------------------------------+-------- -------------------+-------+---------+-----------+
| 2c57b1d4698845a383bc0ce112dfe278 | NULL | public | c5fd90467eec4bce9a50f9685c80cd27 | http:// controller:5000/3 | {} | 1 | RegionOne |
| 9183c8c90f0148eb9e246a6d0aebd08c | NULL | admin | c5fd90467eec4bce9a50f9685c80cd27 | http:// controller:35357/3 | {} | 1 | RegionOne |
| 93a6c0607a5646aeb336277d14ce8dd8 | NULL | internal | c5fd90467eec4bce9a50f9685c80cd27 | http:// controller:5000/3 | {} | 1 | RegionOne |
+----------------------------------+--------------------+-----------+----------------------------------+-------- -------------------+-------+---------+-----------+
3 rows in set (0.01 sec)
终于看到实体的数据了,这些错误的url,开改
MariaDB [keystone]> update endpoint set url='http://controller:5000/v3'
-> ;
Query OK, 3 rows affected (0.01 sec)
完美解决,收工!keystone恢复正常运营!!!
[root@controller ~]# openstack catalog list
+----------+----------+---------------------------------------+
| Name | Type | Endpoints |
+----------+----------+---------------------------------------+
| keystone | identity | RegionOne |
| | | public: http://controller:5000/v3 |
| | | RegionOne |
| | | admin: http://controller:35357/v3 |
| | | RegionOne |
| | | internal: http://controller:5000/v3 |
| | | |
+----------+----------+---------------------------------------+
[root@controller ~]# openstack endpoint list
+----------------------+-----------+--------------+--------------+---------+-----------+-----------------------+
| ID | Region | Service Name | Service Type | Enabled | Interface | URL |
+----------------------+-----------+--------------+--------------+---------+-----------+-----------------------+
| 2c57b1d4698845a383bc | RegionOne | keystone | identity | True | public | http://controller:500 |
| 0ce112dfe278 | | | | | | 0/v3 |
| 9183c8c90f0148eb9e24 | RegionOne | keystone | identity | True | admin | http://controller:353 |
| 6a6d0aebd08c | | | | | | 57/v3 |
| 93a6c0607a5646aeb336 | RegionOne | keystone | identity | True | internal | http://controller:500 |
| 277d14ce8dd8 | | | | | | 0/v3 |
+----------------------+-----------+--------------+--------------+---------+-----------+-----------------------+