pmysql:大批量服务器并行执行mysql命令的工具

      相信很多人都有这样的体会,就是当手头的机器越来越多时,维护等常规操作变得越来越折腾,就是按个机器登录一遍,别的不说,光输入密码也够捣鼓一阵子。因此,一系列的并行批量操作工具应运而生,比如对大批量的linux并行操作的工具psh、pscp等,但是对于大数量的mysql服务器进行操作的工具,我一直也没找一个顺手的工具。

    开源的力量是强大的!最近终于找到了一个开源工具:pmysql ,由facebook mysql engineers组Domas Mituzas 开发的工具,用了一下感觉不错,据说“Ability to crunch hundreds of megabytes of processlist info in few seconds” 。

     具体源码可以在:bzr co lp:mysqlatfacebook/tools/pmysql  下载。

    编译的过程比较简单,但是要先安装mysql devel 、glib 等库,并指定好 mysql_config的路径,具体不再赘述了 :

 

 

 

实际上,我们看其工具上面也有很多待改进的地方,比如,密码在所有的server必须一致、对需操作的数据库不够灵活等。

看着心里直痒痒,我也顺手改了一下,增加了按正则表达式匹配数据库名和只打印命令但不实际执行的功能(操作需谨慎,哈哈),如下:

$ ./pmysql --help
Usage:
  pmysql [OPTION...] [query]

Parallel multiple-server MySQL querying tool

Help Options:
  -?, --help                Show help options

Application Options:
  -Q, --query               Queries to run
  -F, --query-file          File to read queries from
  -X, --servers-file        File to read servers from (stdin otherwise)
  -u, --user                Username with privileges to run the dump
  -p, --password            User password
  -P, --port                TCP/IP port to connect to
  -S, --socket              UNIX domain socket file to use for connection
  -B, --database            Databases (comma-separated) to run query against
  -A, --all                 Run on all databases except i_s, mysql and test
  -t, --threads             Number of parallel threads
  -M, --patterns            Run only on databases which match the regular expression
  -C, --printcmd            Only print out the command,Not really execute it
  -e, --escape              Should tabs, newlines and zero bytes be escaped
  -c, --compress            Compress server-client communication
  -T, --connect-timeout     Connect timeout in seconds (default: 2)

 

添加的部分代码比较简单,就不贴出来了,呵呵

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值