I have a problem with MySQL replication and I wanted to find advice or information on it.
Let me show you the problem.
Observation of delays with replication
Master
Master work on the file mysql-bin.024080
show master status\G
*************************** 1. row ***************************
File: mysql-bin.024080
Position: 62186738
Slave
Slave has all files ( mysql-bin.024080 ) and it works on the file mysql-bin.024075 . The gap between these files increases over time. Currently SQL_THREAD is behind 5 binary logs.
show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.55.55.21
Master_User: slave_replicator
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.024080
Read_Master_Log_Pos: 60111446
Relay_Log_File: mysql-relay-bin.002952
Relay_Log_Pos: 154669142
Relay_Master_Log_File: mysql-bin.024075
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: 154668929
Relay_Log_Space: 2631436265
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: 68158
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: 195390
Master_UUID: 361633ab-6bb7-11e7-829c-1a76636a64a1
Master_Info_File: /var/lib/mysql/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:
When i set sync_binlog = 0 and innodb_flush_log_at_trx_commit = 2 parameters the server performance improves greatly and allows the replication of Slave to catch up. However, I want to leave sync_binlog = 1 and innodb_flush_log_at_trx_commit = 1.
MySQL Global
MySQL Global status: pastebin.com/pnVxjtBi
MySQL Global variables: pastebin.com/f80JJb0u
I think my problem must be with something like Fsync performance.
https://www.percona.com/blog/2018/02/08/fsync-performance-storage-devices/
How I can make my MySQL Slave catch up the Master ?
The result of the sysbench seems bad for a server like this.
What do you think about this ?
sysbench
sudo sysbench fileio --time=60 --file-num=1 --file-extra-flags= --file-total-size=4096 --file-block-size=4096 --file-fsync-all=on --file-test-mode=rndwr --file-fsync-freq=0 --file-fsync-end=0 --percentile=99 run
sysbench 1.0.11 (using system LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Extra file open flags: 0
1 files, 4KiB each
4KiB total file size
Block size 4KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
Calling fsync() after each write operation.
Using synchronous I/O mode
Doing random write test
Initializing worker threads...
Threads started!
File operations:
reads/s: 0.00
writes/s: 117.51
fsyncs/s: 117.51
Throughput:
read, MiB/s: 0.00
written, MiB/s: 0.46
General statistics:
total time: 60.0081s
total number of events: 7052
Latency (ms):
min: 0.42
avg: 8.51
max: 17.87
99th percentile: 8.74
sum: 59994.48
Threads fairness:
events (avg/stddev): 7052.0000/0.00
execution time (avg/stddev): 59.9945/0.00
Hardware detail of the machines
Master:
HOST | |
---|---|
Host OS | Xenserver |
CPU | Intel(R) Xeon(R) CPU D-1541 @ 2.10GHz |
RAM on Host | 128 Go |
Space on Host | RAID 10 SSD 4x744,687Go (1,454 TB) |
VM (MySQL) | |
VM OS | Ubuntu 16.04 |
RAM on VM | 120 Go |
Space on VM | 1,3TB |
SLAVE
HOST (MySQL) | |
---|---|
Host OS | Ubuntu 18.04 |
CPU | 2x Intel(R) Xeon(R) Silver 4214R CPU @ 2.40GHz |
RAM on Host | 192 Go |
Space on Host | RAID 10 SSD (4x3,492TB) 6,984TB |