zoukankan      html  css  js  c++  java
  • 安装OpenStack时,同步keystone数据库报错 keystone DBConnectionError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'controller' ([Errno 111] Connection refused)")

    执行命令 su -s /bin/sh -c "keystone-manage db_sync" keystone 时一直执行失败,查看/var/log/keystone/keystone.log找到报错如下

    2021-09-27 09:05:18.381 185184 ERROR keystone Traceback (most recent call last):
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/bin/keystone-manage", line 10, in <module>
    2021-09-27 09:05:18.381 185184 ERROR keystone sys.exit(main())
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/keystone/cmd/manage.py", line 44, in main
    2021-09-27 09:05:18.381 185184 ERROR keystone cli.main(argv=sys.argv, config_files=config_files)
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/keystone/cmd/cli.py", line 1312, in main
    2021-09-27 09:05:18.381 185184 ERROR keystone CONF.command.cmd_class.main()
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/keystone/cmd/cli.py", line 467, in main
    2021-09-27 09:05:18.381 185184 ERROR keystone CONF.command.version)
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/keystone/common/sql/upgrades.py", line 251, in offline_sync_database_t o_version
    2021-09-27 09:05:18.381 185184 ERROR keystone expand_schema()
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/keystone/common/sql/upgrades.py", line 271, in expand_schema
    2021-09-27 09:05:18.381 185184 ERROR keystone _sync_common_repo(version=None)
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/keystone/common/sql/upgrades.py", line 167, in _sync_common_repo
    2021-09-27 09:05:18.381 185184 ERROR keystone with sql.session_for_write() as session:
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib64/python2.7/contextlib.py", line 17, in __enter__
    2021-09-27 09:05:18.381 185184 ERROR keystone return self.gen.next()
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py", line 944, in _transaction_scope
    2021-09-27 09:05:18.381 185184 ERROR keystone allow_async=self._allow_async) as resource:
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib64/python2.7/contextlib.py", line 17, in __enter__
    2021-09-27 09:05:18.381 185184 ERROR keystone return self.gen.next()
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py", line 558, in _session
    2021-09-27 09:05:18.381 185184 ERROR keystone bind=self.connection, mode=self.mode)
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py", line 317, in _create_session
    2021-09-27 09:05:18.381 185184 ERROR keystone self._start()
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py", line 403, in _start
    2021-09-27 09:05:18.381 185184 ERROR keystone engine_args, maker_args)
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py", line 427, in _setup_for_connectio n
    2021-09-27 09:05:18.381 185184 ERROR keystone sql_connection=sql_connection, **engine_kwargs)
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/engines.py", line 155, in create_engine
    2021-09-27 09:05:18.381 185184 ERROR keystone test_conn = _test_connection(engine, max_retries, retry_interval)
    2021-09-27 09:05:18.381 185184 ERROR keystone File "/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/engines.py", line 339, in _test_connection
    2021-09-27 09:05:18.381 185184 ERROR keystone six.reraise(type(de_ref), de_ref)
    2021-09-27 09:05:18.381 185184 ERROR keystone File "<string>", line 2, in reraise
    2021-09-27 09:05:18.381 185184 ERROR keystone DBConnectionError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'controller' ([Errno 111] Connection refused)")
    2021-09-27 09:05:18.381 185184 ERROR keystone
    2021-09-27 10:09:09.147 165810 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 10 attempts left.
    2021-09-27 10:09:19.158 165810 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 9 attempts left.
    2021-09-27 10:09:29.169 165810 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 8 attempts left.
    2021-09-27 10:09:39.181 165810 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 7 attempts left.
    2021-09-27 10:09:49.193 165810 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 6 attempts left.
    2021-09-27 10:09:59.204 165810 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 5 attempts left.
    2021-09-27 10:10:09.216 165810 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 4 attempts left.
    2021-09-27 10:10:19.228 165810 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 3 attempts left.
    2021-09-27 10:10:29.240 165810 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 2 attempts left.
    2021-09-27 10:10:39.251 165810 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 1 attempts left.
    2021-09-27 10:10:49.255 165810 CRITICAL keystone [-] DBConnectionError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'controller' ([Errno 111] Connection refused)")

    在报错最后打日志

    再次查看keystone日志可以看到,现在的执行的内容如下

     网上搜了下这个格式应该是

    engine("mysql+pymysql://{user}:{password}@{host}:{port}/ajx?charset=utf8".format(**config))

    不难发现是少了端口

    修改/etc/keystone/keystone.conf 增加端口即可

    再次执行 同步命令

  • 相关阅读:
    eclipse生成jar包 注意事项!
    java结合testng,利用XML做数据源的数据驱动示例
    2018 计蒜之道 初赛 第二场
    2018 计蒜之道 初赛 第一场
    Tarjan&&缩点简析
    POJ1159
    POJ1080
    POJ1260
    POJ2533&&1836&&3176
    Luogu P1484 种树
  • 原文地址:https://www.cnblogs.com/czp2016/p/15343486.html
Copyright © 2011-2022 走看看