我是靠谱客的博主 缥缈金鱼,最近开发中收集的这篇文章主要介绍组复制,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

六、组复制

 1、修改
server_id=2
gtid_mode=ON
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_checksum=NONE
log_slave_updates=ON
log_bin=binlog
binlog_format=ROW

transaction_write_set_extraction=XXHASH64
loose-group_replication_group_name="40223b85-80f5-11e8-9b54-5254009db25a"
loose-group_replication_start_on_boot=off
loose-group_replication_local_address= "172.25.77.2:24901"
loose-group_replication_group_seeds= "172.25.77.2:24901,172.25.77.1:24901,172.25.77.3:24901"
loose-group_replication_bootstrap_group=off

loose-group_replication_ip_whitelist='127.0.0.1/8,172.25.77.0/24'
loose-group_replication_enforce_update_everywhere_checks=true
loose-group_replication_single_primary_mode=false

 2、server2主机配置
[root@server2 mysql]# pwd
/var/lib/mysql
[root@serve2 mysql]# rm -fr *
[root@server2 mysql]# /etc/init.d/mysqld start
[root@server2 mysql]# mysql -p

mysql> set sql_log_bin=0;
mysql> alter user root@localhost identified by 'Westos#123';
mysql> grant replication slave on *.* to repl@'%' identified by 'Westos#123';
mysql> flush privileges;
mysql> set sql_log_bin=1;
mysql> change master to master_user='repl',master_password='Westos#123' for channel 'group_replication_recovery';
mysql> install plugin group_replication soname 'group_replication.so';

mysql> set global group_replication_bootstrap_group=on;    ##只有server2主机做
mysql> start group_replication;
mysql> set global group_replication_bootstrap_group=off;

mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | b9590fed-80f6-11e8-b64b-525400eec4fb | server2    |        3306 | ONLINE       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+

 3、server1主机配置
##主配置文件只修改下面2行:
[root@server1 mysql]# vim /etc/my.cnf
server_id=1
loose-group_replication_local_address= "172.25.77.1:24901"

##启动脚本注释以下几行:
[root@server2 mysql]# vim /etc/init.d/mysqld
112             #[ $ret -ne 0 ] && return $ret
113             #initfile="$(install_validate_password_sql_file)"
114             #action $"Installing validate password plugin: " /usr/sbin/mysqld --data    dir="$datadir" --user=mysql --init-file="$initfile"
115             #ret=$?
116             #rm -f "$initfile"

##进入mysql配置
[root@server1 mysql]# /etc/init.d/mysqld start
[root@server2 mysql]# grep password /var/log/mysqld.log
[root@server2 mysql]# mysql -p

mysql> set sql_log_bin=0;
mysql> alter user root@localhost identified by 'Westos#123';
mysql> grant replication slave on *.* to repl@'%' identified by 'Westos#123';
mysql> flush privileges;
mysql> set sql_log_bin=1;
mysql> change master to master_user='repl',master_password='Westos#123' for channel 'group_replication_recovery';
mysql> install plugin group_replication soname 'group_replication.so';

mysql> set global group_replication_allow_local_disjoint_gtids_join=on;    ##server1和server3主机必须做

mysql> start group_replication;
mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 2e07d15c-80fd-11e8-ba64-5254009db25a | server3     |        3306 | ONLINE       |
| group_replication_applier | 39bb4704-80fe-11e8-ba10-5254008d996b | server1     |        3306 | ONLINE       |
| group_replication_applier | b9590fed-80f6-11e8-b64b-525400eec4fb | server2     |        3306 | ONLINE       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+

 4、server3主机同上,即可实现

 5、测试:3个主机均可在mysql进行读写操作

最后

以上就是缥缈金鱼为你收集整理的组复制的全部内容,希望文章能够帮你解决组复制所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(56)

评论列表共有 0 条评论

立即
投稿
返回
顶部