zoukankan      html  css  js  c++  java
  • 主从复制错误处理总结

    错误一

    ERROR] Slave I/O: error connecting to master 'replication@VMS00782:3306' - retry-time: 60 retries: 2, Error_code: 1045

    错误原因:从库用来连接主库的用户权限或者密码不对

    解决方法:首先在主库上检查用来主从复制的用户权限,如果没有问题在检查从库使用的密码是否正确。

    错误二

    140331 10:08:18 [ERROR] Error reading master configuration
    140331 10:08:18 [ERROR] Failed to initialize the master info structure
    140331 10:08:18 [Note] Event Scheduler: Loaded 0 events

    错误原因:这个可能是从库的master.info文件有损坏。

    解决方法:reset slave

    错误三

    Error 'Duplicate entry '1' for key 1' on query. Default database: 'movivi1'. Query: 'INSERT INTO `v1vid0_user_samename` VALUES(null,1,'123','11','4545','123')'

    错误原因:可能是从库的约束比主库更多写造成的。

    解决方法:

    Mysql > stop slave;
    Mysql > set global sql_slave_skip_counter =1 ;
    Mysql > start slave;

    错误四

    Slave SQL: Error 'Table 'xxxx' doesn't exist' on query. Default database: 't591'. Query: 'INSERT INTO `xxxx`(type,post_id,browsenum) SELECT type,post_id,browsenum FROM xxxx WHERE hitdate='20090209'', Error_code: 1146

    错误原因:slave上缺少错误中的表。

    解决方法:在slave上添加上对应的表,然后start slave。

    错误五

    Error 'Unknown column 'qdir' in 'field list'' on query. Default database: 'club'. Query: 'insert into club.question_del (id, pid, ques_name, givepoint, title, subject, subject_pid, createtime, approve, did, status, intime, order_d, endtime,banzhu_uid,banzhu_uname,del_cause,qdir) select id, pid, ques_name, givepoint, title, subject, subject_pid, createtime, approve, did, status, intime, order_d, endtime,'1521859','admin0523','无意义回复',qdir from club.question where id=7330212'
    1 row in set (0.00 sec)

    错误原因:从库上对应的表上缺少字段。

    解决方法:根据主库上表结构,在从库对应表上添加缺少的字段,然后start slave。

    错误六

    mysql> show slave statusG
    *************************** 1. row ***************************
    Slave_IO_State: Waiting for master to send event
    Master_Host: 192.168.60.159
    Master_User: backup
    Master_Port: 3311
    Connect_Retry: 60
    Master_Log_File: mysql-bin.000012
    Read_Master_Log_Pos: 274863854
    Relay_Log_File: mysql-relay-bin.000007
    Relay_Log_Pos: 2160037
    Relay_Master_Log_File: mysql-bin.000012
    Slave_IO_Running: Yes
    Slave_SQL_Running: No
    Replicate_Do_DB: 
    Replicate_Ignore_DB: 
    Replicate_Do_Table: 
    Replicate_Ignore_Table: 
    Replicate_Wild_Do_Table: 
    Replicate_Wild_Ignore_Table: 
    Last_Errno: 1146
    Last_Error: Error executing row event: 'Table 'panda.t' doesn't exist'
    Skip_Counter: 0
    Exec_Master_Log_Pos: 2159824
    Relay_Log_Space: 274866725

    错误原因:主库删除的表在从库中不存在,导致从库在遇到删除不存在表的错误时无法继续同步。

    解决方法:利用slave-skip-errors参数,跳过对于的1146错误(这个参数是一个只读的,需要在配置文件中修改,并重启从库)

    1、在my.cnf的[mysqld]下面添加slave_skip_errors=1146
    2、重启从库 service mysql restart

    3、在从库上启动同步

    mysql> start slave ;
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> show slave statusG
    *************************** 1. row ***************************
    Slave_IO_State: Waiting for master to send event
    Master_Host: 192.168.60.159
    Master_User: backup
    Master_Port: 3311
    Connect_Retry: 60
    Master_Log_File: mysql-bin.000012
    Read_Master_Log_Pos: 274863854
    Relay_Log_File: mysql-relay-bin.000007
    Relay_Log_Pos: 137439021
    Relay_Master_Log_File: mysql-bin.000012
    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: 137438808
    Relay_Log_Space: 274867275
    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: 88484
    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: 159
    Master_UUID: ded30ff9-62b2-11e6-b0d0-f80f41fa11bf
    Master_Info_File: /usr/local/mysql-5.7.14-linux-glibc2.5-x86_64/data/master.info
    SQL_Delay: 0
    SQL_Remaining_Delay: NULL
    Slave_SQL_Running_State: Reading event from the relay log
    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: 0
    Replicate_Rewrite_DB: 
    Channel_Name: 
    Master_TLS_Version: 
    1 row in set (0.00 sec)

    4、去掉my.cnf中的slave_skip_errors=1146

    5、重启从库

    6、启动从库复制
    ---------------------
    原文:https://blog.csdn.net/gua___gua/article/details/52869614

  • 相关阅读:
    2019年计划书单
    redis 分布式锁实现
    filter-grok,dissect匹配数据
    nohup-长期运行进程
    filter
    kill
    watch
    free
    jar
    tree
  • 原文地址:https://www.cnblogs.com/kcxg/p/11131242.html
Copyright © 2011-2022 走看看