mysql主从之多元复制
实验环境:
192.168.132.121 master1
192.168.132.122 master2
192.168.132.123 slave
使用gtid的方式
两个主分别是192.168.132.121和192.168.132.122,一个从端192.168.132.123分别从两个主端同步数据
192.168.132.121 master1配置
[root@master ~]# cat /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=
datadir=/data/mysql
socket=/data/mysql/mysql.sock
user=mysql
skip-name-resolve
slow_query_log=on
long_query_time=
slow_query_log_file=/data/mysql/mysql-slow.log
innodb-file-per-table=
innodb_flush_log_at_trx_commit =
log_warnings =
connect_timeout =
net_read_timeout =
performance_schema_max_table_instances =
server-id =
gtid_mode=on
enforce_gtid_consistency=on
log-slave-updates=
log-bin=master-bin
log-bin-index = master-bin.index
relay-log = relay-log
relay-log-index = relay-log.index
binlog_format=row
auto_increment_offset=
auto_increment_increment= [mysqld_safe]
log-error=/data/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid
[root@master ~]# mysql -uroot -p123456
mysql> grant replication slave on *.* to 'replication'@'192.168.132.122' identified by '';
mysql> grant replication slave on *.* to 'replication'@'192.168.132.123' identified by '';
192.168.132.122 master2配置
[root@master2 ~]# cat /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=
datadir=/data/mysql
socket=/data/mysql/mysql.sock
user=mysql
skip-name-resolve
slow_query_log=on
long_query_time=
slow_query_log_file=/data/mysql/mysql-slow.log
innodb-file-per-table=
innodb_flush_log_at_trx_commit =
log_warnings =
connect_timeout =
net_read_timeout =
performance_schema_max_table_instances =
server-id =
gtid_mode=on
enforce_gtid_consistency=on
log-slave-updates=
log-bin=master-bin
log-bin-index = master-bin.index
relay-log = relay-log
relay-log-index = relay-log.index
binlog_format=row
auto_increment_offset=
auto_increment_increment= [mysqld_safe]
log-error=/data/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid [root@master2 ~]# mysql -uroot -p123456
mysql> grant replication slave on *.* to 'replication'@'192.168.132.121' identified by '';
mysql> grant replication slave on *.* to 'replication'@'192.168.132.123' identified by '';
192.168.132.123 slave配置
[root@slave ~]# cat /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=
datadir=/data/mysql
socket=/data/mysql/mysql.sock
user=mysql
skip-name-resolve
slow_query_log=on
long_query_time=
slow_query_log_file=/data/mysql/mysql-slow.log
innodb-file-per-table=
innodb_flush_log_at_trx_commit =
log_warnings =
connect_timeout =
net_read_timeout =
performance_schema_max_table_instances =
server-id =
gtid_mode=on
enforce_gtid_consistency=on
log-slave-updates=
log-bin=master-bin
log-bin-index = master-bin.index
relay-log = relay-log
relay-log-index = relay-log.index
binlog_format=row
auto_increment_offset=
auto_increment_increment= [mysqld_safe]
log-error=/data/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid
[root@slave ~]# mysql -uroot -p123456
配置从库
mysql> change master to master_host='192.168.132.121',master_user='replication',master_port=,master_password='',master_auto_position= for channel 'master-1';
ERROR (HY000): To have multiple channels, repository cannot be of type FILE; Please check the repository configuration and convert them to TABLE.
mysql> show variables like '%repository%';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| master_info_repository | FILE |
| relay_log_info_repository | FILE |
+---------------------------+-------+
需要设置convert表
/etc/my.cnf
[mysqld] #添加
master_info_repository=TABLE
relay_log_info_repository=TABLE
[root@slave ~]# systemctl restart mysqld
[root@slave ~]# mysql -uroot -p123456
mysql> show variables like '%repository%';
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| master_info_repository | TABLE |
| relay_log_info_repository | TABLE |
+---------------------------+-------+
mysql> change master to master_host='192.168.132.121',master_user='replication',master_port=,master_password='',master_auto_position= for channel 'master-1';
mysql> change master to master_host='192.168.132.122',master_user='replication',master_port=,master_password='',master_auto_position= for channel 'master-2';
查看从端状态
mysql> start slave;
Query OK, rows affected (0.01 sec) mysql> show slave status\G;
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.132.121
Master_User: replication
Master_Port:
Connect_Retry:
Master_Log_File: master-bin.
Read_Master_Log_Pos:
Relay_Log_File: relay-log-master@002d1.
Relay_Log_Pos:
Relay_Master_Log_File: master-bin.
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: None
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error:
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 63a7f26f-a196-11e9-a2b2-000c2991dd19
Master_Info_File: mysql.slave_master_info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 63a7f26f-a196-11e9-a2b2-000c2991dd19:-
Executed_Gtid_Set: 5ad46c94-a197-11e9--000c29f004c9:,
63a7f26f-a196-11e9-a2b2-000c2991dd19:-,
662134df-a196-11e9-b432-000c2963fd11:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name: master-1 #通道1,连接master1
Master_TLS_Version:
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.132.122
Master_User: replication
Master_Port:
Connect_Retry:
Master_Log_File: master-bin.
Read_Master_Log_Pos:
Relay_Log_File: relay-log-master@002d2.
Relay_Log_Pos:
Relay_Master_Log_File: master-bin.
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:
Last_Error:
Skip_Counter:
Exec_Master_Log_Pos:
Relay_Log_Space:
Until_Condition: None
Until_Log_File:
Until_Log_Pos:
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:
Last_IO_Error:
Last_SQL_Errno:
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:
Master_UUID: 662134df-a196-11e9-b432-000c2963fd11
Master_Info_File: mysql.slave_master_info
SQL_Delay:
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count:
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 662134df-a196-11e9-b432-000c2963fd11:-
Executed_Gtid_Set: 5ad46c94-a197-11e9--000c29f004c9:,
63a7f26f-a196-11e9-a2b2-000c2991dd19:-,
662134df-a196-11e9-b432-000c2963fd11:-
Auto_Position:
Replicate_Rewrite_DB:
Channel_Name: master-2 #通道2,连接master2
Master_TLS_Version:
查看进程
mysql> show processlist;
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+
| | root | localhost | NULL | Query | | starting | show processlist |
| | system user | | NULL | Connect | | Waiting for master to send event | NULL |
| | system user | | NULL | Connect | | Slave has read all relay log; waiting for more updates | NULL |
| | system user | | NULL | Connect | | Waiting for master to send event | NULL |
| | system user | | NULL | Connect | | Slave has read all relay log; waiting for more updates | NULL |
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+
验证
master1
mysql> create database master1;
Query OK, row affected (0.00 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| master1 |
| mysql |
| performance_schema |
| sys |
+--------------------+
master2
mysql> create database master2;
Query OK, row affected (0.00 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| master2 |
| mysql |
| performance_schema |
| sys |
+--------------------+
slave查看 #已经同步
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| master1 |
| master2 |
| mysql |
| performance_schema |
| sys |
+--------------------+
多源复制,配置完成
mysql主从之多元复制的更多相关文章
- 高性能Mysql主从架构的复制原理及配置详解
温习<高性能MySQL>的复制篇. 1 复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台 ...
- Mysql主从同步(复制)
目录: mysql主从同步定义 主从同步机制 配置主从同步 配置主服务器 配置从服务器 使用主从同步来备份 使用mysqldump来备份 备份原始文件 ...
- 转:高性能Mysql主从架构的复制原理及配置详解
温习<高性能MySQL>的复制篇. 1 复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台 ...
- 高性能Mysql主从架构的复制原理及配置详解(转)
温习<高性能MySQL>的复制篇. 1 复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台 ...
- Mysql主从同步(复制)(转)
文章转自:https://www.cnblogs.com/kylinlin/p/5258719.html 目录: mysql主从同步定义 主从同步机制 配置主从同步 配置主服务器 配置从服务器 使用主 ...
- 高性能Mysql主从架构的复制原理及配置
1. 复制概述 1.1 mysql支持的复制类型 1.2 复制解决的问题 1.3 复制如何工作 2. 2 复制配置 2.1创建复制帐号 2.2拷贝数据 2.3配置master 2.4配置slave 2 ...
- MySQL主从双向同步复制
本文介绍了mysql主从,实现mysql的双向同步复制. MySQL支持单向.异步复制,复制过程中一个服务器充当主服务器,而一个或多个其它服务器充当从服务器.主服务器将更新写入二进制日志文件,并维护日 ...
- Mysql学习总结(18)——Mysql主从架构的复制原理及配置详解
一.复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台主机的数据复制到其它主机(slaves)上,并重 ...
- Mysql主从架构的复制
复制类型 (1)基于语句的复制: 在主服务器上执行的SQL语句,在从服务器上执行同样的语句.MySQL默认采用基于语句的复制,效率比较高. 一旦发现没法精确复制时,会自动选着基于行的复制. (2) ...
随机推荐
- 前端基础☞CSS
css的四种引入方式 1.行内式 行内式是在标记的style属性中设定CSS样式.这种方式没有体现出CSS的优势,不推荐使用. <p style="background-color: ...
- 使用Laravel5做权限管理
https://www.imooc.com/article/18250 关于权限管理的思考 最近在用laravel设计后台,后台需要有个权限管理.权限管理实质上分为两个部分,首先是认证,然后是权限.认 ...
- Python基础10 回顾
从最初的"Hello World",走到面向对象,该回过头来看看,教程中是否遗漏了什么. 我们之前提到一句话,"Everything is Object".那么 ...
- mysql数据库之linux版本
http://repo.mysql.com/yum/mysql-5.6-community/ 安装 ...
- selenium webdriver学习(八)------------如何操作select下拉框(转)
selenium webdriver学习(八)------------如何操作select下拉框 博客分类: Selenium-webdriver 下面我们来看一下selenium webdriv ...
- 让 AE 输出 MPEG
最近在做视频后期处理,但是我发现 AE 的文件都很大,大概一个 10 分钟视频 10G ,所以有什么办法让他输出的文件变小?一个方法是使用 MPEG 输出. 本文告诉大家如何让 AE 输出 MPEG ...
- 洛谷 2158 [SDOI2008]仪仗队
Description 作为体育委员,C君负责这次运动会仪仗队的训练.仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线所及的学生人数来判断队伍是 ...
- sublime 插件安装packagecontrol
https://packagecontrol.io/installation 第一步: Installation Simple The simplest method of installation ...
- Windows系统下三十款优秀开源软件
Windows系统下三十款优秀开源软件 1.Firefox 官方网站:http://www.getfirefox.com/ 可替换Internet Explorer 功能特点:如果你还没有使用Fire ...
- element表格多选实现单选
9.element多选表格实现单选 userChoose(selection, row) { console.log(selection,'selection') console.log(row,'r ...