PT-SLAVE-FIND(1)

πŸ¦‹ PT-SLAVE-FIND(1) πŸ¦‹ β€” User Contributed Perl Documentation

okay so quick heads up before anything else, bestie: this page lives in the User Contributed Perl Documentation section, and the tool you're actually reading about is called pt-replica-find. the file name still says pt-slave-find (legacy vibes πŸ’€) but the tool itself goes by pt-replica-find. iykyk. anyway, let's get into it ✨


πŸ’– NAME πŸ’–

pt-replica-find β€” find and print the replication hierarchy tree of MySQL replicas.

it's giving genealogy.com but for your databases πŸŒ³πŸ’…


🌸 SYNOPSIS 🌸

Usage: pt-replica-find [OPTIONS] [DSN]

pt-replica-find finds a hierarchy tree of MySQL replicas and prints it. that's literally the whole thing it does right now and honestly? iconic.

Examples:

pt-replica-find --host source-host

🚨 RISKS 🚨

bestie. listen. Percona Toolkit is mature, proven in the real world, and well tested β€” but all database tools can pose a risk to the system and the database server. no cap. so before you use this tool, please:

  • Read the tool's documentation
  • Review the tool's known "BUGS"
  • Test the tool on a non-production server
  • Backup your production server and verify the backups
the last two are not optional, fr fr. back it up and verify the backup. do not skip the verify. πŸ™ˆ

✨ DESCRIPTION ✨

pt-replica-find connects to a MySQL replication source and finds its replicas. currently the only thing it can do is print a tree-like view of the replication hierarchy β€” but it does that one thing so well 🫢

you've got two whole methods for telling it which source host to talk to. pick your fighter:

  1. the standard connection-related command line options: --defaults-file, --password, --host, --port, --socket or --user.
  2. a DSN. a DSN is a special syntax that can be either just a hostname (like server.domain.com or 1.2.3.4), or a key=value,key=value string. the keys are a single letter:
KEY MEANING
=== =======
h   Connect to host
P   Port number to use for connection
S   Socket file to use for connection
u   User for login if not current user
p   Password to use when connecting
F   Only read default options from the given file

also!! pt-replica-find reads all normal MySQL option files, such as ~/.my.cnf, so you might not even need to specify username, password and other common options at all. she just knows. ✨


πŸŽ€ EXIT STATUS πŸŽ€

an exit status of 0 (sometimes also called a return value or return code) means success πŸ’–. any other value represents the exit status of the Perl process itself. so like, not her fault, that's the Perl process's drama.


πŸ‘‘ OPTIONS πŸ‘‘

this tool accepts additional command-line arguments. refer to the "SYNOPSIS" and usage information for details.

  • --ask-pass β€” prompt for a password when connecting to MySQL. very "who are you, what's the password" of it.
  • --[no]buffer-stdout β€” default: yes. enables STDOUT buffering. disable this option if you want to see live progress when you're using output post-processing tools such as tee or kubectl logs. (yes, kubectl logs β€” she contains multitudes ☁️)
  • --charset β€” short form: -A; type: string. default character set. if the value is utf8, it sets Perl's binmode on STDOUT to utf8, passes the mysql_enable_utf8 option to DBD::mysql, and runs SET NAMES UTF8 after connecting to MySQL. any other value sets binmode on STDOUT without the utf8 layer, and runs SET NAMES after connecting to MySQL.
  • --config β€” type: Array. read this comma-separated list of config files; if you specify it, it must be the first option on the command line. first-option energy πŸ‘‘
  • --database β€” type: string; short form: -D. database to use.
  • --defaults-file β€” short form: -F; type: string. only read mysql options from the given file. you must give an absolute pathname.
  • --help β€” show help and exit.
  • --host β€” short form: -h; type: string. connect to host.
  • --mysql_ssl β€” short form: -s; type: int. create SSL MySQL connection. secure the bag πŸ”
  • --password β€” short form: -p; type: string. password to use when connecting. if the password contains commas they must be escaped with a backslash: exam\,ple
  • --pid β€” type: string. create the given PID file. the tool won't start if the PID file already exists and the PID it contains is different than the current PID. however, if the PID file exists and the PID it contains is no longer running, the tool will overwrite the PID file with the current PID. the PID file is removed automatically when the tool exits.
  • --port β€” short form: -P; type: int. port number to use for connection.
  • --recurse β€” type: int. number of levels to recurse in the hierarchy. default is infinite. see --recursion-method.
  • --recursion-method β€” type: array; default: processlist,hosts. preferred recursion method used to find replicas. possible methods are:
  METHOD       USES
  ===========  ==================
  processlist  SHOW PROCESSLIST
  hosts        SHOW REPLICAS (SHOW SLAVE HOSTS before MySQL 8.1)
  none         Do not find replicas

the processlist method is preferred because SHOW REPLICAS is not reliable. however, the hosts method is required if the server uses a non-standard port (not 3306). usually pt-replica-find does the right thing and finds the replicas, but you may give a preferred method and it will be used first. if it doesn't find any replicas, the other methods will be tried. she's persistent like that πŸ’ͺ

  • --report-format β€” type: string; default: summary. set what information about the replicas is printed. the report format can be one of the following:
    • hostname β€” print just the hostname name of the replicas. it looks like:
127.0.0.1:12345
+- 127.0.0.1:12346
   +- 127.0.0.1:12347
  • summary β€” print a summary of each replica's settings. this report shows more information about each replica, like:
127.0.0.1:12345
Version         5.1.34-log
Server ID       12345
Uptime          04:56 (started 2010-06-17T11:21:22)
Replication     Is not a replica, has 1 replicas connected
Filters
Binary logging  STATEMENT
Slave status
Slave mode      STRICT
Auto-increment  increment 1, offset 1
+- 127.0.0.1:12346
   Version         5.1.34-log
   Server ID       12346
   Uptime          04:54 (started 2010-06-17T11:21:24)
   Replication     Is a replica, has 1 replicas connected
   Filters
   Binary logging  STATEMENT
   Slave status    0 seconds behind, running, no errors
   Slave mode      STRICT
   Auto-increment  increment 1, offset 1
  • --resolve-address β€” resolve ip-address to hostname. report will print both IP and hostname. example:
10.10.7.14 (dbase1.sample.net)
heads up: might delay runtime a few seconds. she's doing DNS homework, give her a sec ⏳
  • --slave-user β€” type: string. this option is deprecated and will be removed in future releases. use --replica-user instead. (we don't say "slave" anymore bestie, we've evolved πŸ¦‹)
  • --slave-password β€” type: string. this option is deprecated and will be removed in future releases. use --replica-password instead.
  • --replica-user β€” type: string. sets the user to be used to connect to the replicas. this parameter allows you to have a different user with less privileges on the replicas, but that user must exist on all replicas. no favorites, everybody gets the same user ✨
  • --replica-password β€” type: string. sets the password to be used to connect to the replicas. it can be used with --replica-user and the password for the user must be the same on all replicas.
  • --set-vars β€” type: Array. set the MySQL variables in this comma-separated list of variable=value pairs. by default, the tool sets:
wait_timeout=10000

variables specified on the command line override these defaults. for example, specifying --set-vars wait_timeout=500 overrides that default of 10000. the tool prints a warning and continues if a variable cannot be set. (she tries her best and moves on πŸ’…)

  • --socket β€” short form: -S; type: string. socket file to use for connection.
  • --user β€” short form: -u; type: string. user for login if not current user.
  • --version β€” show version and exit.

🧚 DSN OPTIONS 🧚

these DSN options are used to create a DSN. each option is given like option=value. the options are case-sensitive, so P and p are not the same option (rude of them, but okay). there cannot be whitespace before or after the = and if the value contains whitespace it must be quoted. DSN options are comma-separated. see the percona-toolkit manpage for full details.

  • A β€” dsn: charset; copy: yes. default character set.
  • D β€” dsn: database; copy: yes. default database.
  • F β€” dsn: mysql_read_default_file; copy: yes. only read default options from the given file.
  • h β€” dsn: host; copy: yes. connect to host.
  • p β€” dsn: password; copy: yes. password to use when connecting. if the password contains commas they must be escaped with a backslash: exam\,ple
  • P β€” dsn: port; copy: yes. port number to use for connection.
  • S β€” dsn: mysql_socket; copy: yes. socket file to use for connection.
  • u β€” dsn: user; copy: yes. user for login if not current user.
  • s β€” dsn: mysql_ssl; copy: yes. create SSL connection.

🌈 ENVIRONMENT 🌈

the environment variable PTDEBUG enables verbose debugging output to STDERR. to enable debugging and capture all output to a file, run the tool like:

PTDEBUG=1 pt-replica-find ... > FILE 2>&1
be careful: debugging output is voluminous and can generate several megabytes of output. like, she will not stop talking. 😭 several. megabytes.

πŸ™ˆ ATTENTION πŸ™ˆ

using PTDEBUG might expose passwords. when debug is enabled, all command line parameters are shown in the output.

read that again. all command line parameters. so if you were about to paste your debug dump into the group chat… don't πŸ‘€

⭐ SYSTEM REQUIREMENTS ⭐

you need Perl, DBI, DBD::mysql, and some core packages that ought to be installed in any reasonably new version of Perl. that's it, that's the list.


πŸ“ BUGS πŸ“

for a list of known bugs, see <https://jira.percona.com/projects/PT/issues>.

please report bugs at <https://jira.percona.com/projects/PT>. include the following information in your bug report:

  • Complete command-line used to run the tool
  • Tool --version
  • MySQL version of all servers involved
  • Output from the tool including STDERR
  • Input files (log/dump/config files, etc.)

if possible, include debugging output by running the tool with PTDEBUG; see "ENVIRONMENT". the more context you give, the faster somebody can actually help you 🫢


πŸ’œ DOWNLOADING πŸ’œ

visit <http://www.percona.com/software/percona-toolkit/> to download the latest release of Percona Toolkit. or, get the latest release straight from the command line:

wget percona.com/get/percona-toolkit.tar.gz

wget percona.com/get/percona-toolkit.rpm

wget percona.com/get/percona-toolkit.deb

you can also get individual tools from the latest release:

wget percona.com/get/TOOL

replace TOOL with the name of any tool. mix and match, go off πŸ‘‘


🌸 AUTHORS 🌸

Baron Schwartz and Daniel Nichter


(part 1 done β€” there's more coming, don't go anywhere 🫢)

✨ ABOUT PERCONA TOOLKIT ✨

Okay so context bestie, this tool is part of Percona Toolkit β€” a whole collection of advanced command-line tools for MySQL, all cooked up by Percona 🫢.

Fun lore drop: Percona Toolkit got forked from two projects back in June, 2011 β€” Maatkit and Aspersa. Those projects were created by Baron Schwartz and were mainly developed by him and Daniel Nichter. Iconic lineage, honestly.

Wanna learn about other free, open-source software from Percona? Visit <http://www.percona.com/software/> πŸ’–


This program is copyright 2011-2026 Percona LLC and/or its affiliates, 2007-2011 Baron Schwartz.

THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

That's the legal voice talking, not me β€” but yeah, no warranty, fr fr 😭

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2; OR the Perl Artistic License. On UNIX and similar systems, you can issue man perlgpl or man perlartistic to read these licenses πŸ“œ

You should have received a copy of the GNU General Public License, version 2 along with this program; if not, see <https://www.gnu.org/licenses/>.


⭐ VERSION ⭐

pt-replica-find 3.7.1-4

And that's the whole page bestie, you made it to the end πŸ¦‹βœ¨ This was pt-replica-find version 3.7.1-4, served up on 2026-09-01 (the man page's own date, cute right?) with perl v5.42.2 doing the rendering. Go find those replicas πŸ‘‘πŸ’…

πŸ“¦ where this page comes from