March 15, 2022

MySQL mysqlrpladmin utility commands

mysqlrpladmin utility commands in MySQL

mysqlrpladmin is administration utility for MySQL replication

MySQL utility mysqlrpladmin used to perform administrative actions on a database replication topology consisting of a master and its slaves. And used to recover from planned maintenance of the master or unplanned shutdown of master.

mysqlrpladmin --help
mysqlrpladmin --version

Usage: mysqlrpladmin --slaves=root@localhost:3306 command

mysqlrpladmin --master=dbhost1 --discover-slaves-login=dba health;
mysqlrpladmin --master=dbhost2 --discover-slaves-login=root:password health;
mysqlrpladmin --master=dbhost1 --slaves=slave1,dbhost2,myhost1 elect
mysqlrpladmin --master=dbhost1 --discover-slaves-login=root elect
mysqlrpladmin --master=mysqldb1 --slaves=slave1,mysqldb2 stop
mysqlrpladmin --master=dbhost2 --slaves=myhost1,dbhost1 reset

mysqlrpladmin --slaves=slave1,dbhost2,myhost1 --candidates=slave1,dbhost2,myhost1 failover
mysqlrpladmin --force --slaves=slave1,dbhost2,myhost1 --candidates=slave1,dbhost2,myhost1 failover
mysqlrpladmin --master=slave1 --demote-master --new-master=dbhost1 --discover-slaves-login=dba --rpl-user=dbhost1 --verbose --force switchover 
mysqlrpladmin --master=dbhost2 --demote-master --new-master=dbhost1 --discover-slaves-login=dba --rpl-user=dbhost1 --exec-after=/root/cron_scripts/post_failover.sh --verbose switchover

mysqlrpladmin --master=dbhost1 --discover-slaves-login=dba health; mysqlrpladmin --master=dbhost2 --discover-slaves-login=dba health;
mysqlrpladmin --master=root@localhost:13002 --new-master=root@localhost:13001 --discover-slaves-login=root --demote-master --rpl-user=repl:repl --quiet switchover
mysqlrpladmin --master=myhost1 --slaves=myhost2,myhost3 --new-master=myhost2 --demote-master --log=rpl_switchover.log switchover
mysqlrpladmin --master=myhost2 --slaves=myhost1,myhost3 --new-master=myhost3 --exec-before=./make-master-readonly-slave-my2.sh --exec-after=./make-slave-readwrite-master-my3.sh --log=rpl2.log switchover



mysql rpl admin options:
  --version              show program's version number and exit
  --help                display this help message and exit
  --license              display program's license and exit

  --candidates=CANDIDATES   connection information for candidate slave servers for failover in the form:
user[:password]@host[:port][:socket] or login-path[:port][:socket] or config- path[[group]] Valid only with failover command. List multiple slaves in comma-separated list.
  --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.

  --exec-after=EXEC_AFTER name of script to execute after failover or switchover
  --exec-before=EXEC_BEFORE name of script to execute before failover or switchover
  --log=LOG_FILE        specify a log file to use for logging messages
  --log-age=LOG_AGE      specify maximum age of log entries in days. Entries older than this will be purged on startup. Default = 7 days.
  --master=MASTER        connection information for master server in the form: user[:password]@host[:port][:socket] or login-path[:port][:socket] or config- path[[group]].
  --max-position=MAX_POSITION used to detect slave delay. The maximum difference between the master's log position and the slave's reported read position of the master. A value greater than this means the slave is too far behind the master. Default is 0.

  --ping=PING            Number of ping attempts for detecting downed server.
  --seconds-behind=MAX_DELAY used to detect slave delay. The maximum number of seconds behind the master permitted before slave is considered behind the master. Default is 0.
  --slaves=SLAVES        connection information for slave servers in the form: user[:password]@host[:port][:socket] or login-path[:port][:socket] or config- path[[group]]. List multiple slaves in comma- separated list.
  --timeout=TIMEOUT     maximum timeout in seconds to wait for each replication command to complete. For example, timeout for slave waiting to catch up to master. Default = 300.

  --script-threshold=SCRIPT_THRESHOLD Value for external scripts to trigger aborting the operation if result is greater than or equal to the threshold. Default = None (no threshold checking).
  --new-master=NEW_MASTER connection information for the slave to be used to replace the master for switchover, in the form:  user[:password]@host[:port][:socket] or login-path[:port][:socket] or config- path[[group]]. Valid only with switchover command.
  --force              ignore prerequisite check results or some inconsistencies found (e.g. errant transactions on slaves) and execute action
  -f FORMAT, --format=FORMAT display the output in either grid (default), tab, csv, or vertical format

  --demote-master      make master a slave after switchover.
  --no-health            turn off health report after switchover or failover.
  -v, --verbose          control how much information is displayed. e.g., -v = verbose, -vv = more verbose, -vvv = debug
  -q, --quiet            turn off all messages for quiet execution.
  --rpl-user=RPL_USER  the user and password for the replication user requirement, in the form: user[:password] or login-path. E.g. rpl:passwd

  --ssl-ca=SSL_CA        path to a file that contains a list of trusted SSL  CAs.
  --ssl-cert=SSL_CERT   name of the SSL certificate file to use for establishing a secure connection.
  --ssl-key=SSL_KEY     name of the SSL key file to use for establishing a secure connection.
  --ssl=SSL              specifies if the server connection requires use of SSL. If an encrypted connection cannot be established, the connection attempt fails. By default 0 (SSL not required).

Available Commands:
  •   elect        - perform best slave election and report best slave
  •   failover    - conduct failover from master to best slave
  •   gtid        - show status of global transaction id variables  also displays uuids for all servers
  •   health      - display the replication health
  •   reset        - stop and reset all slaves
  •   start        - start all slaves
  •   stop        - stop all slaves
  •   switchover  - perform slave promotion

  Note:
   elect, gtid and health require --master and either --slaves or --discover-slaves-login;
   failover requires --slaves;
   switchover requires --master, --new-master and either --slaves or --discover-slaves-login;
   start, stop and reset require --slaves (and --master is optional)

Related MySQL Articles: mysqlbinlog utility    MySQL mysqlreplicate cheatsheet


No comments:

Post a Comment