MySQL GTID空库复制搭建
来源:互联网 发布:雅思听力短期提高知乎 编辑:程序博客网 时间:2024/05/18 14:14
MySQL GTID空库复制搭建
环境
1. 主备库开启gtid
2. 备库上停掉之前的传统复制并清空信息
3. 指定主库
4. 备库重新连接
环境
1. 主备库开启gtid
2. 备库上停掉之前的传统复制并清空信息
3. 指定主库
4. 备库重新连接
MySQL GTID空库复制搭建
环境
- 主库:IP:192.168.1.21;版本:5.7.18
- 备库:IP:192.168.1.128;版本:5.6.36
1. 主备库开启gtid
#vim my.cnf
gtid_mode=on
enforce_gtid_consistency=on
#log-slave-updates=ON(5.7不需要添加,会将gtid信息放在mysql.gtid_executed表中)
2. 备库上停掉之前的传统复制并清空信息
root@localhost : (none) 11:56:00> stop slave;
Query OK, 0 rows affected (0.02 sec)
root@localhost : (none) 11:56:33> reset slave all;
Query OK, 0 rows affected (0.08 sec)
3. 指定主库
#复制账号沿用先前的账号repl和密码repl
root@localhost : (none) 01:43:29> change master to master_host='192.168.1.21',master_user='repl',master_password='repl',master_auto_position=1;
Query OK, 0 rows affected, 2 warnings (0.08 sec)
root@localhost : (none) 01:57:13> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.1.21
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: mysql-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File:
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB: sbtest
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: 0
Relay_Log_Space: 151
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: 1593
Last_IO_Error: The slave IO thread stops because the master has @@GLOBAL.GTID_MODE OFF and this server has @@GLOBAL.GTID_MODE ON
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 12001
Master_UUID:
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 the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp: 170523 01:57:13
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 1
1 row in set (0.00 sec)
#报错显示主库没有开启gtid
#查看主库是否开启gtid:
mysql> show variables like 'GTID_MODE%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| gtid_mode | OFF |
+---------------+-------+
1 row in set (0.03 sec)
- 查看主库配置文件发现,主库的gtid_mode=on以及enforce_gtid_consistency=on放在了[mysqld_safe]下,而没有放在[mysqld]下
#修改vim /usr/local/mysql/my.cnf(需要在mysqld下添加,否则会导致不生效)
[mysqld]
gtid_mode=on
enforce_gtid_consistency=on
#重启主库mysql
[root@host-192-168-1-21 mysql]# service mysql stop
Shutting down MySQL.... SUCCESS!
[root@host-192-168-1-21 mysql]# service mysql start
Starting MySQL.. SUCCESS!
mysql> show variables like 'GTID_MODE%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| gtid_mode | ON |
+---------------+-------+
1 row in set (0.01 sec)
4. 备库重新连接
root@localhost : (none) 02:30:41> stop slave;
Query OK, 0 rows affected (0.01 sec)
root@localhost : (none) 02:30:46> start slave;
Query OK, 0 rows affected (0.02 sec)
root@localhost : (none) 02:30:48> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.21
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000031
Read_Master_Log_Pos: 154
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 364
Relay_Master_Log_File: mysql-bin.000031
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: sbtest
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: 154
Relay_Log_Space: 568
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: 12001
Master_UUID: 0a646c88-36e2-11e7-937d-fa163ed7a7b1
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 the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 1
1 row in set (0.00 sec)
阅读全文
0 0
- MySQL GTID空库复制搭建
- MySql基于GTID主从复制的搭建
- mysql gtid模式主从复制搭建
- mysql GTID主从复制
- Mysql GTID主从复制
- mysql gtid复制
- MySQL基于GTID复制
- mysql使用gtid主从复制
- 配置MySQL GTID 主从复制
- Mysql 复制-基于GTID 测试
- 配置MySQL GTID 主从复制
- mysql gtid 复制跳过错误
- 配置MySQL GTID 主从复制
- mysql GTID主从复制 跳过复制错误
- mysql:GTID复制切换成传统复制
- GTID:基于GTID搭建从库
- mysql之 mysql 5.6不停机主从搭建(一主一从基于GTID复制)
- MySQL GTID复制中主从重连如何校验GTID
- 【PSI/SI学习系列】2.PSI/SI深入学习3——SI信息解析2(SDT, EIT, TDT,TOT)——神文004
- Spring学习(三)使用Spring容器创建bean
- 如何安装Qt 5.8.0 +mingw
- JNI笔记(1)认识
- DiscoGAN
- MySQL GTID空库复制搭建
- 利用opencv库识别身份证图片
- 基于mtd的nandflash的擦写nanderase与nandwrite
- 算法提高 盾神与砝码称重
- 图片加载得工具类
- Docker在Linux系统的安装
- 移动应用之UI测试简述
- 安卓通过webview给H5界面实现交互数据
- 进程与线程的一个简单解释