安装mysql5.7
yum install
yum install Percona-Server-server-57 Percona-Server-client-57 Percona-Server-devel-57
mkdir -p /data/{3306,3307,3308}/{data,temp,log,etc}/
chown -R mysql.mysql /data
export port=3306
cat >/data/3306/etc/my.cnf<
[mysqld]
user=mysql
port=$port
datadir=/data/$port/data
log-error=/data/$port/log/err.log
pid-file=/data/$port/temp/mysqld.pid
socket=/data/$port/temp/mysql.sock
symbolic-links=0
server_id=$port
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=/data/$port/log/binlog
binlog_format=ROW
transaction_write_set_extraction=XXHASH64
loose-group_replication_group_name="eb5d4f12-5f2f-11e9-8a72-000c29108615" #一组不变
loose-group_replication_start_on_boot=off
loose-group_replication_local_address= "10.1.102.165:1$port"
loose-group_replication_group_seeds= "10.1.102.165:13306,10.1.102.165:13307,10.1.102.165:13308"
loose-group_replication_bootstrap_group=off
loose-group_replication_single_primary_mode=off
loose-group_replication_enforce_update_everywhere_checks=true
[client]
socket=/data/$port/temp/mysql.sock
EOF
数据初始化
mysqld --defaults-file=/data/3306/etc/my.cnf --initialize-insecure --user=mysql
mysqld --defaults-file=/data/3307/etc/my.cnf --initialize-insecure --user=mysql
mysqld --defaults-file=/data/3308/etc/my.cnf --initialize-insecure --user=mysql
启动
mysqld --defaults-file=/data/3306/etc/my.cnf --daemonize
mysqld --defaults-file=/data/3307/etc/my.cnf --daemonize
mysqld --defaults-file=/data/3308/etc/my.cnf --daemonize
修改密码
mysqladmin -S /data/3306/temp/mysql.sock password root
mysqladmin -S /data/3307/temp/mysql.sock password root
mysqladmin -S /data/3308/temp/mysql.sock password root
关闭
mysqladmin -S /data/3306/temp/mysql.sock shutdown -uroot -proot
mysqladmin -S /data/3307/temp/mysql.sock shutdown -uroot -proot
mysqladmin -S /data/3308/temp/mysql.sock shutdown -uroot -proot
全部添加复制用户
set sql_log_bin=0;
grant replication slave,replication client on *.* to repuser@'%' IDENTIFIED BY 'repuser';
grant replication slave,replication client on *.* to repuser@'127.0.0.1' IDENTIFIED BY 'repuser';
grant replication slave,replication client on *.* to repuser@'localhost' IDENTIFIED BY 'repuser' ;
FLUSH PRIVILEGES;
set sql_log_bin=1;
第1节点
# 安装MGR插件
INSTALL PLUGIN group_replication SONAME 'group_replication.so';
# 检查是否成功安装
SHOW PLUGINS ;
# 使用当前数据库节点引导组,一个组内只有一个节点能引导
# 不允许组内多次引导,这将导致产生两个相同名称的不同组
SET GLOBAL group_replication_bootstrap_group=ON;
START GROUP_REPLICATION;
SET GLOBAL group_replication_bootstrap_group=OFF;
SELECT * FROM performance_schema.replication_group_members\G
其它两节点
# 安装MGR插件
INSTALL PLUGIN group_replication SONAME 'group_replication.so';
# 加入组复制
CHANGE MASTER TO MASTER_USER='repuser', MASTER_PASSWORD='repuser' FOR CHANNEL 'group_replication_recovery';
START GROUP_REPLICATION;
SELECT * FROM performance_schema.replication_group_members;
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
| group_replication_applier | 4854e090-1299-11eb-8f24-0800273486ef | localhost.localdomain | 3306 | ONLINE |
| group_replication_applier | 6828837f-1299-11eb-9257-0800273486ef | localhost.localdomain | 3307 | ONLINE |
| group_replication_applier | 6ed96b46-1299-11eb-9496-0800273486ef | localhost.localdomain | 3308 | ONLINE |
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
阅读(6691) | 评论(0) | 转发(0) |