1、在主库进行一次全备

mysqldump  -uroot -p --single-transaction --master-data=2 --all-databases -R -E  -e -q --triggers    >/home/sa/all_databases_20190523.sql

切记: 不要加--set-gtid-purged=off 参数,不然导入从库后,报 error 1236的错误。

/usr/local/mysql/bin/mysqldump -uroot -p --set-gtid-purged=off -R -E --triggers --single-transaction --hex-blob --skip-opt --add-drop-table --create-options -e -q --set-charset --all-databases >/home/all_databases_20190318.sql

mysqldump -uroot -p --skip-opt --create-options --add-drop-table --set-charset --single-transaction -q -e --triggers -R -E --set-gtid-purged=OFF --hex-blob Tracker114 T1_Doctor XR_DoctorTitle T2_AppointmentOrderForService XR_DutySource XR_Schedule T1_AppointmentOrder DW_Order_ThirdParty DW_Doctor_ThirdParty >/home/sa/Tracker114_20191016_new.sql

在新的服务器上建立主从复制关系:

mysql> change master to master_user='repl', master_host='172.18.16.120',master_password='Repl123#',master_auto_position=1;

ERROR1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log

然后根据提示,查看error log

[root@test.db2.idc2 log]# tail -f mysqld.log

2019-08-27T12:03:49.321764Z 6 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.

2019-08-27T12:03:49.321835Z 6 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.

2019-08-27T12:03:49.321885Z 6 [Warning] 'user' entry 'sysbench@localhost' ignored in --skip-name-resolve mode.

2019-08-27T12:03:49.321953Z 6 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.

2019-08-27T12:03:49.321963Z 6 [Warning] 'db' entry 'sbtest sysbench@localhost' ignored in --skip-name-resolve mode.

2019-08-27T12:03:49.321994Z 6 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.

2019-08-27T12:03:49.322400Z 6 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.

2019-08-27T12:12:13.148834Z 8 [Note] Access denied for user 'root'@'localhost'(using password: YES)2019-08-27T12:15:57.111498Z 9 [Note] Slave: MTS group recovery relay log info based on Worker-Id 1, group_relay_log_name /home/data/mysql57/relay/relay-bin.001715, group_relay_log_pos 247807655 group_master_log_name mysql-bin.000820, group_master_log_pos 247807442

2019-08-27T12:15:57.111528Z 9 [ERROR] Error looking for /home/data/mysql57/relay/relay-bin.001715.

解决方法:在新的从库上,重置relay log日志

mysql> reset slave all;

Query OK, 0 rows affected (0.00 sec)

接着继续,在新的服务器上继续建立主从复制关系:

mysql> change master to master_user='repl', master_host='172.18.16.120',master_password='Repl123#',master_auto_position=1;

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

mysql>start slave;

Query OK,0 rows affected (0.01 sec)

查看从库的复制状态:

mysql>show slave status\G;*************************** 1. row ***************************Slave_IO_State:

Master_Host:172.18.16.120Master_User: repl

Master_Port:3306Connect_Retry:60Master_Log_File:

Read_Master_Log_Pos:4Relay_Log_File: relay-bin.000001Relay_Log_Pos:4Relay_Master_Log_File:

Slave_IO_Running: No

Slave_SQL_Running: Yes

Replicate_Do_DB:

Replicate_Ignore_DB: mysql

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno:0Last_Error:

Skip_Counter:0Exec_Master_Log_Pos:0Relay_Log_Space:154Until_Condition: None

Until_Log_File:

Until_Log_Pos:0Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master:0Master_SSL_Verify_Server_Cert: No

Last_IO_Errno:1236Last_IO_Error: Got fatal error1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.'Last_SQL_Errno:0Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id:120Master_UUID: 0851a6d6-c8af-11e9-a81c-fa163efebf11

Master_Info_File: mysql.slave_master_info

SQL_Delay:0SQL_Remaining_Delay:NULLSlave_SQL_Running_State: Slave hasread all relay log; waiting formore updates

Master_Retry_Count:86400Master_Bind:

Last_IO_Error_Timestamp:190827 20:23:05Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set:

Executed_Gtid_Set: a14948ec-c8b4-11e9-935a-fa163ef7bf86:1-2Auto_Position:1Replicate_Rewrite_DB:

Channel_Name:

查看error log日志

2019-08-27T12:23:05.777385Z 10 [ERROR] Error reading packet from server for channel '': The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires. (server_errno=1236)2019-08-27T12:23:05.777424Z 10 [ERROR] Slave I/O for channel '': Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.', Error_code: 1236

2019-08-27T12:23:05.777431Z 10 [Note] Slave I/O thread exiting for channel '', read up to log 'FIRST', position 4

解决方法:

1、查看主库的master gtid_purged 2、show global variables like '%gtid%'; 找到gtid_purged的值

2、set @@global.gtid_purged='6b156871-8ae7-11e7-88bb-fa163e55e9ea:1-35268634';

mysql dump gtid_mysqldump GTID搭建主从复制库相关推荐

  1. mysql dump gtid_mysqldump导出数据备份 --set-gtid-purged=OFF

    Mysql 数据库 在主从 数据库进行 导出备份和恢复的时候,需要注意是否启用数据库用GTID模式.如果开启,则在mysqldump数据时,应该mysqldump命令加上参数--set-gtid-pu ...

  2. mysql dump gtid_mysqldump命令详解 Part 3- 备份全库

    前面说了MySQL Linux平台和Windows平台的安装 下面开始是MySQL的一些学习笔记 前面我们说了如果构造数据 这节开始说MySQL 的备份 环境为MySQL 5.7.25 在解释命令之前 ...

  3. mysql gtid 搭建主从_MySQL5.7 - 基于GTID复制模式搭建主从复制

    MySQL5.7 - 基于GTID复制模式搭建主从复制 发布时间:2020-04-17 10:09:20 来源:51CTO 阅读:226 作者:insist_way 环境: MySQL5.7.24版本 ...

  4. mysql dump 导出表_误删库,别跑路!教你一招MySQL 数据恢复

    日常工作中,总会有因手抖.写错条件.写错表名.错连生产库造成的误删库表和数据的事情发生.但是,如果每次删库都跑路的话,怕是再也不好找工作了吧!所以,删库跑路不是上上策. 1.前言 数据恢复的前提的做好 ...

  5. MySQL 5.7 基于 GTID 的主从复制实践

    MySQL 5.7 基于 GTID 的主从复制实践 Posted by Mike on 2017-07-03 运维之美 Home About Archives Tags 在 「MySQL 5.7多源复 ...

  6. 阿里云RDS与ECS自建库搭建主从复制

    前言 最近尝试在阿里云RDS与ECS自建库之间搭建主从复制,主要是想用于备份数据,所以对于同步一致性要求不是很高.模拟了几次,遇到的一些坑记录在这里,使用的是基于GTID的主从服务,关于GTID: M ...

  7. mysql gtid 主从_基于GTID搭建主从MySQL

    基于gtid搭建主从MySQL 一.GTID的使用 想让主从之间使用gtid的方式同步数据,需要我们在配置文件中开启mysql对gtid相关的配置信息 找到my.cnf ,在mysqld模块中加入如下 ...

  8. Mysql进阶(1)——异步复制(主从复制、Gtid复制)、半同步复制

    前言 原理总结 异步复制:在主节点写入日志即返回成功,默认情况下MySQL5.5/5.6/5.7和mariaDB10.0/10.1的复制功能是异步的.异步复制可以实现最佳的性能,主库把binlog日志 ...

  9. MySQL搭建主从复制架构实战

    主从复制原理 主库配置文件my.conf 在主库创建同步用户 从库配置文件my.conf 搭建主库 解决docker MySQL容器group by报错问题: vi my.cnf 搭建从库 主从复制模 ...

最新文章

  1. 【NOI2015】荷马史诗
  2. pythoninput函数作用_学习python之input()函数
  3. 论文笔记:Weighted Graph Cuts without Eigenvectors:A Multilevel Approach
  4. 终端如何粘贴快捷键_11 个“原来可以这样”的 Linux 终端命令
  5. 简述div标签和span标签的不同_div与span区别及用法
  6. FreeRTOS空闲任务
  7. GPUImage实现水印
  8. 黑客的克星或叫“白客”
  9. Redis通信协议和集群通信算法
  10. cst和ansys_请教一下cst、ansoft、ansys几种电磁计算软件的异同
  11. 大数据时代最全的医学公共数据库合集整理
  12. react实现九宫格抽奖 - h5
  13. 如何检验数据样本的正态性?
  14. 关于“小于/等于/大于”的英文缩写
  15. flutter 使用 高德地图选取位置
  16. PromptBERT: Improving BERT Sentence Embeddings with Prompts
  17. 为什么html浮动高度不一样,css浮动导致的高度塌陷问题及清楚浮动的方法
  18. CHIPON 芯旺微的KF32A156系列的CAN FD模块的使用介绍
  19. ElasticSearch之——Java操作ES实例(基于ES-2.3.0)
  20. bootstrap 后端模板

热门文章

  1. 文献学习(part11)--基于知识图谱的推荐系统研究综述
  2. 文献学习(part6)--Clustering ensemble based on sample’s stability
  3. python观察日志(part19)--关于iPython中的In[]和Out[]
  4. Django(part4)--练习及re_path方法
  5. 《终身成长》读书笔记(part8)--努力的过程并不只包含努力本身
  6. 关联规则 java_Java实现的关联规则算法
  7. new 实例化对象是啥意思_前端经典面试题解密:JS的new关键字都干了什么?
  8. 吴恩达入驻知乎首答:如何系统学习机器学习?
  9. HTML label标签学习笔记
  10. SAP CRM Genil Text-for-Key-Codes vs SAP C4C只读字段