免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2902 | 回复: 0

Mysql管理必备工具Maatkit详解之十三(mk-slave-find) [复制链接]

论坛徽章:
0
发表于 2010-02-23 14:26 |显示全部楼层

Mysql管理必备工具Maatkit详解之十三(mk-slave-find)
2009年12月07日 作者: 大头刚 
mk-slave-find - 顾名思义,根据master查找slave。安装方法查看
这里

在mysql5.1里查看一个master有哪些slave可以通过PROCESSLIST系统表查出:
mysql> select HOST from information_schema.PROCESSLIST where STATE like '%slave%';
+------------------+
| HOST             |
+------------------+
| 192.168.1.2:44846 |
| 192.168.1.3:33022 |
| 192.168.1.4:50836 |
| 192.168.1.5:32769 |
| 192.168.1.6:33113 |
| 192.168.1.7:33005 |
| 192.168.1.8:32786 |
| 192.168.1.9:32862 |
+------------------+
11 rows in set (0.00 sec)
在5.1之前想查出有哪些slave比较麻烦,比较直接的就是直接通过show processlist把所有进程列出,在去刷选查出:
show processlist;
+-----------+----------+------------------+-----------+-------------+----------+----------------------------------------------------------------+------------------+
| Id        | User     | Host             | db        | Command     | Time     | State                                                       | Info             |
+-----------+----------+------------------+-----------+-------------+----------+----------------------------------------------------------------+------------------+
|      1211 | slave2 | 192.168.1.2:32807 | NULL      | Binlog Dump | 10366310 | Has sent all binlog to slave; waiting for binlog to be updated | NULL             |
| 209052219 | slave3 | 192.168.1.3:60924 | NULL      | Binlog Dump |  4733312 | Has sent all binlog to slave; waiting for binlog to be updated | NULL             |
| 291690986 | slave4  | 192.168.1.4:46357  | NULL      | Binlog Dump |  2061057 | Has sent all binlog to slave; waiting for binlog to be updated | NULL             |
| 291719840 | slave5 | 192.168.1.5:33221 | NULL      | Binlog Dump |  2060248 | Has sent all binlog to slave; waiting for binlog to be updated | NULL             |
| 291809908 | slave6 | 192.168.1.6:38799 | NULL      | Binlog Dump |  2057734 | Has sent all binlog to slave; waiting for binlog to be updated | NULL             |
| 345256247 | slave7  | 192.168.1.7:39452  | NULL      | Binlog Dump |   323761 | Has sent all binlog to slave; waiting for binlog to be updated | NULL             |
| 347842030 | test      | 192.168.1.22:55278 | test | Sleep       |        6 |                                                                | NULL             |
| 348667710 | test      | 192.168.1.33:56003 | test | Sleep       |        6 |                                                                | NULL             |
| 353741496 | test   | 192.168.1.26:48062 | test | Sleep       |        0 |      
看起来都乱,所以Maatkit提供了mk-slave-find工具来方便查询master的slave,使用非常简单:
[root@mysql ~]# mk-slave-find --host 192.168.1.1 -u  -p

192.168.1.1
+- 192.168.1.2
+- 192.168.1.3
+- 192.168.1.4
+- 192.168.1.5
+- 192.168.1.6
+- 192.168.1.7
+- 192.168.1.8
+- 192.168.1.9
最后,我们在看下这个工具的帮助选项:
[root@mysql ~]# mk-slave-find --help
mk-slave-find finds and prints a hierarchy tree of MySQL slaves.  For more
details, please use the --help option, or try 'perldoc /usr/bin/mk-slave-find'
for complete documentation.

Usage: /usr/bin/mk-slave-find [OPTIONS] MASTER-HOST

Options:
  --ask-pass          Prompt for a password when connecting to MySQL
  --charset       -A  Enables character set settings in Perl and MySQL
  --config            Read this comma-separated list of config files; if
                      specified, this must be the first option on the command
                      line
  --database      -D  Database to use
  --defaults-file -F  Only read mysql options from the given file
  --help              Show a brief help message and exit
  --host          -h  Connect to host
  --password      -p  Password to use when connecting
  --port          -P  Port number to use for connection
  --recurse           Number of levels to recurse in the hierarchy
  --set-vars          Specify any variables you want to be set immediately after
                      connecting to MySQL
  --socket        -S  Socket file to use for connection
  --user          -u  User for login if not current user
  --version           Output version information and exit

DSN syntax is key=value[,key=value...]  Allowable DSN keys:
  KEY  COPY  MEANING
  ===  ====  =============================================
  A    yes   Default character set
  D    yes   Database to use
  F    yes   Only read default options from the given file
  P    yes   Port number to use for connection
  S    yes   Socket file to use for connection
  h    yes   Connect to host
  p    yes   Password to use when connecting
  u    yes   User for login if not current user

Options and values after processing arguments:
  --ask-pass          FALSE
  --charset           FALSE
  --config            /etc/maatkit/maatkit.conf,/etc/maatkit/mk-slave-find.conf,/root/.maatkit.conf,/root/.mk-slave-find.conf
  --database          FALSE
  --defaults-file     (No value)
  --help              TRUE
  --host              (No value)
  --password          (No value)
  --port              (No value)
  --recurse           FALSE
  --set-vars          FALSE
  --socket            (No value)
  --user              (No value)
  --version           FALSE

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/111930/showart_2185029.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP