sysad.mn

A collection of notes, guides, musings through the lenses of a Linux systems administrator

A collection of notes, guides, musings through the lenses of a Linux systems administrator

  • LinkedIn
  • Instagram
  • GitHub
Written with ❤

Speeding up MySQL replication delay

7 September, 2018 By gerald Leave a Comment

Note running this command is not recommended where data consistency is needed.

For a 487746 seconds (136 hours) replication lag took around 12 minutes to catch up

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
[root@db01 ~]$ mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 248
Server version: 10.2.16-MariaDB-log MariaDB Server
 
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> SET GLOBAL innodb_flush_log_at_trx_commit = 0; SET GLOBAL sync_binlog = 0;
MariaDB [(none)]>
[2]+  Stopped                 mysql  (wd: /u01/mysql)
(wd now: ~)
 
[root@db01 mysql]$ date;mysql -e "show slave status\G" | grep Seconds_Behind_Master
Fri Sep  7 12:01:31 AEST 2018
        Seconds_Behind_Master: 487746
 
[root@db01 ~]$ date;mysql -e "show slave status\G" | grep Seconds_Behind_Master
Fri Sep  7 12:05:12 AEST 2018
        Seconds_Behind_Master: 158918
 
[root@db01 ~]$ date;mysql -e "show slave status\G" | grep Seconds_Behind_Master
Fri Sep  7 12:09:47 AEST 2018
        Seconds_Behind_Master: 73042
 
[root@db01 ~]$ date;mysql -e "show slave status\G" | grep Seconds_Behind_Master
Fri Sep  7 12:11:10 AEST 2018
        Seconds_Behind_Master: 56615
 
[root@db01 ~]$ date;mysql -e "show slave status\G" | grep Seconds_Behind_Master
Fri Sep  7 12:12:36 AEST 2018
        Seconds_Behind_Master: 7236
 
[root@db01 ~]$ date;mysql -e "show slave status\G" | grep Seconds_Behind_Master
Fri Sep  7 12:13:17 AEST 2018
        Seconds_Behind_Master: 0
 
[root@db01 ~]$ fg
mysql   (wd: /u01/mysql)
 
MariaDB [(none)]> SET GLOBAL innodb_flush_log_at_trx_commit = 1; SET GLOBAL sync_binlog = 1;
Query OK, 0 rows affected (0.00 sec)
 
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [(none)]> Bye

 

Share this:

  • LinkedIn
  • Facebook
  • Twitter
  • WhatsApp
  • Skype
  • Print

Related

Tagged With: linux, mysql, mysql replication delay

Leave a Reply Cancel reply