oak-show-replication-status
NAME
oak-show-replication-status: show how far behind are replicating slaves on a given masterSYNOPSIS
Show the replication status on the localhost machine:oak-show-replication-statusShow the replication status on a given master database:
oak-show-replication-status --host=192.168.2.103Show the replication status on a given master database, expect two slaves:
oak-show-replication-status --host=192.168.2.103 --expect-num-slaves=2Show the replication status on a given master database, expect two slaves, consider 20 seconds lag to be normal delay:
oak-show-replication-status --host=192.168.2.103 -n 2 --normal-delay=20Same as above, provide connection parameters, prompt for password:
oak-show-replication-status --host=192.168.2.103 --user=root --ask-pass --socket=/tmp/mysql.sock -n 2 -d 20Same as above, use defaults file:
oak-show-replication-status --defaults-file=/home/myuser/.my-oak.cnf -n 2 -d 20
DESCRIPTION
oak-show-replication-status outputs a short report which diagnoses how far behind a given master are its slaves. The utility connects to a master server, reads the master status, locates the active slaves, connects to those slaves, and reads their slave status. The utility considers a "normal delay behind the master" and reports the following:- The current master logs file
- If any slaves are missing (see --expect-num-slaves), an error message
- For each connected slave: its master log file, seconds behind master and status.
- "Good": the slave is up to date with the master: it is less than "--normal-delay" behind master.
- "Lag": the slave is more than "--normal-delay" behind master, but is up to date with latest binary log.
- "Far behind": the slave is more than "--normal-delay" behind master, and is not even up to date with latest binary log.
The binary log considered is the last one fetched by the slave (and is not necessarily processed yet). oak-show-replication-status does not act recursively. If one of the slaves is itself a master, the utility does not check up on its slaves.-- master log: mymaster-bin.001761 -- Slave host Master_Log_File Seconds_Behind_Master Status -- myslave1 mymaster-bin.001761 0 Good -- myslave2 mymaster-bin.001761 0 Good
OPTIONS
--ask-passPrompt for password.
-d NORMAL_DELAY, --normal-delay=NORMAL_DELAYAcceptable seconds behind master. A slave lagging behind less than give number is considered to be in "Good" state.
--defaults-file=DEFAULTS_FILERead from MySQL configuration file. Overrides --user, --password, --socket, --port.
Configuration needs to be in the following format:
[client]
user=my_user
password=my_pass
socket=/tmp/mysql.sock
port=3306
MySQL master host (default: localhost)
-n EXPECT_NUM_SLAVES, --expect-num-slaves=EXPECT_NUM_SLAVESNumber of slaves to expect (default: 0). If less than given number slaves can be found, and error message is written.
-p PASSWORD, --password=PASSWORDMySQL password. The same password is expected to apply for the master and the slaves.
-P PORT, --port=PORTTCP/IP port (default: 3306)
--skip-show-slave-hostsWhen SHOW SLAVE HOSTS returns rows, these are considered the only slave hosts. Otherwise slaves are found looking at SHOW PROCESSLIST. With --skip-show-slave-hosts, only SHOW PROCESSLIST is used.
-S SOCKET, --socket=SOCKETMySQL socket file. Only applies when host is localhost
-u USER, --user=USERMySQL user. The same user is expected to apply for the master and the slaves.
ENVIRONMENT
Requires MySQL 5.0 or newer, python 2.3 or newer. python-mysqldb must be installed in order to use this tool. You canapt-get install python-mysqldbor
yum install mysql-python
SEE ALSO
oak-purge-master-logs
oak-get-slave-lag
LICENSE
This tool is released under the BSD license.Copyright (c) 2008 - 2010, Shlomi Noach All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.