MySQL高可用架构之MySQL5.7组复制MGR
MySQL高可用架构之MySQL5.7组复制MGR
###########################################################################################
规划MGR:
host1.us.oracle.com 10.10.20.95
host2.us.oracle.com 10.10.20.97
host3.us.oracle.com 10.10.20.132
MySQL版本:5.7.21
MySQL实例是33061端口
server-id=330611 330612 330613
###########################################################################################
host1:
MySQL实例是33061端口
mysql> select @@port;
+--------+
| @@port |
+--------+
| 33061 |
+--------+
1 row in set (0.01 sec)
[root@host1 ]#cat /etc/hosts
#FOR TEST MGR
10.10.20.132 host3.us.oracle.com
10.10.20.95 host1.us.oracle.com
10.10.20.97 host2.us.oracle.com
vi /data/mysql_33061/my.cnf
[client]
port = 33061
socket = /data/mysql_33061/run/mysql.sock
[mysqld]
port = 33061
socket = /data/mysql_33061/run/mysql.sock
pid_file = /data/mysql_33061/run/mysql.pid
basedir = /usr/local/mysql
datadir = /data/mysql_33061/data
default_storage_engine = InnoDB
max_allowed_packet = 128M
max_connections = 1024
open_files_limit = 65535 server-id=330611
skip-name-resolve
lower_case_table_names=1 character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4' innodb_buffer_pool_size = 4096M
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_data_home_dir=/data/mysql_33061/data/
innodb_log_group_home_dir=/data/mysql_33061/logs/
innodb_log_files_in_group=3
innodb_log_file_size=512M
innodb_data_file_path=ibdata1:512M:autoextend
log_slave_updates=1
binlog_format=ROW
key_buffer_size = 16M
innodb_log_buffer_size = 32M
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_method = O_DIRECT
innodb_print_all_deadlocks = 1 log-error = /data/mysql_33061/logs/mysql_error.log
log-bin = /data/mysql_33061/logs/mysql_bin
slow_query_log = 1
slow_query_log_file = /data/mysql_33061/logs/mysql_slow_query.log
long_query_time = 2
sync_binlog = 600
relay_log_recovery = 1 tmp_table_size = 64M
max_heap_table_size = 64M #FOR MGR
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = 'ce9be252-2b71-11e6-b8f4-00212889f856' #不能用主机的GTID
loose-group_replication_start_on_boot = off
loose-group_replication_bootstrap_group = off
loose-group_replication_ip_whitelist = '10.10.20.95,10.10.20.132,10.10.20.97'
loose-group_replication_local_address = '10.10.20.95:33066' #写自己主机所在IP,端口自选
loose-group_replication_group_seeds ='10.10.20.95:33066,10.10.20.97:33066,10.10.20.132:33066'#写MGR组内主机所在IP,端口自选
loose-group_replication_single_primary_mode = off #关闭单主模式的参数
loose-group_replication_enforce_update_everywhere_checks = off #开启多主模式的参数
init_slave = 'set sql_mode=STRICT_ALL_TABLES'
#自动启动组复制
#loose-group_replication_start_on_boot = on
#group_replication_allow_local_disjoint_gtids_join = on #FOR GTID
gtid_mode=on
enforce_gtid_consistency=on
binlog_gtid_simple_recovery=1
log_slave_updates=1
binlog_checksum=NONE
master_info_repository=TABLE
relay_log_info_repository=TABLE
my.cnf
mysql>INSTALL PLUGIN group_replication SONAME 'group_replication.so';
mysql> show plugins;
+----------------------------+----------+--------------------+----------------------+---------+
......
| BLACKHOLE | ACTIVE | STORAGE ENGINE | NULL | GPL |
| FEDERATED | DISABLED | STORAGE ENGINE | NULL | GPL |
| ngram | ACTIVE | FTPARSER | NULL | GPL |
| group_replication | ACTIVE | GROUP REPLICATION | group_replication.so | GPL |
+----------------------------+----------+--------------------+----------------------+---------+
45 rows in set (0.00 sec)
mysql>GRANT REPLICATION SLAVE ON *.* TO 'dbsync'@'10.10.%.%' IDENTIFIED BY 'xxxxxxx';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> CHANGE MASTER TO MASTER_USER='dbsync',MASTER_PASSWORD='xxxxxxx' FOR CHANNEL 'group_replication_recovery';
Query OK, 0 rows affected, 2 warnings (0.27 sec)
mysql> set global group_replication_ip_whitelist="10.10.20.95,10.10.20.132,10.10.20.97";
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL group_replication_bootstrap_group=ON;
Query OK, 0 rows affected (0.00 sec)
mysql> set auto_increment_offset=5555;
Query OK, 0 rows affected (0.00 sec)
mysql> START GROUP_REPLICATION;
Query OK, 0 rows affected (2.04 sec)
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
| group_replication_applier | 57bc1e44-a447-11e8-8e78-5254000f067d | host1.us.oracle.com | 33061 | ONLINE |
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
1 row in set (0.00 sec)
###########################################################################################
host2:
[root@host2 ]#cat /etc/hosts
#FOR TEST MGR
10.10.20.132 host3.us.oracle.com
10.10.20.95 host1.us.oracle.com
10.10.20.97 host2.us.oracle.com
vi /data/mysql_33061/my.cnf
[client]
port = 33061
socket = /data/mysql_33061/run/mysql.sock [mysqld]
port = 33061
socket = /data/mysql_33061/run/mysql.sock
pid_file = /data/mysql_33061/run/mysql.pid
basedir = /usr/local/mysql
datadir = /data/mysql_33061/data
default_storage_engine = InnoDB
max_allowed_packet = 128M
max_connections = 1024
open_files_limit = 65535 skip-name-resolve
lower_case_table_names=1 character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4' innodb_buffer_pool_size = 4096M
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_data_home_dir=/data/mysql_33061/data/
innodb_log_group_home_dir=/data/mysql_33061/logs/
innodb_log_files_in_group=3
innodb_log_file_size=512M
innodb_data_file_path=ibdata1:512M:autoextend
log_slave_updates=1
binlog_format=ROW
key_buffer_size = 16M
innodb_log_buffer_size = 32M
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_method = O_DIRECT
innodb_print_all_deadlocks = 1 log-error = /data/mysql_33061/logs/mysql_error.log
log-bin = /data/mysql_33061/logs/mysql_bin.log
slow_query_log = 1
slow_query_log_file = /data/mysql_33061/logs/mysql_slow_query.log
long_query_time = 2
sync_binlog = 600
relay_log_recovery = 1 tmp_table_size = 64M
max_heap_table_size = 64M server-id=330612 #FOR MGR
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = 'ce9be252-2b71-11e6-b8f4-00212889f856' #不能用主机的GTID
loose-group_replication_start_on_boot = off
loose-group_replication_bootstrap_group = off
loose-group_replication_ip_whitelist = '10.10.20.95,10.10.20.132,10.10.20.97'
loose-group_replication_local_address = '10.10.20.97:33066' #写自己主机所在IP,端口自选
loose-group_replication_group_seeds ='10.10.20.95:33066,10.10.20.97:33066,10.10.20.132:33066'#写MGR组内主机所在IP,端口自选
loose-group_replication_single_primary_mode = off #关闭单主模式的参数
loose-group_replication_enforce_update_everywhere_checks = off #开启多主模式的参数
init_slave = 'set sql_mode=STRICT_ALL_TABLES' #FOR GTID
gtid_mode=on
enforce_gtid_consistency=on
binlog_gtid_simple_recovery=1
log_slave_updates=1
binlog_checksum=NONE
master_info_repository=TABLE
relay_log_info_repository=TABLE
my.cnf
mysql>INSTALL PLUGIN group_replication SONAME 'group_replication.so';
mysql> CHANGE MASTER TO MASTER_USER='dbsync',MASTER_PASSWORD='xxxxxxx' FOR CHANNEL 'group_replication_recovery';
Query OK, 0 rows affected, 2 warnings (0.56 sec)
mysql> set global group_replication_ip_whitelist="10.10.20.95,10.10.20.132,10.10.20.97";
Query OK, 0 rows affected (0.00 sec)
mysql> set auto_increment_offset=5555;
Query OK, 0 rows affected (0.00 sec)
mysql> set global group_replication_allow_local_disjoint_gtids_join=ON;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> START GROUP_REPLICATION;
Query OK, 0 rows affected, 1 warning (6.88 sec)
###########################################################################################
host3:
[root@host3 ]#cat /etc/hosts
#FOR TEST MGR
10.10.20.132 host3.us.oracle.com
10.10.20.95 host1.us.oracle.com
10.10.20.97 host2.us.oracle.com
vi /data/mysql_33061/my.cnf
[client]
port = 33061
socket = /data/mysql_33061/run/mysql.sock [mysqld]
port = 33061
socket = /data/mysql_33061/run/mysql.sock
pid_file = /data/mysql_33061/run/mysql.pid
basedir = /usr/local/mysql
datadir = /data/mysql_33061/data
default_storage_engine = InnoDB
max_allowed_packet = 128M
max_connections = 1024
open_files_limit = 65535 skip-name-resolve
lower_case_table_names=1 character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4' innodb_buffer_pool_size = 4096M
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_data_home_dir=/data/mysql_33061/data/
innodb_log_group_home_dir=/data/mysql_33061/logs/
innodb_log_files_in_group=3
innodb_log_file_size=512M
innodb_data_file_path=ibdata1:512M:autoextend
log_slave_updates=1
binlog_format=ROW
key_buffer_size = 16M
innodb_log_buffer_size = 32M
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_method = O_DIRECT
innodb_print_all_deadlocks = 1 log-error = /data/mysql_33061/logs/mysql_error.log
log-bin = /data/mysql_33061/logs/mysql_bin.log
slow_query_log = 1
slow_query_log_file = /data/mysql_33061/logs/mysql_slow_query.log
long_query_time = 2
sync_binlog = 600
relay_log_recovery = 1 tmp_table_size = 64M
max_heap_table_size = 64M server-id=330613 #FOR MGR
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = 'ce9be252-2b71-11e6-b8f4-00212889f856' #不能用主机的GTID
loose-group_replication_start_on_boot = off
loose-group_replication_bootstrap_group = off
loose-group_replication_ip_whitelist = '10.10.20.95,10.10.20.132,10.10.20.97'
loose-group_replication_local_address = '10.10.20.132:33066' #写自己主机所在IP,端口自选
loose-group_replication_group_seeds ='10.10.20.95:33066,10.10.20.97:33066,10.10.20.132:33066'#写MGR组内主机所在IP,端口自选
loose-group_replication_single_primary_mode = off #关闭单主模式的参数
loose-group_replication_enforce_update_everywhere_checks = off #开启多主模式的参数
init_slave = 'set sql_mode=STRICT_ALL_TABLES' #FOR GTID
gtid_mode=on
enforce_gtid_consistency=on
binlog_gtid_simple_recovery=1
log_slave_updates=1
binlog_checksum=NONE
master_info_repository=TABLE
relay_log_info_repository=TABLE
my.cnf
mysql>INSTALL PLUGIN group_replication SONAME 'group_replication.so';
mysql> CHANGE MASTER TO MASTER_USER='dbsync',MASTER_PASSWORD='xxxxxxx' FOR CHANNEL 'group_replication_recovery';
Query OK, 0 rows affected, 2 warnings (0.56 sec)
mysql> set global group_replication_ip_whitelist="10.10.20.95,10.10.20.132,10.10.20.97";
Query OK, 0 rows affected (0.00 sec)
mysql> set auto_increment_offset=5555;
Query OK, 0 rows affected (0.00 sec)
mysql> set global group_replication_allow_local_disjoint_gtids_join=ON;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> START GROUP_REPLICATION;
Query OK, 0 rows affected, 1 warning (3.27 sec)
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
| group_replication_applier | 041eac3b-a40a-11e8-b11f-545200297bd8 | host2.us.oracle.com | 33061 | ONLINE |
| group_replication_applier | 57bc1e44-a447-11e8-8e78-5254000f067d | host1.us.oracle.com | 33061 | ONLINE |
| group_replication_applier | e3d6b2db-a44e-11e8-8769-545200494892 | host3.us.oracle.com | 33061 | ONLINE |
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
3 rows in set (0.00 sec)
host1:
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
| group_replication_applier | 041eac3b-a40a-11e8-b11f-545200297bd8 | host2.us.oracle.com | 33061 | ONLINE |
| group_replication_applier | 57bc1e44-a447-11e8-8e78-5254000f067d | host1.us.oracle.com | 33061 | ONLINE |
| group_replication_applier | e3d6b2db-a44e-11e8-8769-545200494892 | host3.us.oracle.com | 33061 | ONLINE |
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
3 rows in set (0.00 sec)
host2:
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
| group_replication_applier | 041eac3b-a40a-11e8-b11f-545200297bd8 | host2.us.oracle.com | 33061 | ONLINE |
| group_replication_applier | 57bc1e44-a447-11e8-8e78-5254000f067d | host1.us.oracle.com | 33061 | ONLINE |
| group_replication_applier | e3d6b2db-a44e-11e8-8769-545200494892 | host3.us.oracle.com | 33061 | ONLINE |
+---------------------------+--------------------------------------+-----------------------+-------------+--------------+
3 rows in set (0.00 sec)
查询主节点:
select variable_value from performance_schema.global_status where variable_name='group_replication_primary_member';
查看当前实例是否有延迟等性能问题(通过队列深度判断)的方法:
select * from performance_schema.replication_group_member_stats\G;
通过查看COUNT_TRANSACTIONS_IN_QUEUE的值,可以判断等待处理的事务数。
参考:
http://www.cnblogs.com/xinysu/p/6674832.html
https://www.cnblogs.com/manger/p/7211932.html
https://www.cnblogs.com/lemon-le/p/9241984.html
MySQL高可用架构之MySQL5.7组复制MGR的更多相关文章
- MySQL高可用架构之MySQL5.7.19 PXC
CentOS7.3下Percona-XtraDB-Cluster-5.7.19集群部署PXC三节点安装:node1:10.10.10.11 node2:10.10.10.12node3:10.10.1 ...
- mysql高可用架构之MHA,haproxy实现读写分离详解
MySQL高可用架构之MHA 一.运维人员需要掌握的MySQL技术: 1.基本SQL语句 2.基本的管理[库表数据的管理 权限的管理] 3.容灾 保证数据不丢失. 二.工作中MySQ ...
- (转)MySQL高可用架构之MHA
MySQL高可用架构之MHA 原文:http://www.cnblogs.com/gomysql/p/3675429.html 简介: MHA(Master High Availability)目前 ...
- MySQL高可用架构之Mycat-关于Mycat安装和参数设置详解
MySQL高可用架构之Mycat-关于Mycat安装和参数设置详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Mycat介绍 1>.什么是Mycat Mycat背后是 ...
- 032:基于Consul和MGR的MySQL高可用架构
目录 一.Consul 1.Consul简介 2.准备环境 3.Consul 安装 4.Consul配置文件 5.Consul 服务检查脚本 6.Consul启动 二.MGR搭建 1.MGR配置 2. ...
- MySQL 高可用架构在业务层面的应用分析
MySQL 高可用架构在业务层面的应用分析 http://mp.weixin.qq.com/s?__biz=MzAxNjAzMTQyMA==&mid=208312443&idx=1&a ...
- 从mysql高可用架构看高可用架构设计
高可用HA(High Availability)是分布式系统架构设计中必须考虑的因素之一,它通常是指,通过设计减少系统不能提供服务的时间. 假设系统一直能够提供服务,我们说系统的可用性是100%.如果 ...
- MySQL高可用架构应该考虑什么? 你认为应该如何设计?
一.MySQL高可用架构应该考虑什么? 对业务的了解,需要考虑业务对数据库一致性要求的敏感程度,切换过程中是否有事务会丢失 对于基础设施的了解,需要了解基础设施的高可用的架构.例如 单网线,单电源等情 ...
- mysql高可用架构MHA搭建(centos7+mysql5.7.28)
无论是传统行业,还是互联网行业,数据可用性都是至关重要的,虽然现在已经步入大数据时代,nosql比较流行,但是作为数据持久化及事务性的关系型数据库依然是项目首选,比如mysql. 现在几乎所有的公司项 ...
随机推荐
- 逆向工程 生成mapper 接口的 重要方法
@Test public void testSelectByExample() { ItemsExample itemsExample = new ItemsExample(); ItemsExamp ...
- Excel如何通过关键字模糊匹配查找全称
打开excel,以其素材为例,通过关键字模糊匹配查找全称. 在公司名下输入公式:=LOOKUP(1,0/FIND(D2,A2:A5),A2:A5),按回车键确定即可. FIND(D2,A2:A ...
- JDK集合框架源码分析 - 简单概要
1.类继承体系 在集合框架的类继承体系中,最顶层有两个接口Collection.Map: Collection 表示一组纯数据 Map 表示一组key-value对 Collection的类继承体系: ...
- 分布式之redis(转发)
为什么写这篇文章? 博主的<分布式之消息队列复习精讲>得到了大家的好评,内心诚惶诚恐,想着再出一篇关于复习精讲的文章.但是还是要说明一下,复习精讲的文章偏面试准备,真正在开发过程中,还是脚 ...
- AVCaptureSession拍照,摄像,载图总结
AVCaptureSession [IOS开发]拍照,摄像,载图总结 1 建立Session 2 添加 input 3 添加output 4 开始捕捉 5 为用户显示当前录制状态 6 捕捉 7 ...
- json反序列化与pickle的用法
json反序列化与pickle 一.定义 序列化:将内存中的不可持久化和传输对象转换为可方便持久化和传输对象的过程. 反序列化:将可持久化和传输对象转换为不可持久化和传输对象的过程. 二. 应用场景 ...
- python dict字典常用操作
字典的特性:key唯一无序 '''特性:key唯一:无序''' info = { 'stu1101': "安徽", 'stu1102': "北京", 'stu1 ...
- ztree 获取CheckBox选中节点时,不获取选中上级父节点
//将第三个参数改为false,表示不去勾选父节点下的所有子节点 zTreeObj.checkNode(node, true, false); setting.check.chkboxType = { ...
- 3.docker镜像管理基础
一.docker镜像相关 1.About Docker Image Docker镜像含有启动容器所需要的文件系统及其内容,因此,其用于创建并启动docker容器. 采用分层构建机制,最底层为bootf ...
- Linux安装配置varnish web加速器
Linux安装配置varnish web加速器 Varnish是一款高性能的开源HTTP加速器,它可以来做纯粹的代理服务器,负载均衡,但varnish最主要的功能是缓存加速,也是它最出色的 ...