MySQL 有很多周边工具,用这些工具提高日常维护管理 MySQL 的效率。

原文: https://mp.weixin.qq.com/s/6IvA-rKhFO4ikRg0Ks43LA

Percona Toolkit

官方地址: https://docs.percona.com/percona-toolkit/

常用的有这些:

  • pt-query-digest,分析MySQL查询,常用于分析 MySQL 慢查询。

  • pt-online-schema-change,可在线修改表结构,常用于生产环境大表修改表结构。

  • pt-table-checksum,验证MySQL复制完整性,常用于主从架构数据一致性校验。

  • pt-table-sync,同步 MySQL 表数据,多数情况与 pt-table-checksum 结合使用,用于修复不一致的数据。

  • pt-kill,kill掉符合特定条件的MySQL查询,通常用来查询或者 KILL 掉执行时间超过多少秒的 SQL。

  • pt-archiver,MySQL数据归档,常用来归档大表。

备份工具

除了官方的备份工具 mysqldump,其他常用的有: xtrabackup,物理备份

官方链接: https://www.percona.com/software/mysql-database/percona-xtrabackup

mydumper,逻辑备份

GitHub 地址: https://github.com/mydumper/mydumper

闪回工具

可以借助一些工具实现 MySQL 闪回,比如:

binlog2sql

binlog2sql,除了闪回功能,还支持主从切换后新 master 数据补偿,并且支持从 Binlog 中生成标准 SQL。

GitHub 地址: https://github.com/danfengcao/binlog2sql

my2sql

my2sql,解析出回滚语句,我们前面写的:MySQL执行delete误删除数据恢复,就讲了my2sql的用法。

GitHub地址: https://github.com/liuhr/my2sql

mysqlbinlog_flashback

mysqlbinlog_flashback,产生Binlog中的回滚SQL

GitHub 地址: https://github.com/58daojia-dba/mysqlbinlog_flashback

数据同步工具

otter

Otter,基于数据库增量日志解析,能将MySQL的数据同步到其他MySQL或者Oracle。

GitHub 地址: https://github.com/alibaba/otter

go-mysql-transfer

go-mysql-transfer,MySQL数据库实时增量同步工具,支持多种接收端,比如:Redis、MongoDB、Elasticsearch、RocketMQ、Kafka、RabbitMQ、HTTP API等,

GitHub地址: https://github.com/wj596/go-mysql-transfer

监控工具

Prometheus,目前比较流行的监控工具,前面也写过一篇文章:Prometheus+Grafana 监控 MySQL。

官方链接: https://prometheus.io/

Prometheus监控MySQL

PMM,PMM(Percona Monitoring and Management )是一款免费的开源监控工具,可以用来监控 MySQL、MongoDB 和 PostgreSQL 等数据库。是对 Prometheus 和 Grafana 这些组件做了二次开发,监控数据更加丰富,部署也方便很多。

PMM 监控 MySQL

官方链接: https://www.percona.com/software/database-tools/percona-monitoring-and-management

Zabbix,Zabbix 算是历史悠久的监控工具了。

Zabbix 监控 MySQL

官方链接:https://www.zabbix.com/

SQL分析审核工具

Soar

Soar,SOAR(SQL Optimizer And Rewriter) 是一个对 SQL 进行优化和改写的自动化工具,

GitHub 地址: https://github.com/XiaoMi/soar

SQLAdvisor

SQLAdvisor,通过分析 SQL,可以给出索引优化建议,

GitHub 地址: https://github.com/Meituan-Dianping/SQLAdvisor

Yearning

Yearning,SQL 审核平台,基于 Go 语言编写,

GitHub 地址: https://github.com/cookieY/Yearning

Archery

Archery,SQL 审核平台,基于 Python 语言编写,

GitHub 地址: https://github.com/hhyo/Archery

分库分表工具

MyCAT2

MyCAT2,遵守 MySQL 原生协议、基于心跳的自动故障切换、支持读写分离等。

GitHub 地址: https://github.com/MyCATApache/Mycat2

DBLE

DBLE,基于MyCAT二次开发,在兼容性、复杂查询和分布式事务方面做了改进和优化,并修复了一些Bug。

GitHub 地址: https://github.com/actiontech/dble

shardingsphere

shardingsphere,分布式SQL事务和查询引擎,可在任何数据库上进行数据分片、扩展、加密等,

GitHub地址: https://github.com/apache/shardingsphere

Online DDL工具

gh-ost,是一款用Go语言开发的MySQL在线改表工具,

GitHub 地址: https://github.com/github/gh-ost

pt-online-schema-change,Percona开源的在线修改表结构工具。

地址: https://docs.percona.com/percona-toolkit/pt-online-schema-change.html

MySQL高可用工具

MHA

MHA,可以根据需要扩展MySQL节点,支持任何存储引擎。

GitHub 地址: https://github.com/yoshinorim/mha4mysql-manager/

Orchestrator

Orchestrator,支持拓扑发现、集群重塑等功能。

Orchestrator实现MySQL故障切换

GitHub 地址: https://github.com/openark/orchestrator

Xenon

Xenon,使用Raft协议的MySQL HA和复制管理工具。

GitHub 地址: https://github.com/radondb/xenon

MGR

InnoDB Cluster(MGR),官方高可用解决方案,支持多节点写入,支持强一致性,这篇文章讲了MGR的部署:MySQL 高可用方案–MGR 第02期:部署

官方文档: https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-innodb-cluster.html