'\" t
.\" Title: \fBmysqlbinlogpurge\fR
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.79.1
.\" Date: 08/01/2016
.\" Manual: MySQL Utilities
.\" Source: MySQL 1.6.3
.\" Language: English
.\"
.TH "\FBMYSQLBINLOGPURGE\" "1" "08/01/2016" "MySQL 1\&.6\&.3" "MySQL Utilities"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
mysqlbinlogpurge \- Binary log purge utility
.SH "SYNOPSIS"
.HP \w'\fBmysqlbinlogpurge\ [\fR\fB\fIoptions\fR\fR\fB]\ \fR\fB\fImaster\fR\fR\fB\ \fR\fB\fIslaves\fR\fR\ 'u
\fBmysqlbinlogpurge [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fImaster\fR\fR\fB \fR\fB\fIslaves\fR\fR
.SH "DESCRIPTION"
.PP
This utility enables you to safely purge (delete) binary logs by ensuring that any files which are in use or required by any of the slaves in a replication topology are not deleted\&. This is achieved by checking which binary logs have been read on each slave\&. This determines the minimal set of binary log files that can be purged\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
.PP
In order to determine which binary logs can be purged,
\fBmysqlbinlogpurge\fR
connects to the master\&. If the specified server is not the active master,
\fBmysqlbinlogpurge\fR
cannot determine which binary logs are still needed by the slaves\&.
.sp .5v
.RE
.PP
You must provide the master\*(Aqs connection parameters with the
\fB\-\-master\fR
option and each slave\*(Aqs connection parameters with the
\fB\-\-slaves\fR
option\&. Alternatively, use the
\fB\-\-discover\-slaves\-login\fR
option configured with the user name and password to connect to the slaves\&. In case the server is not a master, you must provide the connection parameters with the
\fB\-\-server\fR
option\&.
.PP
\fBmysqlbinlogpurge\fR
attempts to determine the binary logs to purge by logging in to each server\&. If a slave is not actively participating in a replication topology,
\fBmysqlbinlogpurge\fR
does not purge any logs\&.
.PP
By default,
\fBmysqlbinlogpurge\fR
purges all the binary log files that are not in use\&. Use the
\fB\-\-binlog\fR
option to override this behavior and configure the first binary log file to not purge\&.
.PP
\fBmysqlbinlogpurge\fR
displays the list of binary log files that were purged\&. Use the
\fB\-\-verbose\fR
option to see a list of the remaining available binary log files on the server and to display additional information when
\fBmysqlbinlogpurge\fR
executes, such as status of the I/O and SQL threads of each slave\&.
OPTIONS.PP
\fBmysqlbinlogpurge\fR
provides the following command\-line options:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-version
.sp
Show the program\*(Aqs version number\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-help
.sp
Display the help message\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-server=
.sp
Connection information for the server\&.
.sp
To connect to a server, it is necessary to specify connection parameters such as the user name, host name, password, and either a port or socket\&. MySQL Utilities provides a number of ways to supply this information\&. All of the methods require specifying your choice via a command\-line option such as \-\-server, \-\-master, \-\-slave, etc\&. The methods include the following in order of most secure to least secure\&.
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Use login\-paths from your
\&.mylogin\&.cnf
file (encrypted, not visible)\&. Example : <\fIlogin\-path\fR>[:<\fIport\fR>][:<\fIsocket\fR>]
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Use a configuration file (unencrypted, not visible) Note: available in release\-1\&.5\&.0\&. Example : <\fIconfiguration\-file\-path\fR>[:<\fIsection\fR>]
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Specify the data on the command\-line (unencrypted, visible)\&. Example : <\fIuser\fR>[:<\fIpasswd\fR>]@<\fIhost\fR>[:<\fIport\fR>][:<\fIsocket\fR>]
.RE
.sp
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-ssl
.sp
Specifies if the server connection requires SSL\&. If an encrypted connection cannot be established, the connection attempt fails\&. By default set to 0, indicating that SSL is not required\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-ssl\-ca
.sp
The path to a file that contains a list of trusted SSL certificate authorities\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-ssl\-cert
.sp
The name of the SSL certificate file to use for establishing a secure connection\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-ssl\-key
.sp
The name of the SSL key file to use for establishing a secure connection\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-binlog=
.sp
Binary log filename to not to purge\&. All the binary log files prior to the specified file are removed\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-dry\-run
.sp
Run
\fBmysqlbinlogpurge\fR
without purging any binary log files, instead displaying a list of the unused binary log files which would be purged\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-discover\-slaves\-login=
.sp
Supply a user name and password, in the form [:] or , used for discovering slaves and relay slaves in the replication topology\&. For example, \-\-discover=joe:secret uses \*(Aqjoe\*(Aq as the user name and \*(Aqsecret\*(Aq as the password for attempting to log in to each discovered slave\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-slaves=
.sp
Connection information for slave servers\&. List multiple slaves in a comma\-separated list\&. The list is evaluated literally, where each server is considered a slave of the master listed\&. Thus, all servers specified in this option must be slaves of the current master\&.
.sp
To connect to a server, it is necessary to specify connection parameters such as the user name, host name, password, and either a port or socket\&. MySQL Utilities provides a number of ways to supply this information\&. All of the methods require specifying your choice via a command\-line option such as \-\-server, \-\-master, \-\-slave, etc\&. The methods include the following in order of most secure to least secure\&.
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Use login\-paths from your
\&.mylogin\&.cnf
file (encrypted, not visible)\&. Example : <\fIlogin\-path\fR>[:<\fIport\fR>][:<\fIsocket\fR>]
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Use a configuration file (unencrypted, not visible) Note: available in release\-1\&.5\&.0\&. Example : <\fIconfiguration\-file\-path\fR>[:<\fIsection\fR>]
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Specify the data on the command\-line (unencrypted, visible)\&. Example : <\fIuser\fR>[:<\fIpasswd\fR>]@<\fIhost\fR>[:<\fIport\fR>][:<\fIsocket\fR>]
.RE
.sp
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-master=
.sp
Connection information for the master server\&.
.sp
To connect to a server, it is necessary to specify connection parameters such as the user name, host name, password, and either a port or socket\&. MySQL Utilities provides a number of ways to supply this information\&. All of the methods require specifying your choice via a command\-line option such as \-\-server, \-\-master, \-\-slave, etc\&. The methods include the following in order of most secure to least secure\&.
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Use login\-paths from your
\&.mylogin\&.cnf
file (encrypted, not visible)\&. Example : <\fIlogin\-path\fR>[:<\fIport\fR>][:<\fIsocket\fR>]
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Use a configuration file (unencrypted, not visible) Note: available in release\-1\&.5\&.0\&. Example : <\fIconfiguration\-file\-path\fR>[:<\fIsection\fR>]
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Specify the data on the command\-line (unencrypted, visible)\&. Example : <\fIuser\fR>[:<\fIpasswd\fR>]@<\fIhost\fR>[:<\fIport\fR>][:<\fIsocket\fR>]
.RE
.sp
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-verbose, \-v
.sp
Specify how much information to display\&. Use this option multiple times to increase the amount of information\&. For example,
\fB\-v\fR
is verbose,
\fB\-vv\fR
is more verbose,
\fB\-vvv\fR
is debug level\&.
.RE
NOTES.PP
If the server specified using the
\fB\-\-server\fR
option is a master server and there are slaves connected,
\fBmysqlbinlogpurge\fR
displays an error and does not purge the binary logs that match the criteria specified\&.
LIMITATIONS.PP
\fBmysqlbinlogpurge\fR
cannot verify slaves that are not actively replicating and will stop and show an error if it finds a slave which is not actively replicating from the master\&.
EXAMPLES.PP
Purge all binary log files not in use from a master, specifying the slaves to check:
.sp
.if n \{\
.RS 4
.\}
.nf
shell> \fBmysqlbinlogpurge \-\-master=root:root@localhost:3310 \e\fR
\fB\-\-slaves=root:root@localhost:3311,root:root@localhost:3312,root:root@localhost:3313 \e\fR
\fB\-vv\fR
exec_util command=python \-u \&.\&./scripts/mysqlbinlogpurge\&.py \-\-master=root:root@localhost:3310 \-\-slaves=root:root@localhost:3311,root:root@localhost:33
12,root:root@localhost:3313 \-vv
# Checking user permission to purge binary logs\&.\&.\&.
#
# Master active binlog file: mysql\-bin\&.000021
# Checking slave: localhost@3311
# I/O thread is currently reading: mysql\-bin\&.000021
# File position of the I/O thread: 120
# Master binlog file with last event executed by the SQL thread: mysql\-bin\&.000021
# I/O thread running: Yes
# SQL thread running: Yes
# Checking slave: localhost@3312
# I/O thread is currently reading: mysql\-bin\&.000021
# File position of the I/O thread: 120
# Master binlog file with last event executed by the SQL thread: mysql\-bin\&.000021
# I/O thread running: Yes
# SQL thread running: Yes
# Checking slave: localhost@3313
# I/O thread is currently reading: mysql\-bin\&.000021
# File position of the I/O thread: 120
# Master binlog file with last event executed by the SQL thread: mysql\-bin\&.000021
# I/O thread running: Yes
# SQL thread running: Yes
# Range of binlog files available: from mysql\-bin\&.000016 to mysql\-bin\&.000021
# Latest binlog file replicated by all slaves: mysql\-bin\&.000020
# Latest not active binlog file: mysql\-bin\&.000020
# Executing query PURGE BINARY LOGS TO \*(Aqmysql\-bin\&.000021\*(Aq
# Binlog file available: mysql\-bin\&.000021
# Range of binlog files purged: from mysql\-bin\&.000016 to mysql\-bin\&.000020
.fi
.if n \{\
.RE
.\}
.PP
Purge all binary log files not in use prior to a specific binary log file:
.sp
.if n \{\
.RS 4
.\}
.nf
shell> \fBmysqlbinlogpurge \-\-master=root:root@localhost:3310 \e\fR
\fB\-\-slaves=root:root@localhost:3311,root:root@localhost:3312,root:root@localhost:3313 \e\fR
\fB\-\-binlog=mysql\-bin\&.000027 \-v\fR
# Checking user permission to purge binary logs\&.\&.\&.
#
# Master active binlog file: mysql\-bin\&.000031
# Checking slave: localhost@3311
# I/O thread is currently reading: mysql\-bin\&.000031
# Checking slave: localhost@3312
# I/O thread is currently reading: mysql\-bin\&.000031
# Checking slave: localhost@3313
# I/O thread is currently reading: mysql\-bin\&.000031
# Range of binlog files available: from mysql\-bin\&.000023 to mysql\-bin\&.000031
# Latest binlog file replicated by all slaves: mysql\-bin\&.000030
# Purging binary logs prior to \*(Aqmysql\-bin\&.000027\*(Aq
# Range of binlog files available: from mysql\-bin\&.000027 to mysql\-bin\&.000031
# Range of binlog files purged: from mysql\-bin\&.000023 to mysql\-bin\&.000026
.fi
.if n \{\
.RE
.\}
.PP
Display a query statement you could use to manually purge all binary log files not in use from a server, without actually purging them by using the \-\-dry\-run option:
.sp
.if n \{\
.RS 4
.\}
.nf
shell> \fBmysqlbinlogpurge \-\-server=root:root@localhost:3310 \-\-dry\-run\fR
# To manually purge purge the binary logs Execute the following query:
PURGE BINARY LOGS TO \*(Aqmysql\-bin\&.000004\*(Aq
.fi
.if n \{\
.RE
.\}
.sp
PERMISSIONS REQUIRED.PP
By default, the user name you specified to connect to the server must have SUPER and REPLICATION SLAVE permissions to be able to purge the binary logs\&.
.SH "COPYRIGHT"
.br
.PP
Copyright \(co 2006, 2016, Oracle and/or its affiliates. All rights reserved.
.PP
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
.PP
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
.PP
You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/.
.sp
.SH "SEE ALSO"
For more information, please refer to the MySQL Utilities and Fabric
documentation, which is available online at
http://dev.mysql.com/doc/index-utils-fabric.html
.SH AUTHOR
Oracle Corporation (http://dev.mysql.com/).