mysqlrplshow

mysqlrplshow工具是用来展示主备之间拓扑结构

$ ./mysqlrplshow --help
Usage: mysqlrplshow --master=root@localhost:3306 
 
mysqlrplshow - show slaves attached to a master
 
Options:
  --version             show program's version number and exit
  --help                display a help message and exit
  --master=MASTER       connection information for master server in the form:
                        <user>[:<password>]@<host>[:<port>][:<socket>] or
                        <login-path>[:<port>][:<socket>].
  -l, --show-list       print a list of the topology.
  -f FORMAT, --format=FORMAT
                        display the list in either grid (default), tab, csv,
                        or vertical format
  -r, --recurse         traverse the list of slaves to find additional
                        master/slave connections. User this option to map a
                        replication topology.
  --max-depth=MAX_DEPTH
                        limit the traversal to this depth. Valid only with the
                        --recurse option. Valid values are non-negative
                        integers.
  -p, --prompt          prompt for slave user and password if different from
                        master login.
  -n NUM_RETRIES, --num-retries=NUM_RETRIES
                        number of retries allowed for failed slave login
                        attempt. Valid with --prompt only.
  -q, --quiet           turn off all messages for quiet execution.
  --discover-slaves-login=DISCOVER
                        at startup, query master for all registered slaves and
                        use the user name and password specified to connect.
                        Supply the user and password in the form
                        <user>[:<password>] or <login-path>. For example,
                        --discover-slaves-login=joe:secret will use 'joe' as
                        the user and 'secret' as the password for each
                        discovered slave.

因为机器有限,在一台机器上开了三个实例:3306、3406、3506。3306和3406互为主备,3506指向3306

–master:连接master需要用户名、密码、主机、端口
–discover-slaves:查找slave需要用户名、密码
–recurse:多向查找,以master为中心查找所有slave,再以slave为中心,查找slave或master
-l:以表单形式展示

$ ./mysqlrplshow --master=slave:slave@hostname_lx:3306 --recurse --discover-slaves-login=slave:slave -l
# master on hostname_lx: ... connected.
# Finding slaves for master: hostname_lx:3306
# master on hostname_lx: ... connected.
# Finding slaves for master: hostname_lx:3406
# master on hostname_lx: ... connected.
# Finding slaves for master: hostname_lx:3506
 
# Replication Topology Graph
hostname_lx:3306 (MASTER)
   |
   +--- hostname_lx:3406 - (SLAVE + MASTER)
   |   |
   |   +--- hostname_lx:3306 <--> (SLAVE + MASTER)
   |
   +--- hostname_lx:3506 - (SLAVE)
 
+------------------------+------------------------+
| Master                 | Slave                  |
+------------------------+------------------------+
| hostname_lx:3306  | hostname_lx:3406  |
| hostname_lx:3306  | hostname_lx:3506  |
| hostname_lx:3406  | hostname_lx:3306  |
+------------------------+------------------------+

注意:做为slave的instance必须设置report-host和report-port参数,不然master拿不到主备关系。


Post a Comment