Linux7单机部署MySQL5.7.29 Group Replication集群过程

SHELL>

创建用户:

useradd mysqlmgr01
useradd mysqlmgr02
useradd mysqlmgr03

解压mysql程序包:

cd /home/mysqlmgr01
tar -xf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
cp /home/mysqlmgr01/mysql-5.7.29 /home/mysqlmgr02/mysql-5.7.29
cp /home/mysqlmgr01/mysql-5.7.29 /home/mysqlmgr03/mysql-5.7.29
chown -R mysqlmgr01.mysqlmgr01 /home/mysqlmgr01/
chown -R mysqlmgr02.mysqlmgr02 /home/mysqlmgr02/
chown -R mysqlmgr03.mysqlmgr03 /home/mysqlmgr03/

初始化数据库:

/home/mysqlmgr01/mysql-5.7.29/bin/mysqld --initialize-insecure --basedir=/home/mysqlmgr01/mysql-5.7.29 --datadir=/home/mysqlmgr01/mysql-5.7.29/s01 --log-error=/home/mysqlmgr01/mysql-5.7.29/s01/log
/home/mysqlmgr02/mysql-5.7.29/bin/mysqld --initialize-insecure --basedir=/home/mysqlmgr02/mysql-5.7.29 --datadir=/home/mysqlmgr02/mysql-5.7.29/s02 --log-error=/home/mysqlmgr02/mysql-5.7.29/s02/log
/home/mysqlmgr03/mysql-5.7.29/bin/mysqld --initialize-insecure --basedir=/home/mysqlmgr03/mysql-5.7.29 --datadir=/home/mysqlmgr03/mysql-5.7.29/s03 --log-error=/home/mysqlmgr03/mysql-5.7.29/s03/log

配置文件(修改03为01和02放到/home/mysqlmgr03/mysql-5.7.29/s03.cnf):

[mysqld]
#
# server configuration
#    
#   replicate-do-db    设定需要复制的数据库
#   replicate-ignore-db 设定需要忽略的复制数据库
#   replicate-do-table  设定需要复制的表
#   replicate-ignore-table 设定需要忽略的复制表
#   replicate-wild-do-table 同replication-do-table功能一样,但是可以通配符
#   replicate-wild-ignore-table 同replication-ignore-table功能一样,但是可以加通配符
# #

datadir=/home/mysqlmgr03/mysql-5.7.29/s03
port=24803
socket=/home/mysqlmgr03/mysql-5.7.29/s03/s03.sock
plugin_dir=/home/mysqlmgr03/mysql-5.7.29/lib/plugin/
lc-messages-dir=/home/mysqlmgr03/mysql-5.7.29/share/english
#
# # Replication configuration parameters
# #
server_id=3
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
#
# # Group Replication configuration
# #
transaction_write_set_extraction=XXHASH64
loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
loose-group_replication_start_on_boot=off
loose-group_replication_local_address= "127.0.0.1:24903"
loose-group_replication_group_seeds= "127.0.0.1:24901,127.0.0.1:24902,127.0.0.1:24903"
loose-group_replication_bootstrap_group=off
loose-group_replication_allow_local_disjoint_gtids_join=ON

3个shell窗口启动数据库,便于查看

/home/mysqlmgr01/mysql-5.7.29/bin/mysqld --defaults-file=/home/mysqlmgr01/mysql-5.7.29/s01.cnf
/home/mysqlmgr02/mysql-5.7.29/bin/mysqld --defaults-file=/home/mysqlmgr02/mysql-5.7.29/s02.cnf
/home/mysqlmgr03/mysql-5.7.29/bin/mysqld --defaults-file=/home/mysqlmgr03/mysql-5.7.29/s03.cnf

登录数据库

mysql -hlocalhost -p24801 -uroot -p --socket=/home/mysqlmgr01/mysql-5.7.29/s01/s01.sock
mysql -hlocalhost -p24802 -uroot -p --socket=/home/mysqlmgr02/mysql-5.7.29/s02/s02.sock
mysql -hlocalhost -p24803 -uroot -p --socket=/home/mysqlmgr03/mysql-5.7.29/s03/s03.sock

MySQL>

 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';
 
 --仅一台服务器执行下面一条语句
 --SET GLOBAL group_replication_bootstrap_group=ON; 
 
 START GROUP_REPLICATION; 
 
 set global read_only=0;
 flush privileges;

测试

SELECT * FROM performance_schema.replication_group_members; 

创建查询主服务器视图

use mysql;
create view master_server as select *from  performance_schema.replication_group_members where member_id =(select variable_value from performance_schema.global_status WHERE VARIABLE_NAME= 'group_replication_primary_member');

测试

select * from mysql.master_server;
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读