MySQL replication fails when it replicate from a slave database server - mysql

I have a master MySQL server A with the bin log file bin.000008. And a slave server B with its bin log file bin.000012.
The replication from A to B works well.
Every time I changes the data to server A, the server B will replicate it correctly.
There's a new MySQL server C. I make it to be as a slave to server B.
The problem is:
When I modify the data on server A, server B replicates it correctly. But server C does not be changed. Which means that the replication is invalid from server B to server C.
I tried to restart the slave on server C. And it says 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.'
Here are the master and slave status of each server:
Server C (slave of Server B):
db> show slave status\G;
|[
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: luexu.com
Master_User: Aario
Master_Port: 1579
Connect_Retry: 60
Master_Log_File: bin.000012
Read_Master_Log_Pos: 194
Relay_Log_File: cf3613332a61-relay-bin.000004
Relay_Log_Pos: 355
Relay_Master_Log_File: bin.000012
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql,information_schema,performance_schema,sys
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: 194
Relay_Log_Space: 569
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: 65535
Master_UUID: dd7aa123-ca18-11e7-9411-0242ac110005
Master_Info_File: /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:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: c389aee6-ca16-11e7-81e3-0242ac110004:1-79,
dd7aa123-ca18-11e7-9411-0242ac110005:1-13
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
]|
Server B (slave of Server A, master of Server C):
db> show variables like '%slave%';
+------------------------------+-----------------------+
| Variable_name | Value |
+------------------------------+-----------------------+
| init_slave | |
| log_slave_updates | ON |
| log_slow_slave_statements | OFF |
| pseudo_slave_mode | OFF |
| rpl_stop_slave_timeout | 31536000 |
| slave_allow_batching | OFF |
| slave_checkpoint_group | 512 |
| slave_checkpoint_period | 300 |
| slave_compressed_protocol | OFF |
| slave_exec_mode | STRICT |
| slave_load_tmpdir | /tmp |
| slave_max_allowed_packet | 1073741824 |
| slave_net_timeout | 60 |
| slave_parallel_type | DATABASE |
| slave_parallel_workers | 0 |
| slave_pending_jobs_size_max | 16777216 |
| slave_preserve_commit_order | OFF |
| slave_rows_search_algorithms | TABLE_SCAN,INDEX_SCAN |
| slave_skip_errors | OFF |
| slave_sql_verify_checksum | ON |
| slave_transaction_retries | 10 |
| slave_type_conversions | |
| sql_slave_skip_counter | 0 |
+------------------------------+-----------------------+
db> show master status\G;
|[
*************************** 1. row ***************************
File: bin.000012
Position: 194
Binlog_Do_DB:
Binlog_Ignore_DB: mysql,sys,information_schema,performance_schema
Executed_Gtid_Set: c389aee6-ca16-11e7-81e3-0242ac110004:1-81,
dd7aa123-ca18-11e7-9411-0242ac110005:1-13
1 row in set (0.00 sec)
]|
db> show slave status\G;
|[
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: luexu.com
Master_User: Aario
Master_Port: 5961
Connect_Retry: 60
Master_Log_File: bin.000008
Read_Master_Log_Pos: 27885
Relay_Log_File: 217fcc5843c2-relay-bin.000005
Relay_Log_Pos: 27684
Relay_Master_Log_File: bin.000008
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql,sys,information_schema,performance_schema
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: 27885
Relay_Log_Space: 27938
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_UUID: c389aee6-ca16-11e7-81e3-0242ac110004
Master_Info_File: /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:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: c389aee6-ca16-11e7-81e3-0242ac110004:48-81
Executed_Gtid_Set: c389aee6-ca16-11e7-81e3-0242ac110004:1-81,
dd7aa123-ca18-11e7-9411-0242ac110005:1-13
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
]|
Server A (master of Server B):
db> show master status\G;
|[
*************************** 1. row ***************************
File: bin.000008
Position: 27885
Binlog_Do_DB:
Binlog_Ignore_DB: mysql,sys,information_schema,performance_schema
Executed_Gtid_Set: c389aee6-ca16-11e7-81e3-0242ac110004:1-81
1 row in set (0.00 sec)
]|
Restart the slave on Server C:
db> stop slave;
db> start slave;
db> show slave status\G;
|[
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: luexu.com
Master_User: Aario
Master_Port: 3306
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: cf3613332a61-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File:
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql,information_schema,performance_schema,sys
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: 0
Relay_Log_Space: 308
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: 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: 65535
Master_UUID: dd7aa123-ca18-11e7-9411-0242ac110005
Master_Info_File: /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: 171210 04:01:51
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: 074c1f93-dd08-11e7-b173-0242ac110004:1-3
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
]|

I am not sure about your problem therefore just some thoughts - maybe you will find some inspiration in them:
Do you have some really important reason for setting chain replication A->B->C? If not avoid this complexity and just make C replica of A (you can do it by simple cloning of already working B replica - see here: http://mysql.freeideas.cz/subdom/mysql/2017/08/14/create-new-replica-by-copying-data-and-log-files-on-os-level/
If you really must chain your replication then it generally works OK, we use it for making bigger changes in architecture without downtimes for a long time already and it works even between different MySQL versions.
We used it for the first time when we needed to move from one cloud provider to another - we used (A) old master on old cloud -> (B) new intended master on new cloud -> (C) replicas on new cloud for apps. And currently we set it for new app development with new version of MySQL - (A) old 5.5 Master -> (B) 5.7 replica/master -> (C) 5.7 replicas for app.
You just need to set "log_slave_updates=ON" on "master replica" and create your C replica(s) the same way from B as you created B from A - see general notes here: http://mysql.freeideas.cz/subdom/mysql/2016/11/10/how-to-manually-set-mysql-replication/
Meaning - you have to make dump for C on your B with replication stopped and tables locked against changes and note master status of B and use it to set C. Of course - you have to ensure bin logs on B will live "long enough" - set "expire_logs_days" on B to several days (of course you have to have enough disk space for it). All these changes in setting require restart.

Related

Why GTID on Master is different from GTID on Slave while both are synced (MariaDB 10.5)?

I have noticed that the Gtid_IO_Pos value is 0-1-557278 and gtid_current_pos on Master is 0-1-557279.
On Slave:
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.32.0.22
Master_User: maxscale
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: ON.000052
Read_Master_Log_Pos: 949077
Relay_Log_File: db-backup-relay-bin.000002
Relay_Log_Pos: 31221
Relay_Master_Log_File: ON.000052
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: 949077
Relay_Log_Space: 31534
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: 0-1-557278
Replicate_Do_Domain_Ids:
Replicate_Ignore_Domain_Ids:
Parallel_Mode: conservative
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Slave_DDL_Groups: 0
Slave_Non_Transactional_Groups: 0
Slave_Transactional_Groups: 1415
1 row in set (0.001 sec)
MariaDB [(none)]>
On Master:
MariaDB [(none)]> show variables like '%pos%';
+-----------------------+---------------------------------------------+
| Variable_name | Value |
+-----------------------+---------------------------------------------+
| gtid_binlog_pos | 0-1-557279 |
| gtid_current_pos | 0-1-557279 |
| gtid_pos_auto_engines | |
| gtid_slave_pos | |
| wsrep_start_position | 7d28ce25-9a5a-11ea-9040-42d6a88cb619:721703 |
+-----------------------+---------------------------------------------+
5 rows in set (0.003 sec)
MariaDB [(none)]>
I checked the binlogs, events order is correct but the content
On Slave:
*************************** 7924. row ***************************
Log_name: ON.000005
Pos: 822231
Event_type: Gtid
Server_id: 1
End_log_pos: 822273
Info: BEGIN GTID 0-1-557278
*************************** 7925. row ***************************
Log_name: ON.000005
Pos: 822273
Event_type: Annotate_rows
Server_id: 1
End_log_pos: 822471
Info: INSERT INTO `ci_sessions` (`id`, `ip_address`, `timestamp`, `data`) VALUES ('s95eu66r81b64gg9glcf7495141kj5hs', '10.32.0.52', 1621415267, '__ci_last_regenerate|i:1621415267;')
*************************** 7926. row ***************************
Log_name: ON.000005
Pos: 822471
Event_type: Table_map
Server_id: 1
End_log_pos: 822544
Info: table_id: 602 (prod_db.ci_sessions)
*************************** 7927. row ***************************
Log_name: ON.000005
Pos: 822544
Event_type: Write_rows_v1
Server_id: 1
End_log_pos: 822663
Info: table_id: 602 flags: STMT_END_F
*************************** 7928. row ***************************
Log_name: ON.000005
Pos: 822663
Event_type: Xid
Server_id: 1
End_log_pos: 822694
Info: COMMIT /* xid=6071 */
On Master:
*************************** 9169. row ***************************
Log_name: ON.000052
Pos: 945936
Event_type: Gtid
Server_id: 1
End_log_pos: 945978
Info: BEGIN GTID 0-1-557279
*************************** 9170. row ***************************
Log_name: ON.000052
Pos: 945978
Event_type: Annotate_rows
Server_id: 1
End_log_pos: 946176
Info: INSERT INTO `ci_sessions` (`id`, `ip_address`, `timestamp`, `data`) VALUES ('s95eu66r81b64gg9glcf7495141kj5hs', '10.32.0.52', 1621415267, '__ci_last_regenerate|i:1621415267;')
*************************** 9171. row ***************************
Log_name: ON.000052
Pos: 946176
Event_type: Table_map
Server_id: 1
End_log_pos: 946249
Info: table_id: 21 (prod_db.ci_sessions)
*************************** 9172. row ***************************
Log_name: ON.000052
Pos: 946249
Event_type: Write_rows_v1
Server_id: 1
End_log_pos: 946368
Info: table_id: 21 flags: STMT_END_F
*************************** 9173. row ***************************
Log_name: ON.000052
Pos: 946368
Event_type: Xid
Server_id: 1
End_log_pos: 946399
Info: COMMIT /* xid=723331 */
I suspect this might confuse CHANGE MASTER TO statement.
I'd like to know if this is normal, if it's normal, how this GTID difference doesn't affect replication?

MariaDB 10.3 Replication doesn't work -> Exec_Master_Log_Pos does not change

I configured a replication cluster with MariaDB 10.3. I can connect from my slave to my master and all write statements from my master is automatically copied to my relay-bin files on my slaves. But then the queries in my relay bin file are not executed on my databases. Furthermore the Exec_Master_Log_Pos does not change meanwhile the Read_Master_Log_Pos does.
I cannot stop the slave because if i do the process hangs and i have to kill it. the Seconds Behind Master grows...
here are my show slave status on my slave server:
MariaDB [(none)]> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: mymaster.test.net
Master_User: repadmin
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 498
Relay_Log_File: slave-relay-bin.000002
Relay_Log_Pos: 555
Relay_Master_Log_File: mysql-bin.000001
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: 328
Relay_Log_Space: 1038
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: 52
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: No
Gtid_IO_Pos:
Replicate_Do_Domain_Ids:
Replicate_Ignore_Domain_Ids:
Parallel_Mode: conservative
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Update
Slave_DDL_Groups: 0
Slave_Non_Transactional_Groups: 0
Slave_Transactional_Groups: 1
1 row in set (0.000 sec)
show processlist:
10 | system user | | NULL | Slave_IO | 1766 | Waiting for master to send event | NULL | 0.000 |
| 11 | system user | | testdb | Slave_SQL | 183 | Update | insert into test values (10) | 0.000 |
It seems that the update process always hangs.
As i said before the queries are copied to my slaves relays-logs but not executed on my database.

mysql slave stuck at Reading event from the relay log all the time

two days ago,i imported data through "source xxx.sql" on the master,it has 1.35million row records,the total size is 10G,the master anything is good after i executed import operate. but that it was finished on the master has passed two days,the state of slave still is "Reading event from the relay log",who can help me to resolve the problem?thanks in advance.
Below are a detail about slave status:
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.50
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.001137
Read_Master_Log_Pos: 43132410
Relay_Log_File: mysql-relay-bin.002897
Relay_Log_Pos: 497809898
Relay_Master_Log_File: mysql-bin.001130
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: 497809685
Relay_Log_Space: 40113924576
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: 161225
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_UUID: 0f9e9ec5-ed9f-11e5-9a4a-525400c50c20
Master_Info_File: /data/mysql1/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)
Below are relay logs list on the salve:
-rw-r----- 1 mysql mysql 254 Oct 15 11:17 mysql-relay-bin.002896
-rw-r----- 1 mysql mysql 19G Oct 15 11:40 mysql-relay-bin.002897
-rw-r----- 1 mysql mysql 161K Oct 15 11:40 mysql-relay-bin.002898
-rw-r----- 1 mysql mysql 254 Oct 15 11:40 mysql-relay-bin.002899
-rw-r----- 1 mysql mysql 67M Oct 15 12:10 mysql-relay-bin.002900
-rw-r----- 1 mysql mysql 18G Oct 15 12:14 mysql-relay-bin.002901
-rw-r----- 1 mysql mysql 112K Oct 15 12:14 mysql-relay-bin.002902
-rw-r----- 1 mysql mysql 254 Oct 15 12:14 mysql-relay-bin.002903
-rw-r----- 1 mysql mysql 420 Oct 15 12:14 mysql-relay-bin.002904
-rw-r----- 1 mysql mysql 4.4M Oct 15 12:14 mysql-relay-bin.002905
-rw-r----- 1 mysql mysql 254 Oct 15 12:14 mysql-relay-bin.002906
-rw-r----- 1 mysql mysql 420 Oct 15 12:14 mysql-relay-bin.002907
-rw-r----- 1 mysql mysql 254 Oct 15 12:14 mysql-relay-bin.002908
-rw-r----- 1 mysql mysql 122M Oct 15 14:34 mysql-relay-bin.002909
-rw-r----- 1 mysql mysql 207 Oct 15 14:34 mysql-relay-bin.002910
-rw-r----- 1 mysql mysql 7.9M Oct 15 15:27 mysql-relay-bin.002911
-rw-r----- 1 mysql mysql 207 Oct 15 15:27 mysql-relay-bin.002912
-rw-r----- 1 mysql mysql 371K Oct 15 15:34 mysql-relay-bin.002913
-rw-r----- 1 mysql mysql 207 Oct 15 15:34 mysql-relay-bin.002914
-rw-r----- 1 mysql mysql 76M Oct 15 23:00 mysql-relay-bin.002915
-rw-r----- 1 mysql mysql 5.3M Oct 15 23:59 mysql-relay-bin.002916
-rw-r----- 1 mysql mysql 254 Oct 15 23:59 mysql-relay-bin.002917
-rw-r----- 1 mysql mysql 36M Oct 16 08:05 mysql-relay-bin.002918
-rw-r----- 1 mysql mysql 4.4M Oct 16 08:22 mysql-relay-bin.002919
-rw-r----- 1 mysql mysql 979M Oct 16 23:00 mysql-relay-bin.002920
-rw-r----- 1 mysql mysql 5.5M Oct 16 23:58 mysql-relay-bin.002921
-rw-r----- 1 mysql mysql 254 Oct 16 23:58 mysql-relay-bin.002922
-rw-r----- 1 mysql mysql 38M Oct 17 08:02 mysql-relay-bin.002923
-rw-r----- 1 mysql mysql 6.6M Oct 17 08:53 mysql-relay-bin.002924
-rw-r----- 1 mysql mysql 725 Oct 17 08:02 mysql-relay-bin.index
See the Seconds_Behind_Master: 161225
line in slave status output, for now the delay is 44 hours.
Run show slave status few times and make a suggestion on the rate it changes, if everything is OK it should be decreasing constantly.
To speed up the slave you can decrease a load on the server: stop querying it for a while and stop any other activity that takes place on the server.
However you may find reasonable to resetup slave from fresh dump from master, xtrabackup from percona can do it with no locks to DB (unless you use MyISAM a lot, as it suites best for innodb engine).

MariaDB Master-Slave replication don't work without error

I have two MariaDB 10.1.16 server on two different host.
I setup a Master-Slave replica and there aren't errors:
SLAVE:
MariaDB [(none)]> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: host02
Master_User: slave
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: host02-bin.000012
Read_Master_Log_Pos: 3814
Relay_Log_File: host03-relay-bin.000027
Relay_Log_Pos: 3188
Relay_Master_Log_File: host02-bin.000012
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: db1,db2,db3,db4,db5,db1,db2,db3,db4,db5
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: 3814
Relay_Log_Space: 3491
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: No
Gtid_IO_Pos:
Replicate_Do_Domain_Ids:
Replicate_Ignore_Domain_Ids:
Parallel_Mode: conservative
MASTER:
MariaDB [(none)]> SHOW MASTER STATUS;
+-----------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-----------------------+----------+--------------+------------------+ | host03-bin.000012 | 3814 | | |
+-----------------------+----------+--------------+------------------+
No errors or warning on Alert log.
master my.cnf:
[mysqld]
server_id=1
relay-log=host02-relay-bin
log-bin=host02-bin
slave my.cnf:
[mysqld]
log-bin
server_id=2
replicate-do-db="db1,db2,db3,db4,db5"
relay-log=host03-relay-bin
log-bin=host03-bin
The problem is there isn't errors but changes made in MASTER (ex. INSERT) doesn't replicate on SLAVE.
Maybe Replicate_Do_DB problem?
You probably do not have a database called db1,db2,db3,db4,db5.
Instead, have 5 replicate-do-db lines in the slave's my.cnf.
Also, be sure not to do this:
USE db88;
INSERT INTO db1.tbl ...
The db88 will be used instead of db1, and the insert will be ignored.

MySQL Cluster error: 1005: Can't create table 'ndb_schema' (errno: 13)

I'm having troubles with my MySQL Cluster Test-setup:
I have two machines running Ubuntu and Docker (using a multi-host network) and each node (ndb_mgm, ndbd and mysqld) runs via Docker. The setup is as follows:
Machine 1:
ndb_mgmd
ndbd1
mysqld1
Machine 2:
ndbd2
mysqld2
When I start the mysqld on one machine, it connects to the manager and wants to initiate the cluster, but its unable to create the table, The whole NDB log on a mysqld instance after a fresh start:
2016-08-02 09:08:57 135 [Note] NDB: Changed global value of binlog_format from STATEMENT to MIXED
2016-08-02 09:08:58 135 [Note] NDB: NodeID is 4, management server 'ndb_mgmd:1186'
2016-08-02 09:08:58 135 [Note] NDB[0]: NodeID: 4, all storage nodes connected
2016-08-02 09:08:58 135 [Warning] NDB: server id set to zero - changes logged to bin log with server id zero will be logged with another server id by slave mysqlds
2016-08-02 09:08:58 135 [Note] NDB Binlog: Starting...
2016-08-02 09:08:58 135 [Note] NDB Binlog: Started
2016-08-02 09:08:58 135 [Note] NDB Binlog: Setting up
2016-08-02 09:08:58 135 [Note] NDB Binlog: Created schema Ndb object, reference: 0x80040004, name: 'Ndb Binlog schema change monitoring'
2016-08-02 09:08:58 135 [Note] NDB Binlog: Created injector Ndb object, reference: 0x80050004, name: 'Ndb Binlog data change monitoring'
2016-08-02 09:08:58 135 [Note] NDB Binlog: Setup completed
2016-08-02 09:08:58 135 [Note] NDB Binlog: Wait for server start completed
2016-08-02 09:08:58 135 [Note] NDB Util: Starting...
2016-08-02 09:08:58 135 [Note] NDB Util: Wait for server start completed
2016-08-02 09:08:58 135 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: bf07c00a-5890-11e6-83a3-02420a000a1e.
2016-08-02 09:08:58 135 [Note] NDB Index Stat: Starting...
2016-08-02 09:08:58 135 [Note] NDB Index Stat: Wait for server start completed
2016-08-02 09:08:58 135 [Note] Server hostname (bind-address): '*'; port: 3306
2016-08-02 09:08:58 135 [Note] IPv6 is available.
2016-08-02 09:08:58 135 [Note] - '::' resolves to '::';
2016-08-02 09:08:58 135 [Note] Server socket created on IP: '::'.
2016-08-02 09:08:58 135 [Note] Event Scheduler: Loaded 0 events
2016-08-02 09:08:58 135 [Note] /usr/local/mysql-cluster-gpl-7.4.12-linux-glibc2.5-x86_64/bin/mysqld: ready for connections.
Version: '5.6.31-ndb-7.4.12-cluster-gpl' socket: '/tmp/mysql.sock' port: 3306 MySQL Cluster Community Server (GPL)
2016-08-02 09:08:58 135 [Note] NDB Util: Wait for cluster to start
2016-08-02 09:08:58 135 [Note] NDB Util: Started
2016-08-02 09:08:58 135 [Note] NDB Binlog: Check for incidents
2016-08-02 09:08:58 135 [Note] NDB Binlog: Wait for cluster to start
2016-08-02 09:08:58 135 [Note] NDB Index Stat: Wait for cluster to start
2016-08-02 09:08:58 135 [Note] NDB Index Stat: Started
2016-08-02 09:08:58 135 [Note] created index stats Ndb object: reference 0x80070004, name: 'Ndb Index Statistics monitoring'
2016-08-02 09:08:58 135 [Note] NDB: Creating mysql.ndb_schema
2016-08-02 09:08:58 135 [ERROR] NDB: Query 'CREATE TABLE IF NOT EXISTS mysql.ndb_schema ( db VARBINARY(63) NOT NULL,name VARBINARY(63) NOT NULL,slock BINARY(32) NOT NULL,query BLOB NOT NULL,node_id INT UNSIGNED NOT NULL,epoch BIGINT UNSIGNED NOT NULL,id INT UNSIGNED NOT NULL,version INT UNSIGNED NOT NULL,type INT UNSIGNED NOT NULL,PRIMARY KEY USING HASH (db,name) ) ENGINE=NDB CHARACTER SET latin1' failed, error: 1005: Can't create table 'ndb_schema' (errno: 13)
The last line shows, that its unable to create a table:
NDB: Query 'CREATE TABLE ...' failed, error: 1005: Can't create table 'ndb_schema' (errno: 13)
If i checkout the ndb_mgm configuration, every node seem connected correctly:
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 #10.0.10.20 (mysql-5.6.31 ndb-7.4.12, Nodegroup: 0, *)
id=3 #10.0.10.21 (mysql-5.6.31 ndb-7.4.12, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 #10.0.10.10 (mysql-5.6.31 ndb-7.4.12)
[mysqld(API)] 2 node(s)
id=4 #10.0.10.30 (mysql-5.6.31 ndb-7.4.12)
id=5 #10.0.10.31 (mysql-5.6.31 ndb-7.4.12)
The configuration for ndb_mgmd:
[ndbd default]
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M
[ndb_mgmd]
hostname=10.0.10.10
datadir=/var/lib/mysql-cluster
[ndbd]
hostname=10.0.10.20
datadir=/usr/local/mysql/data
[ndbd]
hostname=10.0.10.21
datadir=/usr/local/mysql/data
[mysqld]
hostname=10.0.10.30
[mysqld]
hostname=10.0.10.31
Each mysqld is configured as followed:
[mysqld]
ndbcluster
log-error=/var/log/mysql/error.log
Running the status of the cluster on a mysqld instance shows no errors:
mysql> SHOW ENGINE NDB STATUS
-> ;
+------------+-----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
| Type | Name | Status |
+------------+-----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
| ndbcluster | connection | cluster_node_id=4, connected_host=ndb_mgmd, connected_port=1186, number_of_data_nodes=2, number_of_ready_data_nodes=2, connect_count=0 |
| ndbcluster | NdbTransaction | created=2, free=2, sizeof=368 |
| ndbcluster | NdbOperation | created=4, free=4, sizeof=944 |
| ndbcluster | NdbIndexScanOperation | created=0, free=0, sizeof=1152 |
| ndbcluster | NdbIndexOperation | created=0, free=0, sizeof=952 |
| ndbcluster | NdbRecAttr | created=0, free=0, sizeof=88 |
| ndbcluster | NdbApiSignal | created=16, free=16, sizeof=144 |
| ndbcluster | NdbLabel | created=0, free=0, sizeof=200 |
| ndbcluster | NdbBranch | created=0, free=0, sizeof=32 |
| ndbcluster | NdbSubroutine | created=0, free=0, sizeof=72 |
| ndbcluster | NdbCall | created=0, free=0, sizeof=24 |
| ndbcluster | NdbBlob | created=0, free=0, sizeof=496 |
| ndbcluster | NdbReceiver | created=0, free=0, sizeof=128 |
| ndbcluster | NdbLockHandle | created=0, free=0, sizeof=48 |
| ndbcluster | binlog | latest_epoch=0, latest_trans_epoch=200377404227594, latest_received_binlog_epoch=0, latest_handled_binlog_epoch=0, latest_applied_binlog_epoch=0 |
+------------+-----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
15 rows in set (0.00 sec)
If I want to create a table manually on the cluster, i get the following error:
mysql> CREATE DATABASE cluster;
Query OK, 1 row affected (0.00 sec)
mysql> CREATE TABLE cluster_test (name VARCHAR(20), value VARCHAR(20)) ENGINE=ndbcluster;
ERROR 1296 (HY000): Got error 4009 'Cluster Failure' from NDBCLUSTER
mysql> show warnings;
+-------+------+--------------------------------------------------+
| Level | Code | Message |
+-------+------+--------------------------------------------------+
| Error | 1296 | Got error 4009 'Cluster Failure' from NDBCLUSTER |
+-------+------+--------------------------------------------------+
1 row in set (0.00 sec)
I don't know where to get a detailed error description. If I'm right Errno 13 is usually some kind of permission error, but every node has the right permissions to the folders (they actually wrote some files). If you need a detailed folder permission list, please let me know.
Thanks in advice!
Currently the problem is not solved, but after some research the problem seems the AUFS storage inside Docker. I described here the issue.
I got it working using less layers inside the image. I combined a lot of commands inside one RUN directive.
Here are the Dockerfiles that work for me:
mysql daemon:
FROM ubuntu
RUN apt-get update && \
apt-get install -y libcam-pdf-perl build-essential libaio1 libaio-dev && \
cpan File::Copy \
Sys::Hostname \
Data::Dumper
// .. install mysql cluster files to /usr/local/mysql
WORKDIR /usr/local/mysql
RUN groupadd mysql && \
useradd -g mysql -s /bin/false mysql && \
chown -R root . && \
chown -R mysql data && \
chgrp -R mysql . && \
scripts/mysql_install_db --user=mysql
ENV PATH=/usr/local/mysql/bin:$PATH
USER mysql
ndbd:
FROM ubuntu
// .. install mysql cluster files to /usr/local/bin
RUN chmod +x /usr/local/bin/ndb* && \
mkdir -p /usr/local/mysql/data
ndb_mgm:
FROM ubuntu
// .. install mysql cluster files to /usr/local/bin
RUN chmod +x /usr/local/bin/ndb_mgm* && \
mkdir -p /var/lib/mysql-cluster
Maybe this helps someone!