MySQL Ripple 一款开源的MySQL binlog server软件
作者:互联网
MySQL Ripple 是什么
MySQL Ripple 是有google开源的一款工具,地址 https://github.com/google/mysql-ripple
其核心介绍
Ripple is a MySQL binlog server: software which receives binary logs from MySQL or MariaDB servers and delivers them to another MySQL or MariaDB server. Practically ,this is an intermediary master which does not store any data, except the binary logs themselves, and does not apply events.
其实就相当于一个实例所有的表都是黑洞存储引擎,只接受来自主库的binlog但是应用binlog ,不产生数据。但是可以将binlog 传递给其他下游的数据库实例。支持 MySQL 和 MariaDB。
与黑洞存储引擎不同的是,要使用黑洞存储引擎必须安装MySQL、MariaDB软件,初始化实例等信息。而 MySQL Ripple 其实就是一个程序,支持mysql GTID复制协议,(不支持位点模式的复制)。
MySQL Ripple 有哪些应用场景
1 如果有一个主库后面挂N个从库,主库的IO压力以及带宽会非常大。我们可以利用MySQL Ripple 作为一个中间层的binlog server 供下游订阅。
2 也可以给N多个下游提供binlog订阅。
3 类似 mysqlbinlog --stop-never 模式备份binlog。如果发生主备切换,MySQL Ripple可以通过程序动态调整主库的指向,确保binlog的连续性。
如何安装
需要安装bazel
apt-get install pkg-config zip g++ zlib1g-dev unzip python libssl-dev default-jdk-headless libmariadbclient-dev echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - apt-get update && sudo apt-get install bazel
获取代码
git clone https://github.com/google/mysql-ripple.git
编译
cd mysql-ripple bazel build :all bazel test :all
特别注意 目前看到测试成功的案例都是在Ubuntu 上安装成功的,Linux centos 7 上安装测试遇到很多问题。大家需要自己探索。
如何用MySQL ripple
环境
master 127.0.0.1:13001
ripple 127.0.0.1:15000
slave 127.0.0.1:13002
启动mysql ripple
$./bazel-bin/rippled
-ripple_datadir
=./data-ripple_master_address
=127.0.0.1-ripple_master_port
=13001-ripple_master_user
=root-ripple_server_ports
=15000
在指定的数据目录文件里面查看 binlog
$ ls -l data/ total 14920 -rw-rw-r-- 1 sveta sveta 15251024 Mar 6 01:43 binlog.000000 -rw-rw-r-- 1 sveta sveta 71 Mar 6 00:50 binlog.index
相关参数介绍:
-ripple-datadir : datadir where Ripple stores binary logs
-ripple_master_address : master host
-ripple_master_port : master port
-ripple_master_user : replication user
-ripple_server_ports : comma-separated ports which Ripple will listen
在slave 上执行
13002 slave >change master to master_host='127.0.0.1',master_port=15000, master_user='ripple';
Query OK, 0 rows affected, 1 warning (0.02 sec)
13002 slave >start slave;
测试数据
master 13001> select count(*) from sbtest1;
+----------+
| count(*) |
+----------+
| 10000 |
+----------+
1 row in set (0.08 sec)
master 13001> checksum table sbtest1;
+----------------+------------+
| Table | Checksum |
+----------------+------------+
| sbtest.sbtest1 | 4162333567 |
+----------------+------------+
1 row in set (0.11 sec)
slave 13002> select count(*) from sbtest1;
+----------+
| count(*) |
+----------+
| 10000 |
+----------+
1 row in set (0.40 sec)
slave 13002> checksum table sbtest1;
+----------------+------------+
| Table | Checksum |
+----------------+------------+
| sbtest.sbtest1 | 1797645970 |
+----------------+------------+
1 row in set (0.13 sec)
slave 13002> checksum table sbtest1;
+----------------+------------+
| Table | Checksum |
+----------------+------------+
| sbtest.sbtest1 | 4162333567 |
+----------------+------------+
1 row in set (0.10 sec)
ripple 的log
$ ./bazel-bin/rippled -ripple_datadir=./data -ripple_master_address=127.0.0.1 -ripple_master_port=13001 -ripple_master_user=root -ripple_server_ports=15000 WARNING: Logging before InitGoogleLogging() is written to STDERR I0306 15:57:13.641451 27908 rippled.cc:48] InitPlugins I0306 15:57:13.642007 27908 rippled.cc:60] Setup I0306 15:57:13.642937 27908 binlog.cc:307] Starting binlog recovery I0306 15:57:13.644090 27908 binlog.cc:350] Scanning binlog file: binlog.000000 I0306 15:57:13.872016 27908 binlog.cc:417] Binlog recovery complete binlog file: binlog.000000, offset: 15251088, gtid: 6ddac507-3f90-11e9-8ee9-00163e000000:0-0-7192 I0306 15:57:13.872050 27908 rippled.cc:106] Recovered binlog I0306 15:57:13.873811 27908 mysql_server_port_tcpip.cc:150] Listen on host: localhost, port: 15000 I0306 15:57:13.874282 27908 rippled.cc:62] Start I0306 15:57:13.874511 27910 mysql_master_session.cc:181] Master session starting I0306 15:57:13.882601 27910 mysql_client_connection.cc:148] connected to host: 127.0.0.1, port: 13001 I0306 15:57:13.895349 27910 mysql_master_session.cc:137] Connected to host: 127.0.0.1, port: 13001, server_id: 1, server_name: W0306 15:57:13.898556 27910 mysql_master_session.cc:197] master does not support semi sync I0306 15:57:13.898583 27910 mysql_master_session.cc:206] start replicating from '6ddac507-3f90-11e9-8ee9-00163e000000:0-0-7192' I0306 15:57:13.899031 27910 mysql_master_session.cc:229] Master session entering main loop I0306 15:57:13.899550 27910 binlog.cc:626] Update binlog position to end_pos: binlog.000000:15251152, gtid: 0-0-7192 I0306 15:57:13.899572 27910 binlog.cc:616] Skip writing event [ Previous_gtids len = 67 ] I0306 15:57:13.899585 27910 binlog.cc:626] Update binlog position to end_pos: binlog.000000:15251152, gtid: 0-0-7192 ...
总结
这是一款非常轻量级的 binlog server,只是安装还不是很友好,我查看了github上的issue 基本都是安装相关的。在linux 上安装特别痛苦,有安装成功的 ,欢迎介绍安装过程遇到的问题。
另外推荐同款的 软件 https://github.com/flike/kingbus (阅读原文),该开源的软件和mysql ripple类似,不过是基于etcd和go语音开发的,github有中文的介绍,大家有兴趣的可以进一步测试。
参考文章
https://www.percona.com/blog/2019/03/15/mysql-ripple-first-impression-of-mysql-binlog-server/
-The End-
本公众号长期关注于数据库技术以及性能优化,故障案例分析,数据库运维技术知识分享,个人成长和自我管理等主题,欢迎扫码关注。
标签:binlog,15,cc,57,server,master,MySQL,ripple 来源: https://blog.51cto.com/u_15127645/2778770