MGR安装
二、环境准备
主机名 | IP地址 | 角色 |
---|---|---|
node2.com | 172.16.8.101 | primary |
node3.com | 172.16.8.53 | seconde |
node3.com | 172.16.8.68 | seconde |
操作系统:CentOS Linux release 7.2.1511
MySQL版本:mysql-5.7.26-linux-glibc2.12-x86_64
MySQL Router版本:mysql-router-8.0.17-linux-glibc2.12-x86_64
MySQL Shell版本:mysql-shell-8.0.17-linux-glibc2.12-x86-64bit
三、MySQL安装
注意: 以下需要在三台机器上分别安装
本次安装为一主两从模式
1. 关闭防火墙
# systemctl stop firewalld
# systemctl disable firewalld
# setenforce 0
# cat /etc/sysconfig/selinux
## 如果上一步查的SELINUX=disabled则下一步用sed替换不用执行
# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# getenforce
2. 软件包上传、解压
# cd /software/
# tar -xvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
# cd /usr/local/
# ln -s mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz mysql
3. 创建mysql数据目录,增加系统用户mysql
# mkdir -p /data/mysql/data/3306
# useradd mysql
# chown -R mysql:mysql /data/mysql/data/3306
# chown -R mysql:mysql /usr/local/mysql*
4. 增加mysql的配置文件
vim /etc/my.cnf
4.1 node2的配置文件内容如下
[mysqld]
basedir=/usr/local/mysql/
datadir=/data/mysql/data/3306
port=3306
socket=/tmp/mysql.sock
server_id=1
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
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= "172.16.8.101:33060"
loose-group_replication_group_seeds= "172.16.8.101:33060,172.16.8.53:33060,172.16.8.68:33060"
loose-group_replication_bootstrap_group=off
4.2 node3的配置文件内容如下
[mysqld]
basedir=/usr/local/mysql/
datadir=/data/mysql/data/3306
port=3306
socket=/tmp/mysql.sock
server_id=2
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
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= "172.16.8.53:33060"
loose-group_replication_group_seeds= "172.16.8.101:33060,172.16.8.53:33060,172.16.8.68:33060"
loose-group_replication_bootstrap_group=off
4.3 node4的配置文件内容如下
[mysqld]
basedir=/usr/local/mysql/
datadir=/data/mysql/data/3306
port=3306
socket=/tmp/mysql.sock
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
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= "172.16.8.68:33060"
loose-group_replication_group_seeds= "172.16.8.101:33060,172.16.8.53:33060,172.16.8.68:33060"
loose-group_replication_bootstrap_group=off
说明: 上面的三个配置文件省略了所有不必要的配置项,但是看起来还是有点多,这些都是mgr环境要求的。
- server_id:每个实例都要不要样
- loose-group_replication_group_name:为mgr高可用组起一个名字,这个名字一定要是uuid格式的。
- loose-group_replication_local_address:mgr各实例之前都是要进行通信的、这个配置项设置的就是本实例所监听的ip:端口
- loose-group_replication_group_seeds:各mgr实例所监听的ip:端口信息
- Group Replication是要根据GTID(Global Transaction Identifiers)来进行同步的,所以需要开启GTID
5. 初始化mysql数据库
# cd /usr/local/mysql/
# ./bin/mysqld --defaults-file=/etc/my.cnf --datadir=/data/mysql/data/3306/ --user=mysql --initialize-insecure
--initialize-insecure:无密码初始化MySQL
6. 配置mysql与systemd结合
说明: CentOS7.x下与服务启动相关的脚本不在是7以下的/etc/init.d/目录的下脚本,而是/usr/lib/systemd/system/目录
配置systemd相关的配置文件/usr/lib/systemd/system/mysql.service
vim /usr/lib/systemd/system/mysql.service
输入如下内容
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
#LimitNOFILE = 5000
#Restart=on-failure
#RestartPreventExitStatus=1
7. 启动MySQL,并把MySQL加入开机启动
# systemctl enable mysql
# systemctl start mysql
8. 配置环境变量
# echo 'PATH=/usr/local/mysql/bin/:$PATH' >>/etc/profile
# source /etc/profile
9. 添加三台机器的DNS解析
# echo "172.16.8.101 node2.com" >> /etc/hosts
# echo "172.16.8.53 node3.com" >> /etc/hosts
# echo "172.16.8.68 node4.com" >> /etc/hosts
10. 测试登录
# mysql -uroot -p
四、MGR配置
4.1配置mgr的第一个节点:
mgr中所有的结点都属于一个逻辑上的组、这个组就像是QQ群一样,是由群主建起来的,有了这个上组之后,其它的结点就可以加入到这个组中来了。onode2.com来建群,以下步骤在node2.com主机上的mysql中执行
4.1.1 创建用于复制的用户
mysql> set sql_log_bin=0;
mysql> create user mgruser@'%' identified by '123456';
mysql> grant replication slave,replication client on *.* to mgruser@'%';
mysql> create user mgruser@'127.0.0.1' identified by '123456';
mysql> grant replication slave,replication client on *.* to mgruser@'127.0.0.1';
mysql> create user mgruser@'localhost' identified by '123456';
mysql> grant replication slave,replication client on *.* to mgruser@'localhost';
mysql> set sql_log_bin=1;
4.1.2 配置复制所使用的用户
mysql> change master to
-> master_user='mgruser',
-> master_password='123456'
-> for channel 'group_replication_recovery';
4.1.3 安装mysql group replication插件
mysql> install plugin group_replication soname 'group_replication.so';
4.1.4 建个群(官方点的说法就是初始化一个复制组)
mysql> set global group_replication_bootstrap_group=on;
mysql> start group_replication;
mysql> set global group_replication_bootstrap_group=off;
说明:
- global group_replication_bootstrap_group=on:代表这个节点是主节点
4.2配置mgr的第二个节点:
第二个结点和第一个结点唯一的不同在于它不在要自己去建一个群了,它只要加入第一个结点建的群就可以了,以下步骤在node3.com主机上的mysql中执行
4.2.1 创建用于复制的用户
mysql> set sql_log_bin=0;
mysql> create user mgruser@'%' identified by '123456';
mysql> grant replication slave,replication client on *.* to mgruser@'%';
mysql> create user mgruser@'127.0.0.1' identified by '123456';
mysql> grant replication slave,replication client on *.* to mgruser@'127.0.0.1';
mysql> create user mgruser@'localhost' identified by '123456';
mysql> grant replication slave,replication client on *.* to mgruser@'localhost';
mysql> set sql_log_bin=1;
4.2.2 配置复制所要的用户
mysql> change master to
-> master_user='mgruser',
-> master_password='123456'
-> for channel 'group_replication_recovery';
4.2.3 安装组复制插件
mysql> install plugin group_replication soname 'group_replication.so';
4.2.4 加入前面创建好的复制组
mysql> start group_replication;
4.3配置mgr的其它结点:
逻辑上第二个结点与第三、第四、第五...等等结点有着一样的逻辑角色,就也是说它们都不是群主,所以它们的配置方式和第二个结点是一样的,所以不在详细列举每一步的配置
MGR安装的更多相关文章
- MySQL高可用之MGR安装测试
Preface We've learned the machenism of MGR yesterday,Let's configurate an environment and have s ...
- MGR安装记录
装好所有MySQL5.7, 打开GTID 修改my.cnf文件: ## group replication transaction_write_set_extraction = XXHASH64 ## ...
- MySQL高可用之MGR安装测试(续)
Preface I've implemented the Group Replication with three servers yesterday,What a shame it ...
- 带你走进MySQL全新高可用解决方案-MGR
一.初识MGR 相信很多人对MGR这个词比较陌生,其实MGR(全称 MySQL Group Replication [MySQL 组复制])是Oracle MySQL于2016年12月发布MySQL ...
- Goldengate 部署oracle10g在 rac asm环境,完整教程
前言 Goldengate再rac 环境部署,和单机部署区别还是有点大,主要存在环境上. 环境 oracle10g ,sid=rac 准备工作 1.在rac节点,配置监听动态注册,确保goldenga ...
- Centos7下设置ceph 12.2.1 (luminous)dashboard UI监控功能
前言 本文所使用的集群是作者在博客 Centos7下部署ceph 12.2.1 (luminous)集群及RBD使用 中所搭建的集群 dashboard是为了完成对集群状态进行UI监控所开发的功能, ...
- MYSQL-MGR架构配置
MGR安装:机器列表:pc-s4 s4 --2pc-s3 s3 --1pc-s1 s1 --1pc-s2 s2 --1 1,为初始化搭建,2,为后续添加 对1 三个数据库先进行初始化========= ...
- 4. 利用MySQL Shell安装部署MGR集群 | 深入浅出MGR
GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 目录 1. 安装准备 2. 利用MySQL Shell构建MGR集群 3. MySQL Shell接管现存的MGR集群 4 ...
- 3. 安装部署MGR集群 | 深入浅出MGR
GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 目录 1. 安装准备 2. 初始化MySQL Server 3. 初始化MGR第一个节点 4. 继续设置另外两个节点 5. ...
随机推荐
- 阿里面试官让我讲讲Unicode,我讲了3秒说没了,面试官说你可真菜
本文首发于微信公众号:程序员乔戈里 乔哥:首先说说什么是Unicode.码点吧~要想搞懂,这些概念必须清楚 什么是Unicode? 下图来自http://www.unicode.org/standar ...
- pyinstaller打包exe文件闪退的解决办法
pyinstaller是python下目前能打包py文件为windows下的exe文件的一个非常友好易用的库!但是,小爬每次用pyinstaller打包时也总是遇到一些难题,有时网上搜了一圈,也没看到 ...
- Linux 学习笔记 5 文件的下载、压缩、解压、初步认识yum
写在前面 上节我们通过简单的几组命令,已经完全的实现了文件的移动.删除.更名.以及复制,我们最常用的基本玩法,本节将带着大家学习压缩.解压的相关步骤. Linux 学习笔记 4 创建.复制.移动.文件 ...
- 「Main」
这里就是我的小主页辣. My Introduction I am Louch. 姓名:楼翰诚 性别:汉纸 生日:2004/03/09(和加加林同一天呢QAQ) 星座:双鱼座 学校:义乌中学 QQ:10 ...
- 谁再问elasticsearch集群Red怎么办?把这篇笔记给他
前言 可能你经历过这些Red. ...等等 那ES的Red是神么意思? 这里说的red,是指es集群的状态,一共有三种,green.red.yellow.具体含义: 冷静分析 从上图可知,集群red是 ...
- python防止字符串转义
部分转自:https://www.cnblogs.com/hellofengying/p/10183057.html 今天再打开文件名时,出现了错误,如下: In []: path='D:\Code\ ...
- Could not find a version that satisfies the requirement numpy>=1.7.0 (from pan das==0.17.0) (from versions: ) No matching distribution found for numpy>=1.7.0 (from pandas==0.17.0)
今天晚上一直在安装pandas,天杀的,真的是太难了.后来发现提示: Could not find a version that satisfies the requirement numpy> ...
- Map and HashMap
1.1.1. Map 接口 java提供了一组可以以键值对(key-value)的形式存储数据的数据结构,这种数据结构称为Map.我们可以把Map看成一个多行两列的表格,其中第一列存放key,第二列存 ...
- 《C++Primer》第五版习题答案--第一章【学习笔记】
C++Primer第五版习题解答---第一章 ps:答案是个人在学习过程中书写,可能存在错漏之处,仅作参考. 作者:cosefy Date: 2022/1/7 第一章:开始 练习1.3 #includ ...
- mqtt实现跨平台跨应用通讯
介绍 最近物联网应用一直很火,也打算做一些这方面的尝试,就边学边做在家花了2天时间做了一个简单demo,功能很简单,使用emq x 作为mqtt broker,用python写了一个定时抓取主机CPU ...