Exploring MySQL Binlog Server – Ripple
Exploring MySQL Binlog Server – Ripple
Check out the benefits and areas for improvement with MySQL Ripple binlog server.
Join the DZone community and get the full member experience.Join For Free
MySQL does not limit the number of slaves that you can connect to the master server in a replication topology. However, as the number of slaves increases, they will have a toll on the master resources because the binary logs will need to be served to different slaves working at different speeds. If the data churn on the master is high, the serving of binary logs alone could saturate the network interface of the master.
A classic solution for this problem is to deploy a binlog server - an intermediate proxy server that sits between the master and its slaves. The binlog server is set up as a slave to the master, and in turn, acts as a master to the original set of slaves. It receives binary log events from the master, does not apply these events, but serves them to all the other slaves. This way, the load on the master is tremendously reduced, and at the same time, the binlog server serves the binlogs more efficiently to slaves since it does not have to do any other database server processing. Read the full post: Exploring MySQL Binlog Server - Ripple
Ripple is an open source binlog server developed by Pavel Ivanov. A blog post from Percona, titled MySQL Ripple: The First Impression of a MySQL Binlog Server, gives a very good introduction to deploying and using Ripple. I had an opportunity to explore Ripple in some more detail and wanted to share my observations through this post.
1. Support for GTID Based Replication
Ripple supports only GTID mode, and not file and position-based replication. If your master is running in non-GTID mode, you will get this error from Ripple:
Failed to read packet: Got error reading packet from server: The replication sender thread cannot start in AUTO_POSITION mode: this server has GTID_MODE = OFF instead of ON.
You can specify Server_id and UUID for the ripple server using the cmd line options: -ripple_server_id and -ripple_server_uuid
Both are optional parameters, and if not specified, Ripple will use the default server_id=112211 and uuid will be auto generated.
2. Connecting to the Master Using Replication User and Password
While connecting to the master, you can specify the replication user and password using the command line options:
-ripple_master_user and -ripple_master_password
3. Connection Endpoint for the Ripple Server
You can use the command line options -ripple_server_ports and -ripple_server_address to specify the connection end points for the Ripple server. Ensure to specify the network accessible hostname or IP address of your Ripple server as the -rippple_server_address. Otherwise, by default, Ripple will bind to localhost and hence you will not be able to connect to it remotely.
4. Setting up Slaves to the Ripple Server
You can use the CHANGE MASTER TO command to connect your slaves to replicate from the Ripple server.
To ensure that Ripple can authenticate the password that you use to connect to it, you need to start Ripple by specifying the option -ripple_server_password_hash
For example, if you start the ripple server with the command:
you can use the following CHANGE MASTER TO command to connect from the slave:
Note that the password hash specified for the Ripple server corresponds to the text password used in the CHANGE MASTER TO command. Currently, Ripple does not authenticate based on the usernames and accepts any non-empty username as long as the password matches.
5. Ripple Server Management
It's possible to monitor and manage the Ripple server using the MySQL protocol from any standard MySQL client. There are a limited set of commands that are supported which you can see directly in the source code on the mysql-ripple GitHub page.
Some of the useful commands are:
SELECT @@global.gtid_executed;- To see the GTID SET of the Ripple server based on its downloaded binary logs.
STOP SLAVE;- To disconnect the Ripple server from the master.
START SLAVE;- To connect the Ripple server to the master.
Known Issues and Suggestions for Improvement
1. I did not see an option to set up an SSL replication channel from a Ripple server to the master
As a result of this, Ripple server will not be able to connect to a master that mandates encrypted connections. Attempting to connect will result in the error:
2. I was not able to get Ripple server working with the semi-sync option
I started the Ripple server using the option -ripple_semi_sync_slave_enabled=true
On connecting it, the master was able to detect the Ripple server as a semi-sync enabled slave.
However, trying to execute a transaction in semi-sync mode waited for rpl_semi_sync_master_timeout which was 180000
I could see that semi-sync got turned off at the master:
Corresponding snippet from the mysql error logs:
There is an issue reported along similar lines here on the MySQL Ripple Github page.
3. Issue when using parallel replication for the slaves of Ripple server
I saw that SQL thread on the slave would often stop with the error:
Analyzing the relay log and position above revealed that the ‘sequence number’ of the transaction at this point was reset to 1. I tracked down the cause to a binlog rotation happening on the original master. Typically, for direct slaves, there is a rotate event due to which relay logs would also rotate based on master binary log rotation. My assessment is that such conditions can be detected and sequence number reset can be handled by parallel threads. But when the sequence number changes without the rotation of the relay logs, we see the parallel threads failing.
This observation is reported as the issue: slave parallel thread failure while syncing from binlog server #26
4. mysqlbinlog utility does not work on the binary logs produced by Ripple server
Trying to run the mysqlbinlog utility on the binary log resulted in the error:
This issue is raised here: Not able to open the binary log files using mysqlbinlog utility. #25
It's acknowledged by the author as a known issue. I feel that it would be useful to support this utility for debugging purposes.
That’s the report for now from my quick testing. I plan to update this blog post as and when I come across more findings on Ripple. Overall, I found it to be simple and straightforward to use and has the potential to become a standard for binlog servers in MySQL environments.
Published at DZone with permission of Prasad Nagaraj , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.