标签:mysql
1、在三个节点上安装 MySQL 8.0rpm -i https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum install mysql-community-{server,client,common,libs}-*
systemctl start mysqld
2、修改 my.cnf 配置文件
#节点1
server_id=1
gtid_mode=ON
enforce_gtid_consistency=ON
binlog_checksum=NONE
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= "192.168.1.249:24901"
loose-group_replication_group_seeds= "192.168.1.249:24901,192.168.1.252:24901,192.168.1.253:24901"
loose-group_replication_bootstrap_group=off
loose-group_replication_ip_whitelist="192.168.1.0/24"
#节点2
server_id=2
gtid_mode=ON
enforce_gtid_consistency=ON
binlog_checksum=NONE
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= "192.168.1.252:24901"
loose-group_replication_group_seeds= "192.168.1.249:24901,192.168.1.252:24901,192.168.1.253:24901"
loose-group_replication_bootstrap_group=off
loose-group_replication_ip_whitelist="192.168.1.0/24"
loose-group_replication_allow_local_disjoint_gtids_join=ON
#节点3
server_id=3
gtid_mode=ON
enforce_gtid_consistency=ON
binlog_checksum=NONE
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= "192.168.1.253:24901"
loose-group_replication_group_seeds= "192.168.1.249:24901,192.168.1.252:24901,192.168.1.253:24901"
loose-group_replication_bootstrap_group=off
loose-group_replication_ip_whitelist="192.168.1.0/24"
loose-group_replication_allow_local_disjoint_gtids_join=ON
3、在三个节点创建复制账户
SET SQL_LOG_BIN=0;
alter user root@'localhost' identified by 'MySQL8.0';
CREATE USER root@'%' IDENTIFIED BY 'MySQL8.0';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO 'root'@'%' WITH GRANT OPTION;
GRANT BACKUP_ADMIN, BINLOG_ADMIN, CONNECTION_ADMIN, ENCRYPTION_KEY_ADMIN, GROUP_REPLICATION_ADMIN, PERSIST_RO_VARIABLES_ADMIN, REPLICATION_SLAVE_ADMIN, RESOURCE_GROUP_ADMIN, RESOURCE_GROUP_USER, ROLE_ADMIN, SET_USER_ID, SYSTEM_VARIABLES_ADMIN, XA_RECOVER_ADMIN ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
SET SQL_LOG_BIN=1;
4、在第一个节点创建集群并添加节点二、节点三
MySQL JS > shell.connect('root@kuber01:3306')
MySQL kuber01:3306 ssl JS > cluster.addInstance('root@node02:3306');
MySQL kuber01:3306 ssl JS > cluster.addInstance('root@node03:3306');
MySQL kuber01:3306 ssl JS > cluster.status();
5、所有节点停止后重启集群:
var cluster = dba.rebootClusterFromCompleteOutage('myCluster');
6、配置 MySQL Router
mysqlrouter --bootstrap root@kuber01:3306 --user=mysqlrouter
mysqlrouter &
参考文档:
https://blog.csdn.net/KokJuis/article/details/78401022
https://blog.csdn.net/tuyong1972873004/article/details/77260036
标签:mysql
原文地址:http://blog.51cto.com/linux10000/2128077