我是靠谱客的博主 冷艳冰淇淋,最近开发中收集的这篇文章主要介绍mysql 8.0 集群_MySQL数据库之搭建 MySQL 8.0 InnoDB Cluster,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

本文主要向大家介绍了MySQL数据库之搭建 MySQL 8.0 InnoDB Cluster ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。

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 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 &

本文由职坐标整理并发布,希望对同学们学习MySQL有所帮助,更多内容请关注职坐标数据库MySQL数据库频道!

最后

以上就是冷艳冰淇淋为你收集整理的mysql 8.0 集群_MySQL数据库之搭建 MySQL 8.0 InnoDB Cluster的全部内容,希望文章能够帮你解决mysql 8.0 集群_MySQL数据库之搭建 MySQL 8.0 InnoDB Cluster所遇到的程序开发问题。

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

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

评论列表共有 0 条评论

立即
投稿
返回
顶部