We have One Master and One slave server, we take a daily backup of DB by shell script from slave server using mysqldump
and before taking the backup we stop the salve and once the backup is completed by mysqldump
we start it. Backup process usually takes less then 45-60sec, There was not delay in between Master and Slave. But two days before Slave was not started and showing below error:
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.'
I have further Check and find that the log file and position of Master which slave looking is for is already available in Master. But still somehow slave was unable locate the file/position of GTID. Below are some server status.
SLAVE> show slave status\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: x.x.x.x
Master_User: ABC
Master_Port: xxxx
Connect_Retry: 60
Master_Log_File: mysql-bin.000658
Read_Master_Log_Pos: 91643719
Relay_Log_File: mysql-relay-bin.012744
Relay_Log_Pos: 91643948
Relay_Master_Log_File: mysql-bin.000658
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: 91643719
Relay_Log_Space: 91644258
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: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.'
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: 196f53cf-ee6d-11e5-8d12-0025b510005e
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp: 160919 09:59:17
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 196f53cf-ee6d-11e5-8d12-0025b510005e:1-4:6-132771863
Executed_Gtid_Set: 196f53cf-ee6d-11e5-8d12-0025b510005e:1-4:6-132771863,
792b2bf3-ee77-11e5-a241-0025b510001e:1-25652
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
SLAVE> show master status\G
*************************** 1. row ***************************
File: mysql-bin.000653
Position: 25484325
Binlog_Do_DB: XXXX
Binlog_Ignore_DB:
Executed_Gtid_Set: 196f53cf-ee6d-11e5-8d12-0025b510005e:1-4:6-132771863,
792b2bf3-ee77-11e5-a241-0025b510001e:1-25652
1 row in set (0.00 sec)
SLAVE>
SLAVE> show global variables like 'gtid%';
+----------------------------------+----------------------------------------------------------------------------------------------------+
| Variable_name | Value |
+----------------------------------+----------------------------------------------------------------------------------------------------+
| gtid_executed | 196f53cf-ee6d-11e5-8d12-0025b510005e:1-4:6-132771863,792b2bf3-ee77-11e5-a241-0025b510001e:1-25652 |
| gtid_executed_compression_period | 1000 |
| gtid_mode | ON |
| gtid_owned | |
| gtid_purged | 196f53cf-ee6d-11e5-8d12-0025b510005e:1-4:6-2840195 |
+----------------------------------+----------------------------------------------------------------------------------------------------+
MASTER@XYZ$ ll mysql-bin.00065*
-rw-r----- 1 mysql mysql 104858069 Sep 15 20:49 mysql-bin.000650
-rw-r----- 1 mysql mysql 104860166 Sep 15 21:07 mysql-bin.000651
-rw-r----- 1 mysql mysql 104857943 Sep 15 21:26 mysql-bin.000652
-rw-r----- 1 mysql mysql 104857936 Sep 15 21:48 mysql-bin.000653
-rw-r----- 1 mysql mysql 104858328 Sep 15 22:09 mysql-bin.000654
-rw-r----- 1 mysql mysql 104859955 Sep 15 22:32 mysql-bin.000655
-rw-r----- 1 mysql mysql 104859590 Sep 15 23:00 mysql-bin.000656
-rw-r----- 1 mysql mysql 104857967 Sep 15 23:35 mysql-bin.000657
-rw-r----- 1 mysql mysql 104857960 Sep 16 00:24 mysql-bin.000658
-rw-r----- 1 mysql mysql 104858531 Sep 16 02:43 mysql-bin.000659
MASTER> show global variables like 'gtid%';
+----------------------------------+--------------------------------------------------+
| Variable_name | Value |
+----------------------------------+--------------------------------------------------+
| gtid_executed | 196f53cf-ee6d-11e5-8d12-0025b510005e:1-159910700 |
| gtid_executed_compression_period | 1000 |
| gtid_mode | ON |
| gtid_owned | |
| gtid_purged | 196f53cf-ee6d-11e5-8d12-0025b510005e:1-30477145 |
+----------------------------------+--------------------------------------------------+
5 rows in set (0.00 sec)
MASTER> show master status\G
*************************** 1. row ***************************
File: mysql-bin.000793
Position: 36599639
Binlog_Do_DB: XXXXX
Binlog_Ignore_DB:
Executed_Gtid_Set: 196f53cf-ee6d-11e5-8d12-0025b510005e:1-159911071
1 row in set (0.00 sec)
MASTER>
NOTE : Binary logs will expire after 15 days, and this issue was accrued right after the first 15 days of server startup.
This might be Duplicate, Other provide work around for this issue, but I am looking for permanent solution, if it is available.