keystone同步時無法連接數(shù)據(jù)庫的失敗解決方法

問題:

root@swift:/etc/mysql/mariadb.conf.d# su -s /bin/sh -c "keystone-manage db_sync" keystone2017-05-17 21:38:28.105 5553 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 10 attempts left.2017-05-17 21:38:38.107 5553 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 9 attempts left.2017-05-17 21:38:48.117 5553 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 8 attempts left.2017-05-17 21:38:58.124 5553 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 7 attempts left.2017-05-17 21:39:08.130 5553 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 6 attempts left.2017-05-17 21:39:18.138 5553 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 5 attempts left.2017-05-17 21:39:28.144 5553 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 4 attempts left.2017-05-17 21:39:38.151 5553 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 3 attempts left.2017-05-17 21:39:48.158 5553 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 2 attempts left.2017-05-17 21:39:58.167 5553 WARNING oslo_db.sqlalchemy.engines [-] SQL connection failed. 1 attempts left.2017-05-17 21:40:08.171 5553 CRITICAL keystone [-] DBConnectionError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'swift' ([Errno 111] Connection refused)")2017-05-17 21:40:08.171 5553 ERROR keystone Traceback (most recent call last):2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/bin/keystone-manage", line 10, in2017-05-17 21:40:08.171 5553 ERROR keystone? ? sys.exit(main())2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/keystone/cmd/manage.py", line 47, in main2017-05-17 21:40:08.171 5553 ERROR keystone? ? cli.main(argv=sys.argv, config_files=config_files)2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/keystone/cmd/cli.py", line 1024, in main2017-05-17 21:40:08.171 5553 ERROR keystone? ? CONF.command.cmd_class.main()2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/keystone/cmd/cli.py", line 403, in main2017-05-17 21:40:08.171 5553 ERROR keystone? ? migration_helpers.sync_database_to_version(extension, version)2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/keystone/common/sql/migration_helpers.py", line 210, in sync_database_to_version2017-05-17 21:40:08.171 5553 ERROR keystone? ? _sync_common_repo(version)2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/keystone/common/sql/migration_helpers.py", line 132, in _sync_common_repo2017-05-17 21:40:08.171 5553 ERROR keystone? ? with sql.session_for_write() as session:2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__2017-05-17 21:40:08.171 5553 ERROR keystone? ? return self.gen.next()2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 759, in _transaction_scope2017-05-17 21:40:08.171 5553 ERROR keystone? ? allow_async=self._allow_async) as resource:2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__2017-05-17 21:40:08.171 5553 ERROR keystone? ? return self.gen.next()2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 491, in _session2017-05-17 21:40:08.171 5553 ERROR keystone? ? bind=self.connection, mode=self.mode)2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 272, in _create_session2017-05-17 21:40:08.171 5553 ERROR keystone? ? self._start()2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 338, in _start2017-05-17 21:40:08.171 5553 ERROR keystone? ? engine_args, maker_args)2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py", line 362, in _setup_for_connection2017-05-17 21:40:08.171 5553 ERROR keystone? ? sql_connection=sql_connection, **engine_kwargs)2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/engines.py", line 152, in create_engine2017-05-17 21:40:08.171 5553 ERROR keystone? ? test_conn = _test_connection(engine, max_retries, retry_interval)2017-05-17 21:40:08.171 5553 ERROR keystone? File "/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/engines.py", line 334, in _test_connection2017-05-17 21:40:08.171 5553 ERROR keystone? ? six.reraise(type(de_ref), de_ref)2017-05-17 21:40:08.171 5553 ERROR keystone? File "", line 2, in reraise

解決方法:

使用root登錄MySQL

MariaDB [(none)]> show variables like "%char%";

+--------------------------+----------------------------+

| Variable_name? ? ? ? ? ? | Value? ? ? ? ? ? ? ? ? ? ? |

+--------------------------+----------------------------+

| character_set_client? ? | utf8mb4? ? ? ? ? ? ? ? ? ? |

| character_set_connection | utf8mb4? ? ? ? ? ? ? ? ? ? |

| character_set_database? | utf8mb4? ? ? ? ? ? ? ? ? ? |

| character_set_filesystem | binary? ? ? ? ? ? ? ? ? ? |

| character_set_results? ? | utf8mb4? ? ? ? ? ? ? ? ? ? |

| character_set_server? ? | utf8mb4? ? ? ? ? ? ? ? ? ? |

| character_set_system? ? | utf8? ? ? ? ? ? ? ? ? ? ? |

| character_sets_dir? ? ? | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

8 rows in set (0.02 sec)

MariaDB [(none)]>exit

修改/etc/mysql/mariadb.conf.d/目錄下的文件“50-client.cnf 50-mysql-clients.cnf ? 50-server.cnf”

將其中的utf8mb4修改為utf8

mariadb 修改允許遠程訪問

sed?-i?'s/127.0.0.1/0.0.0.0/g'?/etc/mysql/mariadb.conf.d/50-server.cnf

重啟mysql服務(wù)

service mysql restart

再次進入MySQL

MariaDB [(none)]> show variables like "%char%";

+--------------------------+----------------------------+

| Variable_name? ? ? ? ? ? | Value? ? ? ? ? ? ? ? ? ? ? |

+--------------------------+----------------------------+

| character_set_client? ? | utf8? ? ? ? ? ? ? ? ? ? ? |

| character_set_connection | utf8? ? ? ? ? ? ? ? ? ? ? |

| character_set_database? | utf8? ? ? ? ? ? ? ? ? ? ? |

| character_set_filesystem | binary? ? ? ? ? ? ? ? ? ? |

| character_set_results? ? | utf8? ? ? ? ? ? ? ? ? ? ? |

| character_set_server? ? | utf8? ? ? ? ? ? ? ? ? ? ? |

| character_set_system? ? | utf8? ? ? ? ? ? ? ? ? ? ? |

| character_sets_dir? ? ? | /usr/share/mysql/charsets/ |

+--------------------------+----------------------------+

此時還需將原有的數(shù)據(jù)庫keystone刪除再重新創(chuàng)建

MariaDB [(none)]>drop database keystone;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE DATABASE keystone;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY '8782';

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY '8782';

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit

Bye

再進行同步數(shù)據(jù)庫

root@swift:/home/swift# su -s /bin/sh -c "keystone-manage db_sync" keystone

2017-05-17 21:50:35.746 2708 INFO migrate.versioning.api [-] 66 -> 67...

2017-05-17 21:50:36.418 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.419 2708 INFO migrate.versioning.api [-] 67 -> 68...

2017-05-17 21:50:36.435 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.435 2708 INFO migrate.versioning.api [-] 68 -> 69...

2017-05-17 21:50:36.453 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.454 2708 INFO migrate.versioning.api [-] 69 -> 70...

2017-05-17 21:50:36.471 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.471 2708 INFO migrate.versioning.api [-] 70 -> 71...

2017-05-17 21:50:36.489 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.489 2708 INFO migrate.versioning.api [-] 71 -> 72...

2017-05-17 21:50:36.511 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.512 2708 INFO migrate.versioning.api [-] 72 -> 73...

2017-05-17 21:50:36.572 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.572 2708 INFO migrate.versioning.api [-] 73 -> 74...

2017-05-17 21:50:36.617 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.617 2708 INFO migrate.versioning.api [-] 74 -> 75...

2017-05-17 21:50:36.647 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.647 2708 INFO migrate.versioning.api [-] 75 -> 76...

2017-05-17 21:50:36.663 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.663 2708 INFO migrate.versioning.api [-] 76 -> 77...

2017-05-17 21:50:36.681 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.681 2708 INFO migrate.versioning.api [-] 77 -> 78...

2017-05-17 21:50:36.699 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.700 2708 INFO migrate.versioning.api [-] 78 -> 79...

2017-05-17 21:50:36.718 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.719 2708 INFO migrate.versioning.api [-] 79 -> 80...

2017-05-17 21:50:36.736 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.738 2708 INFO migrate.versioning.api [-] 80 -> 81...

2017-05-17 21:50:36.768 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.768 2708 INFO migrate.versioning.api [-] 81 -> 82...

2017-05-17 21:50:36.852 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.852 2708 INFO migrate.versioning.api [-] 82 -> 83...

2017-05-17 21:50:36.924 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.925 2708 INFO migrate.versioning.api [-] 83 -> 84...

2017-05-17 21:50:36.961 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:36.962 2708 INFO migrate.versioning.api [-] 84 -> 85...

2017-05-17 21:50:37.022 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.023 2708 INFO migrate.versioning.api [-] 85 -> 86...

2017-05-17 21:50:37.054 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.055 2708 INFO migrate.versioning.api [-] 86 -> 87...

2017-05-17 21:50:37.119 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.120 2708 INFO migrate.versioning.api [-] 87 -> 88...

2017-05-17 21:50:37.160 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.160 2708 INFO migrate.versioning.api [-] 88 -> 89...

2017-05-17 21:50:37.199 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.199 2708 INFO migrate.versioning.api [-] 89 -> 90...

2017-05-17 21:50:37.243 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.244 2708 INFO migrate.versioning.api [-] 90 -> 91...

2017-05-17 21:50:37.319 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.320 2708 INFO migrate.versioning.api [-] 91 -> 92...

2017-05-17 21:50:37.396 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.397 2708 INFO migrate.versioning.api [-] 92 -> 93...

2017-05-17 21:50:37.476 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.476 2708 INFO migrate.versioning.api [-] 93 -> 94...

2017-05-17 21:50:37.546 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.547 2708 INFO migrate.versioning.api [-] 94 -> 95...

2017-05-17 21:50:37.606 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.607 2708 INFO migrate.versioning.api [-] 95 -> 96...

2017-05-17 21:50:37.626 2708 INFO migrate.versioning.api [-] done

2017-05-17 21:50:37.627 2708 INFO migrate.versioning.api [-] 96 -> 97...

2017-05-17 21:50:37.652 2708 INFO migrate.versioning.api [-] done

root@swift:/home/swift#

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末烁设,一起剝皮案震驚了整個濱河市犹菇,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌艺玲,老刑警劉巖肋僧,帶你破解...
    沈念sama閱讀 211,743評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件斑胜,死亡現(xiàn)場離奇詭異,居然都是意外死亡嫌吠,警方通過查閱死者的電腦和手機止潘,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,296評論 3 385
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來辫诅,“玉大人凭戴,你說我怎么就攤上這事】话” “怎么了么夫?”我有些...
    開封第一講書人閱讀 157,285評論 0 348
  • 文/不壞的土叔 我叫張陵者冤,是天一觀的道長。 經(jīng)常有香客問我档痪,道長涉枫,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,485評論 1 283
  • 正文 為了忘掉前任腐螟,我火速辦了婚禮愿汰,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘乐纸。我一直安慰自己衬廷,他們只是感情好,可當我...
    茶點故事閱讀 65,581評論 6 386
  • 文/花漫 我一把揭開白布汽绢。 她就那樣靜靜地躺著吗跋,像睡著了一般。 火紅的嫁衣襯著肌膚如雪庶喜。 梳的紋絲不亂的頭發(fā)上小腊,一...
    開封第一講書人閱讀 49,821評論 1 290
  • 那天,我揣著相機與錄音久窟,去河邊找鬼秩冈。 笑死,一個胖子當著我的面吹牛斥扛,可吹牛的內(nèi)容都是我干的入问。 我是一名探鬼主播,決...
    沈念sama閱讀 38,960評論 3 408
  • 文/蒼蘭香墨 我猛地睜開眼稀颁,長吁一口氣:“原來是場噩夢啊……” “哼芬失!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起匾灶,我...
    開封第一講書人閱讀 37,719評論 0 266
  • 序言:老撾萬榮一對情侶失蹤棱烂,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后阶女,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體颊糜,經(jīng)...
    沈念sama閱讀 44,186評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,516評論 2 327
  • 正文 我和宋清朗相戀三年秃踩,在試婚紗的時候發(fā)現(xiàn)自己被綠了衬鱼。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 38,650評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡憔杨,死狀恐怖鸟赫,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤抛蚤,帶...
    沈念sama閱讀 34,329評論 4 330
  • 正文 年R本政府宣布台谢,位于F島的核電站,受9級特大地震影響霉颠,放射性物質(zhì)發(fā)生泄漏对碌。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,936評論 3 313
  • 文/蒙蒙 一蒿偎、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧怀读,春花似錦诉位、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,757評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至啤誊,卻和暖如春岳瞭,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背蚊锹。 一陣腳步聲響...
    開封第一講書人閱讀 31,991評論 1 266
  • 我被黑心中介騙來泰國打工瞳筏, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人牡昆。 一個月前我還...
    沈念sama閱讀 46,370評論 2 360
  • 正文 我出身青樓姚炕,卻偏偏與公主長得像,于是被迫代替她去往敵國和親丢烘。 傳聞我的和親對象是個殘疾皇子柱宦,可洞房花燭夜當晚...
    茶點故事閱讀 43,527評論 2 349

推薦閱讀更多精彩內(nèi)容

  • 首先,我們在使用前先看看HDFS是什麼播瞳?這將有助于我們是以后的運維使用和故障排除思路的獲得掸刊。 HDFS采用mast...
    W_Bousquet閱讀 4,181評論 0 2
  • 失眠 2009-12-25 08:36 閱讀(49)評論(12) 夜半醒來難再眠, 輾轉(zhuǎn)反側(cè)心煩亂赢乓。 漫漫長夜苦煎...
    零星往事閱讀 185評論 0 0
  • 在陳奕迅的歌里面骏全,感情的跌宕輪回也只有10年苍柏,10年之后就是物是人非。按照咱們?nèi)祟惖恼I韥碛嬎憬薄Df20年试吁,就...
    閑話星座閱讀 329評論 0 0
  • 我曾經(jīng)最后悔的事就是沒能夠考上個好大學熄捍,以至于我總是在夢中夢見上高中的情景烛恤。可在初高中的時候余耽,我并不是那個貪玩不學...
    執(zhí)手天涯暖閱讀 204評論 0 0