Saturday, June 24, 2023

.::: Trouble Shooting GTID Replication, slave not running :::.

 1. check slave status
MariaDB [teguhth]> select @@hostname,@@version;
+------------+---------------------+
| @@hostname | @@version           |
+------------+---------------------+
| teguhth02  | 10.5.21-MariaDB-log |
+------------+---------------------+
1 row in set (0.000 sec)


or
Last_Errno: 1950
Last_Error: An attempt was made to binlog GTID 1-1-8 which would create an out-of-order sequence number with existing GTID 1-1-8, and gtid strict mode is enabled

MariaDB [teguhth]> SHOW SLAVE STATUS \G
*************************** 1. row ***************************
                Slave_IO_State:
                   Master_Host: 10.10.10.33
                   Master_User: replica
                   Master_Port: 3306
                 Connect_Retry: 60
               Master_Log_File: mysql-bin.000001
           Read_Master_Log_Pos: 328
                Relay_Log_File: teguhth02-relay-bin.000002
                 Relay_Log_Pos: 627
         Relay_Master_Log_File: mysql-bin.000001
              Slave_IO_Running: No
             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: 328
               Relay_Log_Space: 940
               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: 1236
                 Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Error: connecting slave requested to start from GTID 1-1-7, which is not in the master's binlog'
                 Last_Errno: 1950
                 Last_Error: An attempt was made to binlog GTID 1-1-8 which would create an out-of-order sequence number with existing GTID 1-1-8, and gtid strict mode is enabled
                Last_SQL_Errno: 0
                Last_SQL_Error:
   Replicate_Ignore_Server_Ids:
              Master_Server_Id: 1
                Master_SSL_Crl:
            Master_SSL_Crlpath:
                    Using_Gtid: Slave_Pos
                   Gtid_IO_Pos: 1-1-7,0-1-4
       Replicate_Do_Domain_Ids:
   Replicate_Ignore_Domain_Ids:
                 Parallel_Mode: optimistic
                     SQL_Delay: 0
           SQL_Remaining_Delay: NULL
       Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
              Slave_DDL_Groups: 19
Slave_Non_Transactional_Groups: 6
    Slave_Transactional_Groups: 0
1 row in set (0.000 sec)

MariaDB [teguhth]>


2. check from mysql log
[root@teguhth02 ~]# cat /var/lib/mysql/mysql_error.log
Version: '10.5.21-MariaDB-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
2023-06-19 16:05:02 6 [Note] Slave I/O thread: connected to master 'replica@10.10.10.31:3306',replication starts at GTID position '1-1-7'
2023-06-19 16:05:21 8 [Warning] IP address '10.10.10.31' could not be resolved: Name or service not known
2023-06-19 16:05:21 8 [Note] Start semi-sync binlog_dump to slave (server_id: 1), pos(./mysql-bin.000002, 4)
2023-06-19 16:05:23 7 [Note] Error reading relay log event: slave SQL thread was killed
2023-06-19 16:05:23 7 [Note] Slave SQL thread exiting, replication stopped in log 'mysql-bin.000002' at position 328; GTID position '1-1-7'
2023-06-19 16:05:23 7 [Note] master was 10.10.10.31:3306
2023-06-19 16:05:23 6 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.000002', position 328; GTID position 1-1-7
2023-06-19 16:05:23 6 [Note] master was 10.10.10.31:3306
2023-06-19 16:05:52 8 [Note] Stop semi-sync binlog_dump to slave (server_id: 1)
2023-06-19 16:06:13 11 [Note] Slave I/O thread: Start semi-sync replication to master 'replica@10.10.10.31:3306' in log 'mysql-bin.000002' at position 328
2023-06-19 16:06:13 12 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000002' at position 328, relay log './teguhth02-relay-bin.000001' position: 4; GTID position '1-1-7'
2023-06-19 16:06:13 11 [Note] Slave I/O thread: connected to master 'replica@10.10.10.31:3306',replication starts at GTID position '1-1-7'
[root@teguhth02 mysql]#
[root@teguhth02 mysql]#

or other error
2023-06-19 16:05:02 6 [ERROR] mysqld: Error writing file '/var/lib/mysqlbinlogs/mysql-bin' (errno: 1950 "Unknown error 1950")
2023-06-19 16:05:02 6 [ERROR] Slave SQL: An attempt was made to binlog GTID 1-1-8 which would create an out-of-order sequence number with existing GTID 1-1-8, and gtid strict mode is enabled, Gtid 1-1-8, Internal MariaDB error code: 1950
2023-06-19 16:05:02 6 [Warning] Slave: An attempt was made to binlog GTID 1-1-8 which would create an out-of-order sequence number with existing GTID 1-1-8, and gtid strict mode is enabled Error_code: 1950
2023-06-19 16:05:02 6 [Warning] Slave: Error writing file '/var/lib/mysqlbinlogs/mysql-bin' (errno: 1950 "Unknown error 1950") Error_code: 1026
2023-06-19 16:05:02 6 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000002' position 117; GTID position '1-1-7'
2023-06-19 16:05:02 6 [Note] Slave SQL thread exiting, replication stopped in log 'mysql-bin.000002' at position 117; GTID position '1-1-7'
[root@teguhth02 ~]#

3. fix error using  last gtid

select @@hostname,@@version;
stop slave ; reset slave; reset master;
SET GLOBAL gtid_slave_pos = '1-1-7' ;
CHANGE MASTER TO MASTER_HOST='10.10.10.31',MASTER_USER='replica', MASTER_PORT=3306,MASTER_PASSWORD='password', master_use_gtid=slave_pos;
start slave;
show slave status \G;

MariaDB [(none)]> select @@hostname,@@version;
+------------+---------------------+
| @@hostname | @@version           |
+------------+---------------------+
| teguhth02  | 10.5.21-MariaDB-log |
+------------+---------------------+
1 row in set (0.001 sec)

MariaDB [(none)]> stop slave ; reset slave; reset master;
Query OK, 0 rows affected (0.006 sec)

Query OK, 0 rows affected (0.001 sec)

Query OK, 0 rows affected (0.004 sec)

MariaDB [(none)]> SET GLOBAL gtid_slave_pos = '1-1-7' ;
Query OK, 0 rows affected (0.025 sec)

MariaDB [(none)]> CHANGE MASTER TO MASTER_HOST='10.10.10.31',MASTER_USER='replica', MASTER_PASSWORD='password', master_use_gtid=slave_pos;
Query OK, 0 rows affected (0.013 sec)

MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.007 sec)

MariaDB [(none)]>


4. check slave after using last gtid
MariaDB [teguhth]> select @@hostname,@@version;
+------------+---------------------+
| @@hostname | @@version           |
+------------+---------------------+
| teguhth02  | 10.5.21-MariaDB-log |
+------------+---------------------+
1 row in set (0.000 sec)

MariaDB [(none)]> show slave status \G;
*************************** 1. row ***************************
                Slave_IO_State: Waiting for master to send event
                   Master_Host: 10.10.10.31
                   Master_User: replica
                   Master_Port: 3306
                 Connect_Retry: 60
               Master_Log_File: mysql-bin.000002
           Read_Master_Log_Pos: 2102
                Relay_Log_File: teguhth02-relay-bin.000002
                 Relay_Log_Pos: 670
         Relay_Master_Log_File: mysql-bin.000002
              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: 2102
               Relay_Log_Space: 983
               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: 0
 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: 1
                Master_SSL_Crl:
            Master_SSL_Crlpath:
                    Using_Gtid: Slave_Pos
                   Gtid_IO_Pos: 1-1-7
       Replicate_Do_Domain_Ids:
   Replicate_Ignore_Domain_Ids:
                 Parallel_Mode: optimistic
                     SQL_Delay: 0
           SQL_Remaining_Delay: NULL
       Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
              Slave_DDL_Groups: 0
Slave_Non_Transactional_Groups: 0
    Slave_Transactional_Groups: 0
1 row in set (0.001 sec)

ERROR: No query specified

MariaDB [(none)]>


No comments:

Post a Comment

Popular Posts