提示: MySQL InnoDB Cluster底层依赖Group Replication模式,至少3台机器

1.  准备3台 CentOS Linux 7 (Core), 修改各主机名:db-host1, db-host2, db-host3  然后配置各台机器 hosts 映射, 对应如下

cat << EOF >> /etc/hosts
192.168.50.181 db-host1
192.168.50.182 db-host2
192.168.50.183 db-host3
EOF

2. 确保3台服务器要互相访问正常,为了保险期间请关闭防火墙,firewalld常用命令 如:

# 启动
systemctl start firewalld # 关闭
systemctl stop firewalld # 查看状态
systemctl status firewalld # 开机禁用
systemctl disable firewalld # 开机启用
systemctl enable firewalld # 查看所有打开的端口
firewall-cmd --zone=public --list-ports

3. 确保互访使用ssh 共享,这里使用root 账户 如:在db-host1 执行,其它以此类推:

ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.50.182 ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.50.183

4. 准备安装 mysql-community-server,mysql-shell,mysql-router 在3台机器安装,注意版本:

wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
yum install mysql-community-server
wget https://dev.mysql.com/get/Downloads/MySQL-Shell/mysql-shell-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-shell-8.0.18-1.el7.x86_64.rpm
yum install mysql-shell
wget https://dev.mysql.com/get/Downloads/MySQL-Router/mysql-router-community-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-router-community-8.0.17-1.el7.x86_64.rpm
yum install mysql-router

5. 安装完MysqlServer 后,依次每台初始化mysql,步骤如下:#初始化:

mysqld --initialize;

#赋访问权限:
chown mysql:mysql /var/lib/mysql -R #启动mysql服务:
systemctl start mysqld.service; #设置mysql开机自启
mysql systemctl enable mysqld; #命令查看数据库的密码:
cat /var/log/mysqld.log | grep password #进入mysql命令行:
mysql -uroot -p (输入上述查看的数据库密码进入mysql命令行)
#命令来修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码'; #创建远程访问权限:
create user 'root'@'%' identified with mysql_native_password by '密码'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; flush privileges;

6. 由于依赖组复制,在host1 修改  /etc/my.cnf

server_id = 4000000161
loose-group_replication_group_name="a38e32fd-5fb6-11e8-ad7a-00259015d941"
loose-group_replication_local_address= "192.168.50.181:3306"
loose-group_replication_group_seeds= "192.168.50.181:3306,192.168.50.182:3306,192.168.50.183:3306"
loose-group_replication_single_primary_mode=TRUE

然后拷贝 /etc/my.cnf到另外2台机器

rsync -e "ssh -p22" -avpgolr /etc/my.cnf root@192.168.50.182:/etc/
rsync -e "ssh -p22" -avpgolr /etc/my.cnf root@192.168.50.183:/etc/

确保各自 server_id  和 address

host1    server_id = 4000000161

loose-group_replication_local_address= "192.168.50.181:3306"

host2    server_id = 4000000162

loose-group_replication_local_address= "192.168.50.182:3306"

host3    server_id = 4000000163

loose-group_replication_local_address= "192.168.50.183:3306"

7. 3台mysql server 启动组复制

start group_replication

8. 检查实例配置, 使用 mysqlsh

dba.checkInstanceConfiguration('root@db-host1:3306')
dba.checkInstanceConfiguration('root@db-host2:3306')
dba.checkInstanceConfiguration('root@db-host3:3306')

8. 配置实例

dba.configureInstance('root@db-host1:3306',{'restart': true})
dba.configureInstance('root@db-host2:3306',{'restart': true})
dba.configureInstance('root@db-host3:3306',{'restart': true})

9. 创建添加实例

var cluster = dba.createCluster('mycluster');
var cluster=dba.getCluster('mycluster')
cluster.addInstance('root@db-host2:3306');
cluster.addInstance('root@db-host3:3306');

10. 登录主服务器 ,查看,配置成功

mysql> select * from performance_schema.replication_group_members;

注意:由于8.0 中的一些变化和5.X配置有所配置不同,按照以前的配置容易出错,要善于对应分析日志进行排错

推荐参考资料:

https://blog.csdn.net/wzy0623/article/details/100779450

https://www.jianshu.com/p/6e2918845ec8

https://lefred.be/content/mysql-8-0-innodb-cluster-the-quick-hands-on-manual/

https://cloud.tencent.com/developer/article/1445710

MySQL 8.0.18 InnoDB Cluster 主从(MGR)完整安装配置的更多相关文章

  1. mysql 8.0.18 mgr 搭建及其切换

    mysql 8.0.18 mgr 搭建及其切换 一.系统安装包 yum -y install make gcc-c++ cmake bison-devel ncurses-devel readline ...

  2. mysql 8.0.18 手工安装记录

    mysql 8.0.18 手工安装记录 为了日常方便,特记录如下. 一.安装系统依赖包 #.系统依赖包安装 yum -y install make gcc-c++ cmake bison-devel ...

  3. win10 安装mysql 8.0.18 解决Navicat初次连接报错

    win10 安装mysql 8.0.18 解决Navicat初次连接报错 win10 安装mysql 8.0.18-winx64 一,先去官网下载mysql 安装包 https://dev.mysql ...

  4. MySQL 8.0.18安装教程(windows 64位)

    目录 1-先去官网下载点击的MySQL的下载​ 2-配置初始化的my.ini文件的文件3-初始化MySQL4-安装MySQL服务 + 启动MySQL 服务5-连接MySQL + 修改密码 * 第一项 ...

  5. mysql 8.0.18 hash join测试(内外网首文)

    CREATE TABLE COLUMNS_hj as select * from information_schema.`COLUMNS`; INSERT INTO COLUMNS_hj SELECT ...

  6. MySQL 8.0.18 在 Windows Server 2019 上的安装(ZIP)公开

    AskScuti MySQL : Windows Server 2019 安装 MySQL 8.0 温馨提示:为了展现我最“魅力”的一面,请用谷歌浏览器撩我. 一切就绪,点我开撩

  7. MySQL 8.0.18 在 Windows Server 2019 上的安装(MSI)公开

    AskScuti MySQL : Windows Server 2019 安装 MySQL 8.0 温馨提示:为了展现我最“魅力”的一面,请用谷歌浏览器撩我.那个 IE 啊,我很无奈. 一切就绪,点我 ...

  8. Ubuntu 16.04 + CUDA 8.0 + cuDNN v5.1 + TensorFlow(GPU support)安装配置详解

    随着图像识别和深度学习领域的迅猛发展,GPU时代即将来临.由于GPU处理深度学习算法的高效性,使得配置一台搭载有GPU的服务器变得尤为必要. 本文主要介绍在Ubuntu 16.04环境下如何配置Ten ...

  9. mysql 8.0.18 小白安装教程

    1. 下载 官网下载:https://dev.mysql.com/downloads/mysql/ 嫌官网网速慢可以加q群,在群文件里下载: 1.下载第一个download 2.解压在自己建的目录(各 ...

随机推荐

  1. Replication:distribution 中一直在运行 waitfor delay @strdelaytime 语句

    Replication 自动创建来一个 Job:Replication monitoring refresher for distribution,这个Agent执行一个sp: dbo.sp_repl ...

  2. Java开发月薪2W的知乎讨论记录截取

    1. 推荐看 作者:匿名用户 链接:https://www.zhihu.com/question/39890405/answer/83676977 来源:知乎 著作权归作者所有.商业转载请联系作者获得 ...

  3. centos lnmp一键安装

    安装 系统需求: 需要2 GB硬盘剩余空间 128M以上内存,OpenVZ的建议192MB以上(小内存请勿使用64位系统) Linux下区分大小写,输入命令时请注意! 安装步骤: 1.使用putty或 ...

  4. VS 安装resharper 后 无法进行UnitTest

    Vs安装 Resharper后,无法进行单元测试,发现报错提示信息如下: ignored test-case is missing. rebuild the project and try again ...

  5. 利用Properties属性集结合类加载器读取配置文件

    配置文件test.properties a=123 测试类Demo1.java public class Demo1 { public static void main(String[] args) ...

  6. Java 之 可变字符序列:字符串缓冲区(StringBuilder 与 StringBuffer)

    一.字符串拼接问题 由于 String 类的对象内容不可改变,所以每当进行字符串拼接时,总是会在内存中创建一个新的对象. Demo: public class StringDemo { public ...

  7. Easy2game使用

    每个独享IP服务器,开设3-5个高速接口IP,用户可自行选择当地连接速度快的接口接入服务器,服务器再为用户自动分配所绑定的独享IP连接至游戏服务器,可保证连接的稳定性,统一性 打开软件 添加程序 服务 ...

  8. 在windows 10 64位系统下安装TensorFlow

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/mao_hui_fei/article/de ...

  9. 关于c3p0的重连机制(转载)

    1)C3P0容错和自动重连与以下配置参数有关: breakAfterAcquireFailure :true表示pool向数据库请求连接失败后标记整个pool为block并close,就算后端数据库恢 ...

  10. 李代数E8 的根系 python绘图

    安装前需安装依赖:(针对Centos7) yum install -y cairo pip install cairocffi 源代码:https://github.com/neozhaoliang/ ...