• mysql 主从同步恢复处理


    1.问题现象

    主从同步配置几天后,突然有一天不同步了,查看同步情况如下:

    mysql> show slave status\G;
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 10.10.xx.xx
                      Master_User: dt_sync
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000145
              Read_Master_Log_Pos: 22358502
                   Relay_Log_File: relay.000053
                    Relay_Log_Pos: 68192171
            Relay_Master_Log_File: mysql-bin.000018
                 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: 1418
                       Last_Error: Error 'This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)' on query. Default database: 'sx_mom'. Query: 'CREATE DEFINER=`root`@`%` FUNCTION `getAllChild`(id int) RETURNS varchar(2000) CHARSET utf8mb4 COLLATE utf8mb4_bin
    BEGIN   
    DECLARE str varchar(1000);  
    DECLARE cid varchar(10000); 
    DECLARE result varchar(2000); 
    
    set result = '';
    SET str = '';   
    SET cid = id;
    
    WHILE cid is not null DO 
                    SET result = concat(result,',',cid);
                    set str = cid;
                    select group_concat(menu_id) into cid from sys_menu where find_in_set(parent_id,str)>0;  
    END WHILE;   
    RETURN result;   
    END'
                     Skip_Counter: 0
              Exec_Master_Log_Pos: 68191958
                  Relay_Log_Space: 13398132029
                  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: NULL
    Master_SSL_Verify_Server_Cert: No
                    Last_IO_Errno: 0
                    Last_IO_Error: 
                   Last_SQL_Errno: 1418
                   Last_SQL_Error: Error 'This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)' on query. Default database: 'sx_mom'. Query: 'CREATE DEFINER=`root`@`%` FUNCTION `getAllChild`(id int) RETURNS varchar(2000) CHARSET utf8mb4 COLLATE utf8mb4_bin
    BEGIN   
    DECLARE str varchar(1000);  
    DECLARE cid varchar(10000); 
    DECLARE result varchar(2000); 
    
    set result = '';
    SET str = '';   
    SET cid = id;
    
    WHILE cid is not null DO 
                    SET result = concat(result,',',cid);
                    set str = cid;
                    select group_concat(menu_id) into cid from sys_menu where find_in_set(parent_id,str)>0;  
    END WHILE;   
    RETURN result;   
    END'
      Replicate_Ignore_Server_Ids: 
                 Master_Server_Id: 40
                      Master_UUID: 3a077b03-38bb-11ed-9a96-0cda411d1419
                 Master_Info_File: mysql.slave_master_info
                        SQL_Delay: 0
              SQL_Remaining_Delay: NULL
          Slave_SQL_Running_State: 
               Master_Retry_Count: 86400
                      Master_Bind: 
          Last_IO_Error_Timestamp: 
         Last_SQL_Error_Timestamp: 221025 10:10:48
                   Master_SSL_Crl: 
               Master_SSL_Crlpath: 
               Retrieved_Gtid_Set: 3a077b03-38bb-11ed-9a96-0cda411d1419:5-8139191
                Executed_Gtid_Set: 35d26faf-38bb-11ed-9929-0cda411df25c:1-4,
    3a077b03-38bb-11ed-9a96-0cda411d1419:1-818046
                    Auto_Position: 1
             Replicate_Rewrite_DB: 
                     Channel_Name: 
               Master_TLS_Version: 
    1 row in set (0.00 sec)
    
    ERROR: 
    No query specified
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96

    2.处理问题

    mysql> show variables like ' log_bin_trust_function_creators';
    Empty set (0.00 sec)
    
    mysql> show variables like 'log_bin_trust_function_creators';
    +---------------------------------+-------+
    | Variable_name                   | Value |
    +---------------------------------+-------+
    | log_bin_trust_function_creators | OFF   |
    +---------------------------------+-------+
    1 row in set (0.00 sec)
    
    mysql> set global  log_bin_trust_function_creators=1;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> stop slave;
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> start slave;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show slave status\G;
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 172.6.2.1
                      Master_User: slave3
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000423
              Read_Master_Log_Pos: 95536598
                   Relay_Log_File: mysql-relay-bin.001260
                    Relay_Log_Pos: 972250501
            Relay_Master_Log_File: mysql-bin.000422
                 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: 972250338
                  Relay_Log_Space: 1169284268
                  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: 10902
    Master_SSL_Verify_Server_Cert: No
                    Last_IO_Errno: 0
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58

    3.参考

    mysql查看主从同步状态的方法

  • 相关阅读:
    白嫖阿里云服务器,速看!数量不多
    springboot基于Android的洗衣店预约APP毕业设计源码260839
    JAVA线程池1.0
    【Vue】 v-once、ref、provide、inject
    C++&QT day4
    考虑阶梯式碳交易机制与电制氢的综合能源系统热电优化(Matlab代码实现)
    WFP实现侧边栏导航菜单
    MOS晶体管单元电路的最佳二维公共质心布局生成
    Oracle DBlink使用方法
    element 动态渲染form表单,添加验证
  • 原文地址:https://blog.csdn.net/shandian534/article/details/128148341