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. 现在几乎所有的公司项 ...
随机推荐
- 搜索专题:HDU1241 Oil Deposits
Oil Deposits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tot ...
- 【转】MySQL my.cnf 参数 详解
[client] port = 3306 //客户端端口号为3306 socket = /tmp/mysql.sock //套接字文件(sockets),这种文件一般用在网络上的资料套 ...
- Maven clean install 跳过单元测试
1.使用MVN命令 mvn clean install -DskipTests 或者 mvn clean install -Dmaven.test.skip=true 2.Eclipse中设置clea ...
- Quartz.NET | 佳佳的博客
原文:Quartz.NET | 佳佳的博客 Quartz.NET 是一个定时计划任务的框架,支持 .NET Core. 本文示例代码大部分来自于官方教程:Quartz.NET - Quartz.NET ...
- 关于ES6的新特性
1 let声明变量 01 let声明的变量,不可重复声明,比如 let a=1 : let a=2 :这样申明会报错 02 let声明的变量,有块级作用域,比如 if( ){ ...
- VSCode配置 Debugger for Chrome插件
Debugger for Chrome这个插件是直接在vscode里面进行调试js文件,跟谷歌的控制台是一样的功能,下载了它就不用打开浏览器的控制台就能进行打断点. 首先在左侧扩展栏找到这个插件下载好 ...
- vue-cli proxyTable中跨域中pathRewrite 解释
问:proxyTable 里面的pathRewrite里面的‘^/iclient’:'' 什么意思? 答:用代理, 首先你得有一个标识, 告诉他你这个连接要用代理. 不然的话, 可能你的 html ...
- [转载]ISE中COE与MIF文件的联系与区别
原文地址:ISE中COE与MIF文件的联系与区别作者:铁掌北京漂 在ISE中,当用Blcok Memory Generator 生成某个ROM模块时,经常要对ROM中的内容作初始化.这时,就需要我们另 ...
- 计蒜客 蓝桥模拟 A. 结果填空:矩阵求和
给你一个从 n×nn \times nn×n 的矩阵,里面填充 111 到 n×nn \times nn×n .例如当 nnn 等于 333 的时候,填充的矩阵如下. 1 1 2 3 2 4 5 ...
- 1130. Infix Expression (25)
Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with pa ...