maatkit使用实例

来源:互联网 发布:麦迪季后赛数据 编辑:程序博客网 时间:2024/04/29 09:31

对比配置文件: mk-config-diff h=localhost,u=root h=10.10.17.182,u=maatkit,p=maatkit

 

检查死锁:mk-deadlock-logger h=localhost,u=root d=open_kslws_com

 

检查重复索引:mk-duplicate-key-checker h=localhost,u=root d=open_kslws_com 结果给出执行方法

 

查看mysql错误日志:mk-error-log  /data/mysqldata/mysql/localhost.localdomain.err

 

批量执行: mk-find -u root -h localhost --dblike open_kslws_com --engine MyISAM --exec "optimize table %D.%N"

 

检查主从延迟: mk-heartbeat --check h=localhost,u=root h=10.10.17.182,u=maatkit,p=maatkit -D open_kslws_com
(mk-heartbeat的实现也是借助timestmp的比较实现的,它首先需要保证主从服务器必须要保持一致,通过与相同的一个NTP server同步时钟。它需要在主库上创建一个heartbeat的表,里面至少有id与ts两个字段,id为server_id,ts就是当前的时间戳 now(),该结构也会被复制到从库上,表建好以后,会在主库上以后台进程的模式去执行一行更新操作的命令,定期去向表中的插入数据,这个周期默认为1 秒,同时从库也会在后台执行一个监控命令,与主库保持一致的周期去比较,复制过来记录的ts值与主库上的同一条ts值,差值为0表示无延时,差值越大表示延时的秒数越多。我们都知道复制是异步的ts不肯完全一致,所以该工具允许半秒的差距,在这之内的差异都可忽略认为无延时。这个工具就是通过实打实的复制,巧妙的借用timestamp来检查延时)

 

检查主从差异:mk-table-checksum h=localhost,u=root h=10.10.17.182,u=maatkit,p=maatkit -d open_kslws_com   | mk-checksum-filter


分析慢语句索引建议:mk-index-usage

 

1.mk-archiver 将MySQL表中的一些行数据库归档到另外一个表或者文件中。Archive rows from a MySQL table into another table or a file.
2.mk-audit 对MySQL配置,架构和操作进行分析,汇总并生成报告。Analyze, summarize and report on MySQL config, schema and operation
3.mk-checksum-filter 过滤mk-table-checksum生成的checksums。Filter checksums from mk-table-checksum.
4.mk-deadlock-logger 抽取和记录MySQL死锁信息。Extract and log MySQL deadlock information.
5.mk-duplicate-key-checker 查找MySQL表中重复的索引和外键索引。Find duplicate indexes and foreign keys on MySQL tables.
6.mk-fifo-split Split files and pipe lines to a fifo without really splitting.暂时没有被包含在fedora 11的源包中。
7.mk-find 类似于GNU的find工具,用于查找MySQL表和执行动作。Find MySQL tables and execute actions, like GNU find.
8.mk-heartbeat 监控MySQL replication延迟时间。Monitor MySQL replication delay.
9.mk-kill kill掉符合某一条件的MySQL queries。Kill MySQL queries that match certain criteria.暂时没有被包含在fedora 11的源包中。
10.mk-loadavg 监控MySQL负载并在负载过大时采取某些动作。Watch MySQL load and take action when it gets too high. 暂时没有被包含在fedora 11的源包中。
11.mk-log-player 分割并重现MySQL的slow logs。Split and play MySQL slow logs. 暂时没有被包含在fedora 11的源包中。
12.mk-parallel-dump 以并行的方式dump MySQL的多个表。Dump sets of MySQL tables in parallel.
13.mk-parallel-restore 以并行的方式将文件Load到MySQL中去。Load files into MySQL in parallel.
14.mk-profile-compact 压缩mk-query-profiler的输出。Compact the output from mk-query-profiler.
15.mk-query-digest 解析日志和相关资料。分析,转换,过滤,复审queries,并生成报告。Parses logs and more. Analyze, transform, filter, review and report on queries.暂时没有被包含在fedora 11的源包中。存在另外的mk-log-parser工具。
16.mk-query-profiler 执行SQL语句并打印统计信息,或者评估其他进程的活动。Execute SQL statements and print statistics, or measure activity caused by other processes.
17.mk-show-grants 规范话和打印MySQL授权信息。这样你可以更有效的复制,比较他们,也可以更好的对他们进行版本控制。Canonicalize and print MySQL grants so you can effectively replicate, compare and version-control them.
18.mk-slave-delay 控制MySQL slave端,使它滞后于其master。Make a MySQL slave server lag behind its master.
19.mk-slave-find 找出并打印MySQL和其slave的层级关系树模型。Find and print replication hierarchy tree of MySQL slaves.
20.mk-slave-move 在MySQL replication层级关系中移动某一个MySQL slave。Move a MySQL slave around in the replication hierarchy.
21.mk-slave-prefetch 将relay log传给MySQL slave以便预热缓存。Pipeline relay logs on a MySQL slave to pre-warm caches.
22.mk-slave-restart 监控MySQL replication并在其出现错误时重启replication。Watch and restart MySQL replication after errors.
23.mk-table-checksum 利用它可以对在线的replication进行一致性检查,或者有效地计算一个或多个服务器上的MySQL表的校验和。Perform an online replication consistency check, or checksum MySQL tables efficiently on one or many servers.
24.mk-table-sync 有效地同步MySQL的表。Synchronize MySQL tables efficiently.
25.mk-upgrade 在两个MySQL server上提交SQL语句,并比较运行结果。Execute SQL statements against two MySQL servers and compare the results. 暂时没有被包含在fedora 11的源包中。
26.mk-visual-explain 将EXPLAIN的输出打印成树状结构。Format EXPLAIN output as a tree.

 

原创粉丝点击