openstack给keystone同步数据库出错WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 8 attempts le

执行su -s /bin/sh -c “keystone-manage db_sync” keystone 报错

解决方法:

· 在controller节点上,修改 /etc/hosts
添加:
192.168.221.101 controller

注意,192.168.221.101是controller节点的ip,请根据自己的更改 ·

报错如下

Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
     * Setting up iSCSI targets
   ...done.
2013-12-02 11:56:28  WARNING [cinder.db.sqlalchemy.session] SQL connection failed. 10 attempts left.
2013-12-02 11:56:41  WARNING [cinder.db.sqlalchemy.session] SQL connection failed. 9 attempts left.
2013-12-02 11:56:54  WARNING [cinder.db.sqlalchemy.session] SQL connection failed. 8 attempts left.
2013-12-02 11:57:07  WARNING [cinder.db.sqlalchemy.session] SQL connection failed. 7 attempts left.
2013-12-02 11:57:20  WARNING [cinder.db.sqlalchemy.session] SQL connection failed. 6 attempts left.
2013-12-02 11:57:33  WARNING [cinder.db.sqlalchemy.session] SQL connection failed. 5 attempts left.
2013-12-02 11:57:46  WARNING [cinder.db.sqlalchemy.session] SQL connection failed. 4 attempts left.
2013-12-02 11:57:59  WARNING [cinder.db.sqlalchemy.session] SQL connection failed. 3 attempts left.
2013-12-02 11:58:12  WARNING [cinder.db.sqlalchemy.session] SQL connection failed. 2 attempts left.
2013-12-02 11:58:25  WARNING [cinder.db.sqlalchemy.session] SQL connection failed. 1 attempts left.
2013-12-02 11:58:38 CRITICAL [cinder] (OperationalError) (2003, "Can't connect to MySQL server on '172.30.0.200' (113)") None None
Traceback (most recent call last):
  File "/usr/bin/cinder-manage", line 794, in 
    main()
  File "/usr/bin/cinder-manage", line 791, in main
    fn(*fn_args)
  File "/usr/bin/cinder-manage", line 219, in sync
    return migration.db_sync(version)
  File "/usr/lib/python2.7/dist-packages/cinder/db/migration.py", line 33, in db_sync
    return IMPL.db_sync(version=version)
  File "/usr/lib/python2.7/dist-packages/cinder/db/sqlalchemy/migration.py", line 76, in db_sync
    current_version = db_version()
  File "/usr/lib/python2.7/dist-packages/cinder/db/sqlalchemy/migration.py", line 88, in db_version
    return versioning_api.db_version(get_engine(), repository)
  File "/usr/lib/python2.7/dist-packages/cinder/db/sqlalchemy/session.py", line 138, in get_engine
    _ENGINE.connect()
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2471, in connect
    return self._connection_cls(self, **kwargs)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 878, in __init__
    self.__connection = connection or engine.raw_connection()
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2557, in raw_connection
    return self.pool.unique_connection()
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 184, in unique_connection
    return _ConnectionFairy(self).checkout()
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 401, in __init__
    rec = self._connection_record = pool._do_get()
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 746, in _do_get
    con = self._create_connection()
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 189, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 282, in __init__
    self.connection = self.__connect()
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 344, in __connect
    connection = self.__pool._creator()
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 80, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 281, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (OperationalError) (2003, "Can't connect to MySQL server on '172.30.0.200' (113)") None None
0+0 records in
0+0 records out
0 bytes (0 B) copied, 1.2862e-05 s, 0.0 kB/s
  Physical volume "/dev/loop2" successfully created
  Volume group "cinder-volumes" successfully created
cinder-api stop/waiting
cinder-api start/running, process 18907
cinder-scheduler stop/waiting
cinder-scheduler start/running, process 18918
stop: Unknown instance: 
cinder-volume start/running, process 18929

或者是这样报错

fatal: [controller]: FAILED! => {"changed": true, "cmd": "su -s /bin/sh -c \"keystone-manage db_sync\" keystone", "delta": "0:01:44.650785", "end": "2017-12-07 12:09:09.043452", "msg": "non-zero return code", "rc": 1, "start": "2017-12-07 12:07:24.392667", "stderr": "2017-12-07 12:07:28.645 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 10 attempts left.\n2017-12-07 12:07:38.658 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 9 attempts left.\n2017-12-07 12:07:48.669 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 8 attempts left.\n2017-12-07 12:07:58.683 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 7 attempts left.\n2017-12-07 12:08:08.689 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 6 attempts left.\n2017-12-07 12:08:18.702 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 5 attempts left.\n2017-12-07 12:08:28.714 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 4 attempts left.\n2017-12-07 12:08:38.726 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 3 attempts left.\n2017-12-07 12:08:48.738 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 2 attempts left.\n2017-12-07 12:08:58.758 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 1 attempts left.\n2017-12-07 12:09:08.771 11174 CRITICAL keystone [-] DBConnectionError: (pymysql.err.OperationalError) (2003, \"Can't connect to MySQL server on 'controller' ([Errno 111] Connection refused)\")\n2017-12-07 12:09:08.771 11174 ERROR keystone Traceback (most recent call last):\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/bin/keystone-manage\", line 10, in \n2017-12-07 12:09:08.771 11174 ERROR keystone     sys.exit(main())\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/cmd/manage.py\", line 44, in main\n2017-12-07 12:09:08.771 11174 ERROR keystone     cli.main(argv=sys.argv, config_files=config_files)\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/cmd/cli.py\", line 1294, in main\n2017-12-07 12:09:08.771 11174 ERROR keystone     CONF.command.cmd_class.main()\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/cmd/cli.py\", line 461, in main\n2017-12-07 12:09:08.771 11174 ERROR keystone     CONF.command.version)\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/common/sql/migration_helpers.py\", line 207, in offline_sync_database_to_version\n2017-12-07 12:09:08.771 11174 ERROR keystone     expand_schema()\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/common/sql/migration_helpers.py\", line 232, in expand_schema\n2017-12-07 12:09:08.771 11174 ERROR keystone     _sync_common_repo(version=None)\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/common/sql/migration_helpers.py\", line 123, in _sync_common_repo\n2017-12-07 12:09:08.771 11174 ERROR keystone     with sql.session_for_write() as session:\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/contextlib.py\", line 17, in __enter__\n2017-12-07 12:09:08.771 11174 ERROR keystone     return self.gen.next()\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py\", line 874, in _transaction_scope\n2017-12-07 12:09:08.771 11174 ERROR keystone     allow_async=self._allow_async) as resource:\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/contextlib.py\", line 17, in __enter__\n2017-12-07 12:09:08.771 11174 ERROR keystone     return self.gen.next()\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py\", line 518, in _session\n2017-12-07 12:09:08.771 11174 ERROR keystone     bind=self.connection, mode=self.mode)\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py\", line 277, in _create_session\n2017-12-07 12:09:08.771 11174 ERROR keystone     self._start()\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py\", line 363, in _start\n2017-12-07 12:09:08.771 11174 ERROR keystone     engine_args, maker_args)\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py\", line 387, in _setup_for_connection\n2017-12-07 12:09:08.771 11174 ERROR keystone     sql_connection=sql_connection, **engine_kwargs)\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/engines.py\", line 155, in create_engine\n2017-12-07 12:09:08.771 11174 ERROR keystone     test_conn = _test_connection(engine, max_retries, retry_interval)\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/engines.py\", line 339, in _test_connection\n2017-12-07 12:09:08.771 11174 ERROR keystone     six.reraise(type(de_ref), de_ref)\n2017-12-07 12:09:08.771 11174 ERROR keystone   File \"\", line 2, in reraise\n2017-12-07 12:09:08.771 11174 ERROR keystone DBConnectionError: (pymysql.err.OperationalError) (2003, \"Can't connect to MySQL server on 'controller' ([Errno 111] Connection refused)\")\n2017-12-07 12:09:08.771 11174 ERROR keystone ", "stderr_lines": ["2017-12-07 12:07:28.645 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 10 attempts left.", "2017-12-07 12:07:38.658 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 9 attempts left.", "2017-12-07 12:07:48.669 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 8 attempts left.", "2017-12-07 12:07:58.683 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 7 attempts left.", "2017-12-07 12:08:08.689 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 6 attempts left.", "2017-12-07 12:08:18.702 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 5 attempts left.", "2017-12-07 12:08:28.714 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 4 attempts left.", "2017-12-07 12:08:38.726 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 3 attempts left.", "2017-12-07 12:08:48.738 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 2 attempts left.", "2017-12-07 12:08:58.758 11174 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 1 attempts left.", "2017-12-07 12:09:08.771 11174 CRITICAL keystone [-] DBConnectionError: (pymysql.err.OperationalError) (2003, \"Can't connect to MySQL server on 'controller' ([Errno 111] Connection refused)\")", "2017-12-07 12:09:08.771 11174 ERROR keystone Traceback (most recent call last):", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/bin/keystone-manage\", line 10, in ", "2017-12-07 12:09:08.771 11174 ERROR keystone     sys.exit(main())", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/cmd/manage.py\", line 44, in main", "2017-12-07 12:09:08.771 11174 ERROR keystone     cli.main(argv=sys.argv, config_files=config_files)", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/cmd/cli.py\", line 1294, in main", "2017-12-07 12:09:08.771 11174 ERROR keystone     CONF.command.cmd_class.main()", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/cmd/cli.py\", line 461, in main", "2017-12-07 12:09:08.771 11174 ERROR keystone     CONF.command.version)", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/common/sql/migration_helpers.py\", line 207, in offline_sync_database_to_version", "2017-12-07 12:09:08.771 11174 ERROR keystone     expand_schema()", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/common/sql/migration_helpers.py\", line 232, in expand_schema", "2017-12-07 12:09:08.771 11174 ERROR keystone     _sync_common_repo(version=None)", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/keystone/common/sql/migration_helpers.py\", line 123, in _sync_common_repo", "2017-12-07 12:09:08.771 11174 ERROR keystone     with sql.session_for_write() as session:", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/contextlib.py\", line 17, in __enter__", "2017-12-07 12:09:08.771 11174 ERROR keystone     return self.gen.next()", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py\", line 874, in _transaction_scope", "2017-12-07 12:09:08.771 11174 ERROR keystone     allow_async=self._allow_async) as resource:", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/contextlib.py\", line 17, in __enter__", "2017-12-07 12:09:08.771 11174 ERROR keystone     return self.gen.next()", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py\", line 518, in _session", "2017-12-07 12:09:08.771 11174 ERROR keystone     bind=self.connection, mode=self.mode)", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py\", line 277, in _create_session", "2017-12-07 12:09:08.771 11174 ERROR keystone     self._start()", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py\", line 363, in _start", "2017-12-07 12:09:08.771 11174 ERROR keystone     engine_args, maker_args)", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py\", line 387, in _setup_for_connection", "2017-12-07 12:09:08.771 11174 ERROR keystone     sql_connection=sql_connection, **engine_kwargs)", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/engines.py\", line 155, in create_engine", "2017-12-07 12:09:08.771 11174 ERROR keystone     test_conn = _test_connection(engine, max_retries, retry_interval)", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/engines.py\", line 339, in _test_connection", "2017-12-07 12:09:08.771 11174 ERROR keystone     six.reraise(type(de_ref), de_ref)", "2017-12-07 12:09:08.771 11174 ERROR keystone   File \"\", line 2, in reraise", "2017-12-07 12:09:08.771 11174 ERROR keystone DBConnectionError: (pymysql.err.OperationalError) (2003, \"Can't connect to MySQL server on 'controller' ([Errno 111] Connection refused)\")", "2017-12-07 12:09:08.771 11174 ERROR keystone "], "stdout": "", "stdout_lines": []}

你可能感兴趣的:(openstack,linux运维)