当前位置: 首页 > news >正文

mysql8 主从复制一直失败

问题描述:

开启同步后从服务器一直失败,报错如下:

         Last_SQL_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction 'ANONYMOUS' at source log mysql-bin.000004, end_log_pos 47974616. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.
 

这个看不出具体,转到日志文件去看:

2024-12-06T09:32:56.038060Z 5 [System] [MY-014001] [Repl] Replica receiver thread for channel '': connected to source 'slave@172.22.107.84:23306' with server_uuid=614993fb-34f0-11ef-ba87-00163e28fbbf, server_id=100. Starting replication from file 'mysql-bin.000004', position '48380251'.
2024-12-06T09:32:56.038099Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.36'  socket: '/var/lib/mysql/mysql.sock'  port: 23306  MySQL Community Server - GPL.
2024-12-06T09:32:56.254437Z 7 [ERROR] [MY-010584] [Repl] Replica SQL for channel '': Worker 1 failed executing transaction 'ANONYMOUS' at source log mysql-bin.000004, end_log_pos 47974616; Could not execute Update_rows event on table xxl_job.xxl_job_log_report; Can't find record in 'xxl_job_log_report', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's source log mysql-bin.000004, end_log_pos 47974616, Error_code: MY-001032
2024-12-06T09:32:56.254598Z 6 [ERROR] [MY-010586] [Repl] Error running query, replica SQL thread aborted. Fix the problem, and restart the replica SQL thread with "START REPLICA". We stopped at log 'mysql-bin.000004' position 47932536
2024-12-06T09:33:43.605596Z 15 [Warning] [MY-010897] [Repl] Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
2024-12-06T09:33:43.609579Z 15 [System] [MY-014001] [Repl] Replica receiver thread for channel '': connected to source 'slave@172.22.107.84:23306' with server_uuid=614993fb-34f0-11ef-ba87-00163e28fbbf, server_id=100. Starting replication from file 'mysql-bin.000004', position '48564548'.
2024-12-06T09:33:43.676934Z 17 [ERROR] [MY-010584] [Repl] Replica SQL for channel '': Worker 1 failed executing transaction 'ANONYMOUS' at source log mysql-bin.000004, end_log_pos 47974616; Could not execute Update_rows event on table xxl_job.xxl_job_log_report; Can't find record in 'xxl_job_log_report', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's source log mysql-bin.000004, end_log_pos 47974616, Error_code: MY-001032
2024-12-06T09:33:43.677113Z 16 [ERROR] [MY-010586] [Repl] Error running query, replica SQL thread aborted. Fix the problem, and restart the replica SQL thread with "START REPLICA". We stopped at log 'mysql-bin.000004' position 47974288

注意里面的[ERROR]后面,那是具体的问题

etc/my.cnf配置

[root@PROD-VM-88 log]# vi /etc/my.cnf
[root@PROD-VM-88 log]# systemctl restart mysqld
[root@PROD-VM-88 log]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
port=23306server-id=101user=mysql
character-set-server=utf8mb4
collation-server=utf8mb4_general_cidatadir=/data/www/server/mysql
socket=/var/lib/mysql/mysql.socklog-error=/data/www/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid#关闭完整字段限制
sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'lower_case_table_names=1[mysqld]
# 跳过指定的错误码|数据不存在,外健约束
slave-skip-errors=1032,1062,1452

解决办法:

因为master中的一些表是设置了外键约束所以在同步过来时无法执行,还有一些数据在slave上手动删了造成了数据的不一致,所以要把这个都跳过,方法:

[mysqld]
# 跳过指定的错误码|数据不存在,外健约束
slave-skip-errors=1032,1062,1452
 

http://www.lryc.cn/news/500427.html

相关文章:

  • EDA - Spring Boot构建基于事件驱动的消息系统
  • 使用vue-seamless-scroll实现echarts图表大屏滚动,出现空白间隔的解决方案
  • ios使用UIScrollView和PageControl创建图片轮播
  • 3D 生成重建024-LGM第一个开源的3D生成大模型!
  • linux目录权限
  • 语言模型使用心得
  • ChatGPT客户端安装教程(附下载链接)
  • Electron 基础+传值+引用+安全
  • 手机租赁系统全面解析与开发指南
  • mongoDb的读session和写session权限报错问题
  • Centos在2024年6月30日停止维护后如何换yum源安装组件
  • 阿里云ACP云计算模拟试题(附答案解析)
  • 简单的爬虫脚本编写
  • [MySQL基础](三)SQL--图形化界面+DML
  • 11.23[大数据]
  • C++ 游戏开发进阶:打造更精彩的游戏世界
  • 想在iPad上远程操作安卓手机的APP,怎样实现iPad远程控制安卓?
  • GPS北斗卫星授时服务器功能是什么?应用是什么?
  • 利用Java爬虫获取商品数据的完整指南
  • mysql 迁移达梦数据库出现的 sql 语法问题 以及迁移方案
  • 深入解析css-浮动-学习小结
  • 【机器学习】机器学习的基本分类-无监督学习-K-Means聚类
  • .NET for Android/iOS应用的如何在各自的系统运行
  • 访问django后台,提示CSRF验证失败. 请求被中断403
  • Scala的隐式转换(1)
  • 华为TaurusDB与GaussDB:信创改造的“降本提效”之路
  • Linux网络编程---本地套接字
  • 数据结构之四:堆和二叉树
  • 【论文阅读】国际开源发展经验及其对我国开源创新体系建设的启示
  • redis击穿,穿透,雪崩以及解决方案