问题重现:
在部署完OpenStack平台后,运行命令 nova-status upgrade check进行Nova服务检查,却报错了,报错详细信息如下:
[root@controller neutron]# nova-status upgrade check
Option "os_region_name" from group "placement" is deprecated. Use option "region-name" from
group "placement".
Error:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nova/cmd/status.py", line 624, in main
ret = fn(*fn_args, **fn_kwargs)
File "/usr/lib/python2.7/site-packages/nova/cmd/status.py", line 554, in check
result = func(self)
File "/usr/lib/python2.7/site-packages/nova/cmd/status.py", line 494, in
_check_api_service_version
cctxt, 'nova-osapi_compute')
File "/usr/lib/python2.7/site-packages/nova/cmd/status.py", line 448, in
_get_min_service_version
services = Table('services', meta, autoload=True)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/schema.py", line 456, in __new__
metadata._remove_table(name, schema)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 66, in
__exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/schema.py", line 451, in __new__
table._init(name, metadata, *args, **kw)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/schema.py", line 533, in _init
include_columns, _extend_on=_extend_on)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/schema.py", line 559, in _autoload
_extend_on=_extend_on
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 2056, in
run_callable
return conn.run_callable(callable_, *args, **kwargs)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1545, in
run_callable
return callable_(self, *args, **kwargs)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 389, in
reflecttable
table, include_columns, exclude_columns, **opts)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.py", line 602, in
reflecttable
table_name, schema, **table.dialect_kwargs)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.py", line 312, in
get_table_options
info_cache=self.info_cache, **kw)
File "<string>", line 2, in get_table_options
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.py", line 54, in
cache
ret = fn(self, con, *args, **kw)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py", line 1984, in
get_table_options
connection, table_name, schema, **kw)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py", line 2123, in
_parsed_state_or_create
info_cache=kw.get('info_cache', None)
File "<string>", line 2, in _setup_parser
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.py", line 54, in
cache
ret = fn(self, con, *args, **kw)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py", line 2148, in
_setup_parser
full_name=full_name)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py", line 2243, in
_show_create_table
raise exc.NoSuchTableError(full_name)
NoSuchTableError: `services`
ERROR nova.context ProgrammingError: (pymysql.err.ProgrammingError) (1146, u"Table
'nova_cell0.services' doesn't exist")
从错误的内容来分析,Option "os_region_name" from group "placement" is deprecated. Use option "region-name" from
group "placement". 这一段是白给的,只是提示某个配置将在下一个版本过期,以后用region-name 这个键,不用os_region_name这个键而已,可以忽略。
中间的内容也是白给的,只是能够看到错误原因是和数据库有关的。那么,关键的就是最后两句话了:
raise exc.NoSuchTableError(full_name)
NoSuchTableError: `services`
这里,我就给大家翻译翻译,这里的意思是数据库里找不到一个表了,这个表的名字是services。根据报错的第一个错误:
File "/usr/lib/python2.7/site-packages/nova/cmd/status.py", line 624, in main
ret = fn(*fn_args, **fn_kwargs)
vim +624 /usr/lib/python2.7/site-packages/nova/cmd/status.py 看到如下内容:
def check(self):
"""Performs checks to see if the deployment is ready for upgrade.
These checks are expected to be run BEFORE services are restarted with
new code. These checks also require access to potentially all of the
Nova databases (nova, nova_api, nova_api_cell0) and external services
such as the placement API service.
:returns: UpgradeCheckCode
这里说的是要检查的库是 nova, nova_api, nova_api_cell0,查看数据库后,发现是cell0数据库没有这个表,那么,如何建立这个表呢?
再次执行同步nova数据库的命令就可以啦,这个命令是:
su -s /bin/sh -c "nova-manage db sync" nova
输出是:
/usr/lib/python2.7/site-packages/pymysql/cursors.py:166: Warning: (1831, u'Duplicate index
`block_device_mapping_instance_uuid_virtual_name_device_name_idx`. This is deprecated and
will be disallowed in a future release.')
result = self._query(query)
/usr/lib/python2.7/site-packages/pymysql/cursors.py:166: Warning: (1831, u'Duplicate index
`uniq_instances0uuid`. This is deprecated and will be disallowed in a future release.')
result = self._query(query)
[root@controller nova]# echo $?
0
那么,这里的输出是警告,可以忽略,因为 echo $? 是0嘛。警告内容翻译一下就是 预告了一下Python的某些方法要在未来版本废弃。
至此,错误排除了,可以愉快的执行命令nova-status upgrade check 检查了。
总结:
错误的根本原因是由于我使用的是脚本部署安装的,由于前期的某个错误,导致placement有错误,因此,su -s /bin/sh -c "nova-manage db sync" nova这个命令同步数据库是失败的,而脚本并没有生产日志,因此,忽略了这一个隐藏的错误。