ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[toc] ## 暴力解决 ### 基于日志点 ~~~ # 停止复制 mysql@slave> stop slave; # 备份后锁主库 mysql@master> flush tables with read lock; # 利用工具或者命令进行master数据备份,并从库数据恢复 # 查看master日志文件与日志点 mysql@master> show master status; +--------------------+----------+--------------+------------------+-------------------------------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +--------------------+----------+--------------+------------------+-------------------------------------------+ | master2-bin.000002 | 21658 | | | 1913a4b9-b43f-11e9-bb4c-0242c0a81003:1-25 | +--------------------+----------+--------------+------------------+-------------------------------------------+ 1 row in set (0.01 sec) # 更新slave日志点 [root@slave] change master to master_host='master.mysql.org', master_user='slave', master_port=3306, master_password='************', master_log_file='master2-bin.000002', master_log_pos=21658; mysql@master> start slave; ~~~ ### 基于GTID #### 方案1:跳过当前事务 ~~~ # slave的my.conf增加以下配置: slave-skip-errors=1032 # 或者all # 重启数据库 /etc/init.d/mysqld restart # 跳过一个事务 mysql@slave>STOP SLAVE; mysql@slave>SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1 mysql@slave>slave start; ~~~ #### 方案2:重置事务 ~~~ mysql@slave> show global variables like '%gtid%' ... # 主库执行到25 gtid_executed: 1913a4b9-b43f-11e9-bb4c-0242c0a81003:1-25 ... # 清除从库的主从信息 mysql@slave> stop slave; mysql@slave> reset slave; mysql@slave> reset master; # 设置gtid_purged mysql@slave> set @@global.gtid_purged='1913a4b9-b43f-11e9-bb4c-0242c0a81003:1-25' # 重新设置主从同步 mysql@slave> change master to master_host='ip地址', master_port=3306, master_user='usernamet', master_password='password', master_auto_position=1; # 启动主从 mysql@slave> start slave # 查看状态 mysql@slave> show slave status; ~~~ ## 解决1045错误 1. 在主上面检查mysql复制账号权限 2. 安装ping检查两个容器之间的ip是否能链接:apt-get update && apt-get install iputils-ping