中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

怎么部署MySQL Group Replication

發布時間:2021-11-18 11:31:58 來源:億速云 閱讀:268 作者:iii 欄目:MySQL數據庫

這篇文章主要介紹“怎么部署MySQL Group Replication”,在日常操作中,相信很多人在怎么部署MySQL Group Replication問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么部署MySQL Group Replication”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

一、環境準備

名稱    版本    備注
操作系統    RHEL6.5_X86_64    
數據庫    5.7.18-15   Percona二進制版本
復制節點  10.26.7.129 node1
    10.26.7.142 node2
    10.26.7.166 node3

二、MGR詳細部署步驟
1、MYSQL5.7安裝
本次學習實驗采用的是Percona-Server-5.7.18-15-Linux.x86_64.ssl101二進制版本,具體安裝過程略
2、節點1my.cnf參數配置(主寫節點)
#replicate
server-id=1001
skip-slave-start = false
read-only = false
expire_logs_days = 2
max_binlog_size = 1G
max_binlog_cache_size = 2G
log-bin = /home/mysql/mysql-bin
log-bin-index = /home/mysql/bin-index
binlog_format = row

log-slave-updates = 1
sync_binlog = 1
log-slow-slave-statements = 1
max-relay-log-size = 1G
relay-log = /home/mysql/mysql-relay
relay-log-index = /home/mysql/relay-index
gtid_mode=ON
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_checksum=NONE
#group replication
transaction_write_set_extraction  =XXHASH64         
loose-group_replication_group_name  ="2faa74b8-66bb-11e7-ab7e-b8ca3a6a61ec"  #務必以uuid形式配置
loose-group_replication_start_on_boot  =off
loose-group_replication_local_address  ="10.26.7.129:24001"                                    #不同節點配置不同節點本身的IP地址和端口,區分MYSQL自身的3306端口
loose-group_replication_group_seeds  ="10.26.7.129:24001,10.26.7.142:24001,10.26.7.166:24001"
loose-group_replication_bootstrap_group  =off
3、創建復制賬戶(主寫節點)
set sql_log_bin=0;
create user rpl_user@'%';
grant replication slave on *.* to rpl_user@'%'  identified by 'rpl_pass';
flush privileges;
set sql_log_bin=1;
change master to master_user='rpl_user',master_password='rpl_pass' for channel 'group_replication_recovery';
4、安裝組復制插件并啟動組復制(主寫節點)
安裝插件
install plugin group_replication soname 'group_replication.so';
檢查插件是否正確安裝
show plugins
+-----------------------------+----------+--------------------+----------------------+---------+
| Name                        | Status   | Type               | Library              | License |
+-----------------------------+----------+--------------------+----------------------+---------+
| group_replication           | ACTIVE   | GROUP REPLICATION  | group_replication.so | GPL     |
+-----------------------------+----------+--------------------+----------------------+---------+
啟動組復制
set global group_replication_bootstrap_group=ON;
start group_replication;
set global group_replication_bootstrap_group=OFF;
檢查組復制成員及狀態
select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 2faa74b8-66bb-11e7-ab7e-b8ca3a6a61ec | node1       |        3306 | ONLINE       |
5、添加組復制成員實例node2 和node3
***添加節點前,務必做DNS解析,如果沒有配置DNS解析服務器,需要在每個節點配置hosts解析  /etc/hosts***
10.26.7.166 node3
10.26.7.142 node2
10.26.7.129 node1

***節點my.cnf參數文件server-id和loose-group_replication_local_address ="node2:24001需要分別更改"***

node2
set sql_log_bin=0;
create user rpl_user@'%';
grant replication slave on *.* to rpl_user@'%'  identified by 'rpl_pass';
flush privileges;

set sql_log_bin=1;
change master to master_user='rpl_user',master_password='rpl_pass' for channel 'group_replication_recovery';

install plugin group_replication soname 'group_replication.so';
show plugins

set global group_replication_allow_local_disjoint_gtids_join=ON;
start group_replication;

node3同樣執行上述命令

然后檢查組復制信息
select * from performance_schema.replication_group_members;     
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 2faa74b8-66bb-11e7-ab7e-b8ca3a6a61ec | node1       |        3306 | ONLINE       |
| group_replication_applier | 35e38786-66bb-11e7-bcc3-b8ca3a6a61a4 | node2       |        3306 | ONLINE       |
| group_replication_applier | 3bbedb1e-66bb-11e7-8fc0-b8ca3a6a7c48 | node3       |        3306 | ONLINE       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+

測試組復制是否正常:
(root:localhost:Sat Jul 15 13:26:33 2017)[(none)]>create database dbtest;
Query OK, 1 row affected (0.01 sec)
(root:localhost:Sat Jul 15 13:26:40 2017)[(none)]>use dbtest;
Database changed
(root:localhost:Sat Jul 15 13:26:45 2017)[dbtest]>create table t1(id int primary key);
Query OK, 0 rows affected (0.01 sec)
(root:localhost:Sat Jul 15 13:26:54 2017)[dbtest]>insert into t1 values(1);
Query OK, 1 row affected (0.00 sec)
node2和node3執行查詢
(root:localhost:Sat Jul 15 12:57:32 2017)[db01]>use dbtest;
Database changed
(root:localhost:Sat Jul 15 13:27:26 2017)[dbtest]>select * from t1;
+----+
| id |
+----+
|  1 |
+----+
1 row in set (0.00 sec)
三、錯誤問題以及匯總:
1、錯誤案例01
錯誤信息:2017-07-15T01:36:06.929941Z 4 [ERROR] Plugin group_replication reported: 'The group name 'group-replication-test' is not a valid UUID'
錯誤原因:loose-group_replication_group_name參數沒有按照UUID格式指定,被認為設置該參數無效
解決方案:更改loose-group_replication_group_name參數值為,loose-group_replication_group_name  ="2faa74b8-66bb-11e7-ab7e-b8ca3a6a61ec"
2、錯誤案例02
錯誤信息:
2017-07-15T01:29:27.271909Z 0 [Warning] unknown variable 'loose-group_replication_group_name=group-replication-test'
2017-07-15T01:29:27.271926Z 0 [Warning] unknown variable 'loose-group_replication_start_on_boot=off'
2017-07-15T01:29:27.271930Z 0 [Warning] unknown variable 'loose-group_replication_local_address=10.26.7.129:3306'
2017-07-15T01:29:27.271935Z 0 [Warning] unknown variable 'loose-group_replication_group_seeds=10.26.7.129:3306,10.26.7.142:3306,10.26.7.166:3306'
2017-07-15T01:29:27.271939Z 0 [Warning] unknown variable 'loose-group_replication_bootstrap_group=off'
錯誤原因:因為先設置了這些參數,而沒有裝group_replication插件,導致數據庫實例無法識別這些參數
解決方案:安裝group replication插件,install plugin group_replication soname 'group_replication.so'; (uninstall plugin group_replication 卸載,show plugins查看)
3、錯誤案例03
錯誤信息:
2017-07-15T01:54:54.447829Z 0 [Note] Plugin group_replication reported: 'Unable to bind to 0.0.0.0:3306 (socket=60, errno=98)!'
2017-07-15T01:54:54.447948Z 0 [ERROR] Plugin group_replication reported: 'Unable to announce tcp port 3306. Port already in use?'
2017-07-15T01:54:54.448101Z 0 [ERROR] Plugin group_replication reported: '[GCS] Error joining the group while waiting for the network layer to become ready.'
錯誤原因:配置的組復制監聽端口和MYSQL實例端口沖突
解決方案:調整下面參數
loose-group_replication_local_address  ="10.26.7.129:24001"                                    #不同節點配置不同節點本身的IP地址和端口,區分MYSQL自身的3306端口
loose-group_replication_group_seeds  ="10.26.7.129:24001,10.26.7.142:24001,10.26.7.166:24001"
4、錯誤案例04
錯誤信息:
2017-07-15T04:20:01.249529Z 21 [ERROR] Slave I/O for channel 'group_replication_recovery': error connecting to master 'rpl_user@node2:3306' - retry-time: 60  retries: 1, Error_code: 2005
錯誤原因:沒有配置DNS解析或者hosts解析,節點無法連接其他數據庫
解決方案:配置hosts解析,每個節點/etc/hosts添加如下內容
10.26.7.166 node3
10.26.7.142 node2
10.26.7.129 node1
5、錯誤案例05
錯誤信息
2017-07-15T03:42:45.395407Z 288 [ERROR] Slave SQL for channel 'group_replication_recovery': Error 'Can't create database 'db01'; database exists' on query. Default database: 'db01'. Query: 'create database db01', Error_code: 1007
2017-07-15T03:42:45.395472Z 288 [Warning] Slave: Can't create database 'db01'; database exists Error_code: 1007
2017-07-15T03:42:45.395503Z 288 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000005' position 434
錯誤原因:這個錯誤是由于節點由于各種原因退出mgr組,后面又加入了mgr組,但之前存在的數據依舊存在
解決方案:刪除要加入組復制節點存在的數據庫即可,但其他節點不是主寫節點,需要先調整參數set global super_read_only=0;然后執行drop database db01;再重新加入組
set global group_replication_allow_local_disjoint_gtids_join=ON;
start group_replication;
6、錯誤案例06
錯誤信息:
2017-07-15T03:44:09.982428Z 18 [ERROR] Slave SQL for channel 'group_replication_recovery': Error 'Can't create database 'db01'; database exists' on query. Default database: 'db01'. Query: 'create database db01', Error_code: 1007
2017-07-15T03:44:09.982493Z 18 [Warning] Slave: Can't create database 'db01'; database exists Error_code: 1007
2017-07-15T03:44:09.982522Z 18 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000005' position 434
錯誤原因:同上錯誤案例05
解決方案:同上錯誤案例05
7、錯誤案例07
錯誤信息:
2017-07-15T03:49:10.370846Z 0 [ERROR] Plugin group_replication reported: 'This member has more executed transactions than those present in the group. Local transactions: 2faa74b8-66bb-11e7-ab7e-b8ca3a6a61ec:1-4,35e38786-66bb-11e7-bcc3-b8ca3a6a61a4:1 > Group transactions: 2faa74b8-66bb-11e7-ab7e-b8ca3a6a61ec:1-16'
錯誤原因:同上錯誤案例05,在從庫執行了多余的事務
解決方案:同上錯誤案例05,直接重新加入節點即可
set global group_replication_allow_local_disjoint_gtids_join=ON;
start group_replication;
8、錯誤案例08
錯誤信息
ERROR 3098 (HY000): The table does not comply with the requirements by an external plugin.
錯誤原因:由于主節點創建了表t1,但沒有指定主鍵(此時表結構可以復制到各節點,一旦插入數據DML操作即會報錯)
解決方案:為表增加主鍵,然后做DML操作(MGR需要各表都有主鍵)
alter table t1 add primary key(id);
insert into t1 values(1),(2);    
9、錯誤案例09
錯誤信息:
mysqldump -R -E --triggers --single-transaction  --master-data=2 -B db01 >db01.sql
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events.
mysqldump: Couldn't execute 'SAVEPOINT sp': The MySQL server is running with the --transaction-write-set-extraction!=OFF option so it cannot execute this statement (1290)
錯誤原因:mgr不支持mysqldump的事務一致性備份,因為其不支持savepoint
解決方案:通過xtrabackup或者不加--single-transaction備份
10、錯誤案例10
錯誤信息:
create table t2 as select * from t1;
ERROR 1786 (HY000): Statement violates GTID consistency: CREATE TABLE ... SELECT.
錯誤原因:配置MGR,開啟了GTID,所有GTID不支持的操作,MGR也不支持
解決方案:使用create table t2 like t1; insert into t2 select * from t;分開兩個事務執行

到此,關于“怎么部署MySQL Group Replication”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

上林县| 门头沟区| 涡阳县| 咸宁市| 兴化市| 元谋县| 连南| 永寿县| 壤塘县| 浙江省| 石泉县| 上饶县| 潼南县| 渭源县| 翁牛特旗| 东方市| 体育| 法库县| 白城市| 湘潭市| 峨山| 海城市| 合作市| 永靖县| 桂林市| 九江县| 壶关县| 黄平县| 公安县| 西青区| 岐山县| 嘉禾县| 乌兰察布市| 南投市| 绿春县| 杭州市| 大竹县| 辽中县| 岳池县| 灵台县| 虹口区|