MySQL Shell無法拉起MGR叢集解決辦法
阿新 • • 發佈:2022-03-13
用MySQL Shell要重新拉起一個MGR叢集時,可能會提示下面的錯誤資訊:
Dba.rebootClusterFromCompleteOutage: Unable to get an InnoDB cluster handle. The instance '172.16.130.197:3306' may belong to a different cluster from the one registered in the Metadata since the value of 'group_replication_group_name' does not match the one registered in the Metadata: possible split-brain scenario. Please retry while connected to another member of the cluster. (RuntimeError)
意思是該節點屬於其他MGR叢集(從元資料讀取到的 group_replication_group_name
值判斷的),因此不能直接拉起。
這種錯誤常見於MySQL 5.7版本構建的MGR叢集環境下,如果是執行MySQL 8.0的話則一般很少見。
之所以會這樣,是因為MySQL 5.7中還不支援 SET PERSIST 功能。
在MySQL 8.0中,用MySQL Shell構建MGR叢集時,會隨機生成一個UUID作為 group_replication_group_name,並以 SET PERSIST 的方式持久化(儲存到 mysqld-auto.cnf
檔案中),例項重啟時還能繼續讀取。
而在MySQL 5.7中,因為沒有這個功能,例項重啟時還會從原來的 my.cnf
現在已經知道問題的原因了,解決辦法也簡單。
- 獲取正確的 group_replication_group_name。
例項重啟完成後,讀取mysql_innodb_cluster_metadata.clusters
這個元資料表,獲取正確的 group name。
mysql> select attributes->'$.group_replication_group_name' from clusters;
+----------------------------------------------+
| attributes->'$.group_replication_group_name' |
+----------------------------------------------+
| "bc664a9b-9b5b-11ec-8a73-525400c5601a" |
+----------------------------------------------+
- 在每個節點上手動修改 group_replication_group_name 。
mysql> set global group_replication_group_name = "bc664a9b...";
- 再次執行
dba.rebootClusterFromCompleteOutage()
就行了。
MySQL 172.16.130.197:3306 ssl JS > dba.rebootClusterFromCompleteOutage()
Restoring the default cluster from complete outage...
Enjoy GreatSQL :)