Mysql管理必备工具Maatkit详解之十三(mk-slave-find)
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,使用非常简单:
# 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
最后,我们在看下这个工具的帮助选项:
# 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 MASTER-HOST
Options:
--ask-pass Prompt for a password when connecting to MySQL
--charset -AEnables 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 -DDatabase to use
--defaults-file -FOnly read mysql options from the given file
--help Show a brief help message and exit
--host -hConnect to host
--password -pPassword to use when connecting
--port -PPort 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 -SSocket file to use for connection
--user -uUser for login if not current user
--version Output version information and exit
DSN syntax is key=value[,key=value...]Allowable DSN keys:
KEYCOPYMEANING
====================================================
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
页:
[1]