天天看點

一次簡單的排錯過程

[root@controller scripts]# openstack p_w_picpath create "cirros"   --file cirros-0.3.4-x86_64-disk.img   --disk-format qcow2 --container-format bare   --public

出現錯誤如下"500 Internal Server Error: The server has either erred or is incapable of performing the requested operation. (HTTP 500)"

檢視/var/log/glance/api.log注意到如下錯誤

2016-08-21 09:30:18.343 13311 ERROR glance.common.wsgi [req-c7e5abcd-c6f8-462b-ab1b-4b5b76aad182 f7649ace8e334b18ab41bc469615040a eb048b599fc441b091d9cb

83b893351e - - -] Caught error: (_mysql_exceptions.OperationalError) (1045, "Access denied for user 'glance'@'localhost' (using password: YES)")

1檢查mysql

show grants for 'glance'@'localhost';  

GRANT USAGE ON *.* TO 'glance'@'localhost' IDENTIFIED BY PASSWORD '********************************'

确認資料庫使用者沒有問題

2檢查 /etc/glance/glance-api.conf

more /etc/glance/glance-api.conf|grep ^[^#]

發現忘記添加下面的資料庫連接配接串

[database]

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

3修改之後重新開機服務

systemctl restart openstack-glance-api.service openstack-glance-registry.service

4再次運作

依然報錯

5檢視/var/log/glance/api.log注意到如下錯誤

2016-08-21 09:51:58.360 2674 INFO eventlet.wsgi.server [req-679f0386-f300-4c7e-8792-462dde2e6189 f7649ace8e334b18ab41bc469615040a eb048b599fc441b091d9cb

83b893351e - - -] 10.0.0.11 - - [21/Aug/2016 09:51:58] "GET /v2/schemas/p_w_picpath HTTP/1.1" 200 4344 0.282085

2016-08-21 09:51:58.446 2674 ERROR glance.common.wsgi [req-cc9bc6ce-44f1-4df4-b18f-63aeadc8a50f f7649ace8e334b18ab41bc469615040a eb048b599fc441b091d9cb8

3b893351e - - -] Caught error: (pymysql.err.ProgrammingError) (1146, u"Table 'glance.p_w_picpaths' doesn't exist") [SQL: u'INSERT INTO p_w_picpaths (created_at, upd

ated_at, deleted_at, deleted, id, name, disk_format, container_format, size, virtual_size, status, is_public, checksum, min_disk, min_ram, owner, protec

ted) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'] [parameters: (datetime.datetime(2016, 8, 21, 13, 51, 58, 441792), dat

etime.datetime(2016, 8, 21, 13, 51, 58, 441792), None, 0, '22571831-2e2f-43a4-9941-5afcc1828fae', u'cirros', u'qcow2', u'bare', None, None, 'queued', 1,

 None, 0, 0, u'eb048b599fc441b091d9cb83b893351e', 0)]

6根據提示運作

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

Option "verbose" from group "DEFAULT" is deprecated for removal.  Its value may be silently ignored in the future.

/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py:1056: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo_db.sqlalchemy.enginefacade

  expire_on_commit=expire_on_commit, _conf=conf)

/usr/lib/python2.7/site-packages/pymysql/cursors.py:146: Warning: Duplicate index 'ix_p_w_picpath_properties_p_w_picpath_id_name' defined on the table 'glance.p_w_picpath_properties'. This is deprecated and will be disallowed in a future release.

  result = self._query(query)

7然後重新開機服務

8再然後運作

成功