MaxScale Binlog Server实践
MaxScale Binlog Server实践
简介
Part1:写在最前
在之前的博文中有说到MaxScale,作为中间件,配合MHA使用或者主从使用可实现读写分离和负载均衡,今天简单介绍下MaxScale作为Binlog Server来减少主从延迟的问题;MySQL的主从架构中,链式拓扑的架构比较容易出现主从延迟的问题。本文着重介绍MaxScale作为Binlog Server是如何降低主从延迟的。
MaxScale配合MHA请移步至:
http://suifu.blog.51cto.com/9167728/1869520
Part2:本文环境
HE1:192.168.1.248 slave
HE3:192.168.1.250 master
HE4:192.168.1.251 maxscale
架构演示
效果对比
实战
[root@HE4 ~]# yum -y install maxscale-2.0.1-2.centos.6.x86_64.rpm
[root@HE4 ~]# mkdir -p /data/binlog
[root@HE4 ~]# useradd maxscale
[root@HE4 ~]# chown -R maxscale. /data/binlog
[root@HE4 ~]# cat /etc/maxscale.cnf
[maxscale] threads=1 ##根据CPU核数设置 [Replication] type=service router=binlogrouter user=mysync passwd=MANAGER # 使用主库上的repl复制账号 # 权限: # GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'repl'@'%' IDENTIFIED BY 'repl'; router_options=server_id=1251,heartbeat=30,binlogdir=/data/binlog,transaction_safety=1,mariadb10-compatibility=1,send_slave_heartbeat=1 # server_id设置maxscale的,记得不能与主和从库重复,要唯一 # heartbeat=30秒,意思为当maxscale在30秒内没有接收到主库推送的binlog日志,发送心跳检查 # binlogdir设置接收binlog的存放路径,目录属性chown -R maxscale.maxscale /data/binlog # transaction_safety=1此参数用于启用binlog日志中的不完整事务检测。 当MariaDB MaxScale启动时,如果当前binlog文件已损坏或找到不完整的事务,则可能会出现错误消息。 在正常工作期间,binlog事件不会分配到从库,直到事务已经提交。 默认值为off,设置transaction_safety = on以启用不完全事务检测。 # send_slave_heartbeat=1开启心跳检查 [Replication Listener] type=listener service=Replication protocol=MySQLClient port=5308 # 后端的从库CHANGE MASTER TO这个端口,默认5308 [CLI] type=service router=cli [CLI Listener] type=listener service=CLI protocol=maxscaled port=6603
[root@HE4 ~]# /etc/init.d/maxscale start
Starting MaxScale: maxscale (pid 16680) is running... [ OK ]
[root@HE4 ~]# /etc/init.d/maxscale status
Checking MaxScale status: MaxScale (pid 16680) is running.[ OK ]
[root@HE1 ~]# mysql -umysync -pMANAGER -h192.168.1.251 -P5308 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 3196 Server version: 10.0.0 2.0.1-maxscale Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> CHANGE MASTER TO MASTER_HOST='192.168.1.250',MASTER_USER='mysync',MASTER_PASSWORD='MANAGER',MASTER_PORT=3306,MASTER_LOG_FILE='mysql-bin.000005',MASTER_LOG_POS=20; ERROR 1234 (42000): Can not set MASTER_LOG_POS to 20: Permitted binlog pos is 4. Specified master_log_file=mysql-bin.000005 MySQL [(none)]> CHANGE MASTER TO MASTER_HOST='192.168.1.250',MASTER_USER='mysync',MASTER_PASSWORD='MANAGER',MASTER_PORT=3306,MASTER_LOG_FILE='mysql-bin.000005',MASTER_LOG_POS=4; MySQL [(none)]> start slave; Query OK, 0 rows affected (0.00 sec)
这里可以看出,Maxscale binlog server只能从位置4开始配置
配置好后,在/data/binlog下生成的binlog文件
[root@HE4 ~]# cd /data/binlog/
cache master.ini mysql-bin.000003
[root@HE3 ~]# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 7 Server version: 10.1.16-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show master status; +------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000005 | 652 | | | +------------------+----------+--------------+------------------+ 1 row in set (0.00 sec) MariaDB [(none)]> grant replication client,replication slave on *.* to 'mysync'@'192.168.1.%' identified by 'MANAGER'; MariaDB [(none)]>flush privileges;
从库指向binlogserver [root@HE1 ~]# mysql -uroot -pMANAGER Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 5 Server version: 10.1.16-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CHANGE MASTER TO MASTER_HOST='192.168.1.251',MASTER_USER='mysync',MASTER_PASSWORD='MANAGER',MASTER_PORT=5308,MASTER_LOG_FILE='mysql-bin.000005',MASTER_LOG_POS=652; Query OK, 0 rows affected (0.02 sec) MariaDB [(none)]> start slave; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> show slave status\G *************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.1.251Master_User: mysyncMaster_Port: 5308Connect_Retry: 60Master_Log_File: mysql-bin.000005Read_Master_Log_Pos: 652Relay_Log_File: mysql-relay-bin.000002Relay_Log_Pos: 537Relay_Master_Log_File: mysql-bin.000005Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0Last_Error: Skip_Counter: 0Exec_Master_Log_Pos: 652Relay_Log_Space: 835Until_Condition: NoneUntil_Log_File: Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1250Master_SSL_Crl: Master_SSL_Crlpath: Using_Gtid: NoGtid_IO_Pos: Replicate_Do_Domain_Ids: Replicate_Ignore_Domain_Ids: Parallel_Mode: conservative 1 row in set (0.00 sec)
MaxScale Binlog Server实践相关推荐
- MaxScale Binlog Server
MaxScale Binlog Server理想架构图 要点提示: 1.MX只能适合Mariadb自家的版本作为BINLOG ROUTER,其他DB都不适合 2.开通IPTABLES,避免端口呗过滤 ...
- MySQL链式复制加速神器: MaxScale Binlog Server(附视频)
本文根据DBAplus社群第83期线上分享整理而成 讲师介绍 贺春旸 普惠金融MySQL专家 <MySQL管理之道>第一版.第二版作者,曾任职于中国移动飞信.机锋安卓市场,拥有丰富的数据库 ...
- 2021-02-28 SQL server实践记录---3Select
SQL server实践记录---3Select 举例用相关表 各种Select语句 举例用相关表 CangKu[cangkuid, cangkuhao, chengshi, mianji, chua ...
- 基于django rest framework的mock server实践
网上找了一下mock server的实现,发现python的基本都是基于flask来实现的,因最近在学django,就尝试用drf实现了下: A brief introduction of sui_m ...
- Mock Server实践
背景 在美团服务端测试中,被测服务通常依赖于一系列的外部模块,被测服务与外部模块间通过REST API或是Thrift调用来进行通信.要对被测服务进行系统测试,一般做法是,部署好所有外部依赖模块,由被 ...
- 快速迁移数据中心:华为云数据库SQL Server实践案例技术解析
1. 简介 企业或用户将数据中心部署在线下,采用独立软件提供商(Independent Software Vendor)软件进行管理.线下数据运维成本较高,故障容灾单一化,是目前遇到的瓶颈.采用云 ...
- 搭建Mock Server实践(一)理论篇
背景 在我司 S 产品测试时,日常工作有百分之 70 是需要跟接口测试打交道,搭建的 MockServer 有数十个. 接触过多个搭建 MockServer 平台,整理成文,分享之. 目录 part1 ...
- Spring Boot 集成 MyBatis和 SQL Server实践
文章共 509字,阅读大约需要 2分钟 ! 概 述 Spring Boot工程集成 MyBatis来实现 MySQL访问的示例我们见过很多,而最近用到了微软的 SQL Server数据库,于是本文则给 ...
- binlog复制的灾备设计
2019独角兽企业重金招聘Python工程师标准>>> [导读]本文主要介绍Booking网站在业务发展过程中碰到MySQL主库挂载几十甚至上百个从库时探索的解决方案:使用Binlo ...
最新文章
- 迁移学习——Domain Adaptation
- 指针数组 与 数组指针 的分析
- 数据库集群技术 -摘自网络
- 如何关闭一切流氓程序开机自启【gitter、vmware等】
- 如何修改 匿名类型 中的属性值 ?
- [html] 列举几种瀑布流布局的方法
- SolrCloud详解及搭建
- KeyMob移动广告聚合平台-致力于打造最牛的聚合平台
- 用Flex绘制带Icon的Tooltip
- 【redis】Redis中常用的五大数据类型的介绍以及代码的实现
- winform文件迁移工具
- 快手短视频领域为例的领域数据建设探索
- ACM--素数距离问题
- SQL语句BETWEEN
- php对接海康视频教程_海康安防管理平台Web视频对接
- 一个基于对话框的简单MFC程序分析
- 微小区客户成功服务流程
- 最近穷疯了只好吃馒头
- 常用电路基础公式换算
- 【前端html页面数据导出为pdf文件】