搭建 MySQL 8.0 InnoDB Cluster
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了搭建 MySQL 8.0 InnoDB Cluster相关的知识,希望对你有一定的参考价值。
1、在三个节点上安装 mysql 8.0
rpm -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 [email protected]'localhost' identified by 'MySQL8.0';
CREATE USER [email protected]'%' 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('[email protected]:3306')
MySQL kuber01:3306 ssl JS > cluster.addInstance('[email protected]:3306');
MySQL kuber01:3306 ssl JS > cluster.addInstance('[email protected]:3306');
MySQL kuber01:3306 ssl JS > cluster.status();
5、所有节点停止后重启集群:
var cluster = dba.rebootClusterFromCompleteOutage('myCluster');
6、配置 MySQL Router
mysqlrouter --bootstrap [email protected]:3306 --user=mysqlrouter
mysqlrouter &
参考文档:
https://blog.csdn.net/KokJuis/article/details/78401022
https://blog.csdn.net/tuyong1972873004/article/details/77260036
以上是关于搭建 MySQL 8.0 InnoDB Cluster的主要内容,如果未能解决你的问题,请参考以下文章
MySQL 8.0 innodb_undo_tablespace废弃掉
死锁 BLOB INSERT MySQL 8.0 InnoDB 集群
MySQL 8.0 InnoDB Cluster 恢复故障成员
MySQL 8.0中InnoDB buffer pool size进度更透明