Friday, 21 August 2015

Tune Master/Slave Replication

The option "slave_compressed_protocol", if it is set to 1, MySQL uses compression for the slave/master protocol if both the slave and the master support it. The default is 0 (no compression).
MySQL replication works with two number of threads, IO_THREAD and SQL_THREAD. IO_THREAD connects to a master, reads binary log events from the master as they come in and just copies them over to a local log file called relay log.

Here is how to implement it: 
mysql> show global variables like '%slave_compressed_protocol%';
+—————————+——-+
| Variable_name             | Value |
+—————————+——-+
| slave_compressed_protocol | OFF   |
+—————————+——-+
1 row in set (0.00 sec)
mysql> stop slave;
Query OK, 0 rows affected (0.25 sec) 
mysql> set global slave_compressed_protocol=1;
Query OK, 0 rows affected (0.00 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql> show global variables like '%slave_compressed_protocol%';
+—————————+——-+
| Variable_name             | Value |
+—————————+——-+
| slave_compressed_protocol | ON    |

+———————————–+

Upon looking into MySQL replication, I also experimented with SSH compression since the replication goes through an SSH Tunnel. I had similar success with SSH compression as well.

/.ssh/config 

 Compression yes
 CompressionLevel 9

No comments:

Post a Comment