mysql基于gtid的复制的限制_mysql基于GTID的复制方式

Mysql的复制方法一共有四种:基于sql语句、基于行、混合部署、基于GTIDS

GTIDS的使用环境一般在一主多从下使用

GTIDS的环境:

角色

IP

Master

192.168.200.101

Slave

192.168.200.102

实验步骤:

如果不是新安装的mysql,那么我们需要将主节点上的数据导入从节点,达到数据同步。

修改MySQL的配置文件

[root@master ~]# vim /etc/my.cnf

[mysqld]

gtid_mode=on

enforce_gtid_consistency=on

server_id=1

datadir=/usr/local/mysql/data

socket=/tmp/mysql.sock

#binlog

log-bin=mysql-binlog

log-slave-updates=1

binlog_format=row

#relay log

skip_slave_start=1

登录mysql进行配置

[root@master ~]# mysql -u root -p

mysql> grant replication slave on *.* to ‘myslave‘@‘192.168.200.%‘ identified by ‘123123‘;

Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

3. 修改从节点mysql配置文件

[root@slave ~]# vim /etc/my.cnf

[mysqld]

datadir=/usr/local/mysql/data

socket=/tmp/mysql.sock

server-id = 2

log_bin=on

gtid-mode=on

enforce-gtid-consistency=on

read_only=on

#保证从节点的安全性

master_info_repository=TABLE

relay_log_info_repository=TABLE

登录从节点mysql进行配置

[root@slave ~]# mysql -uroot -p

mysql> stop slave;

Query OK, 0 rows affected (0.01 sec)

mysql> change master to master_host=‘192.168.200.101‘,

-> master_user=‘myslave‘,

-> master_password=‘123123‘,

-> master_auto_position=1;

Query OK, 0 rows affected, 2 warnings (0.04 sec)

mysql> start slave;

Query OK, 0 rows affected (0.01 sec)

mysql>show slave status\G‘;

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.200.101

Master_User: myslave

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-binlog.000001

Read_Master_Log_Pos: 604

Relay_Log_File: slave-relay-bin.000002

Relay_Log_Pos: 823

Relay_Master_Log_File: mysql-binlog.000001

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: 0

Last_Error:

Skip_Counter: 0

Exec_Master_Log_Pos: 604

Relay_Log_Space: 1030

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 0

Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id: 1

Master_UUID: 66e3b98a-5782-11e9-86c5-000c29d506eb

Master_Info_File: mysql.slave_master_info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set: 66e3b98a-5782-11e9-86c5-000c29d506eb:1-2

Executed_Gtid_Set: 66e3b98a-5782-11e9-86c5-000c29d506eb:1-2

Auto_Position: 1

Replicate_Rewrite_DB:

Channel_Name:

Master_TLS_Version:

row in set (0.00 sec)

测试

在主节点上创建数据

mysql> create database test;

Query OK, 1 row affected (0.01 sec)

然后在从节点上查看

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

| test               |

+--------------------+

5 rows in set (0.01 sec)

mysql基于GTID的复制方式

标签:语句   数据同步   padding   repos   cal   hang   0 rows   pos   row

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:https://www.cnblogs.com/JIAlinux/p/10893534.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值