1MK-PURGE-LOGS(1) User Contributed Perl Documentation MK-PURGE-LOGS(1)
2
3
4
6 mk-purge-logs - Purge binary logs on a master based on purge rules.
7
9 Usage: mk-purge-logs [OPTION...] DSN
10
11 mk-purge-logs purges binary logs on a MySQL server, based on purge
12 rules.
13
14 Print and purge all unused binary logs on master:
15
16 mk-purge-logs --print --purge h=master
17
18 Silently purge oldest binary logs on master until their total size is
19 less than 1M:
20
21 mk-purge-logs --purge-rules total_size --total-size 1M h=master
22
23 Purge oldest, unused binary logs on master until their total size is
24 less than 500k, print information about work done:
25
26 mk-purge-logs --purge-rules unused,total_size --total-size 500k \
27 --verbose h=master
28
30 The following section is included to inform users about the potential
31 risks, whether known or unknown, of using this tool. The two main
32 categories of risks are those created by the nature of the tool (e.g.
33 read-only tools vs. read-write tools) and those created by bugs.
34
35 mk-purge-logs purges (deletes) binary logs on a master based on
36 "--purge-rules" when "--purge" is specified. Specifying the wrong
37 "--purge-rules" could delete binary logs that are still needed.
38
39 At the time of this release, we know of no bugs that could cause
40 serious harm to users.
41
42 The authoritative source for updated information is always the online
43 issue tracking system. Issues that affect this tool will be marked as
44 such. You can see a list of such issues at the following URL:
45 <http://www.maatkit.org/bugs/mk-purge-logs>.
46
47 See also "BUGS" for more information on filing bugs and getting help.
48
50 mk-purge-logs purges binary logs on a master based on "--purge-rules"
51 by executing "PURGE BINARY LOGS TO".
52
54 Specify at least one of "--purge" or "--print".
55
56 This tool accepts additional command-line arguments. Refer to the
57 "SYNOPSIS" and usage information for details.
58
59 --ask-pass
60 group: Connection
61
62 Prompt for a password when connecting to MySQL.
63
64 --config
65 type: Array
66
67 Read this comma-separated list of config files; if specified, this
68 must be the first option on the command line.
69
70 --defaults-file
71 short form: -F; type: string; group: Connection
72
73 Only read mysql options from the given file. You must give an
74 absolute pathname.
75
76 --dry-run
77 Print but do not execute the "--purge" statement (disables
78 "--purge").
79
80 Specifying this option allows you to test what mk-purge-logs would
81 do if "--purge" were specified without "--dry-run". The SQL
82 statement for "--purge" is printed to STDOUT, like:
83
84 This is a dry-run. The following SQL statement would be executed
85 by specifying --purge without --dry-run:
86 PURGE BINARY LOGS TO ? mysql-bin.000003
87
88 The first line lets you know that "--dry-run" is in effect and the
89 line after it is the SQL statement that would be executed on the
90 server with the "?" replaced by the binary log file name that
91 follows it.
92
93 See also "--print".
94
95 --help
96 Show help and exit.
97
98 --password
99 short form: -p; type: string; group: Connection
100
101 Password to use when connecting.
102
103 --port
104 short form: -P; type: int; group: Connection
105
106 Port number to use for connection.
107
108 --print
109 Print which binary logs "--purge" will purge.
110
111 This option prints each binary log file name and its size to STDOUT
112 that would be purged if all the "--purge-rules" pass and "--purge"
113 is specified. Purging uses the MySQL "PURGE BINARY LOGS TO"
114 command which only specifies the binary log file name to purge to,
115 not the binary logs before it. This option will print the binary
116 logs before the purge to binary log.
117
118 See also "--dry-run".
119
120 --purge
121 Purge (delete) binary logs that match all "--purge-rules". The
122 server's master binary logs are purged using "PURGE BINARY LOGS"
123 when this option is specified and all "--purge-rules" pass. Else,
124 no binary logs are purged.
125
126 Specify "--print" to see which binary logs are purged and their
127 sizes, else all binary logs are purged silently unless there is an
128 error.
129
130 See also "--dry-run".
131
132 --purge-rules
133 type: Hash; default: unused
134
135 Match binary logs that pass all of the specified rules. The rules
136 are mutually inclusive, so only binary logs that pass all rules are
137 purged.
138
139 Some rules, like "total_size", require an extra option to specify
140 their value.
141
142 • total_size
143
144 Purge oldest binary logs until the total size of all binary
145 logs is less than "--total-size". "SHOW BINARY LOGS" lists the
146 size of each binary log. If the total of these sizes is
147 greater than "--total-size", then the oldest binary logs are
148 purged until the total size is less than or equal to
149 "--total-size".
150
151 • unused
152
153 Purge binary logs that are no longer being read by any slaves.
154 When this rule is specified, mk-purge-logs will recurse to the
155 server's first-level slaves (i.e. only direct slaves of the
156 server) and "SHOW SLAVE STATUS" to find which master binary
157 logs they are reading. Master binary logs not being read by
158 any slaves are unused and will be purged.
159
160 --recursion-method
161 type: string
162
163 Preferred recursion method for discovering slaves.
164
165 Possible methods are:
166
167 METHOD USES
168 =========== ================
169 processlist SHOW PROCESSLIST
170 hosts SHOW SLAVE HOSTS
171
172 The processlist method is preferred because SHOW SLAVE HOSTS is not
173 reliable. However, the hosts method is required if the server uses
174 a non-standard port (not 3306). Usually mk-purge-logs does the
175 right thing and finds the slaves, but you may give a preferred
176 method and it will be used first. If it doesn't find any slaves,
177 the other methods will be tried.
178
179 --set-vars
180 type: string; default: wait_timeout=10000; group: Connection
181
182 Set these MySQL variables. Immediately after connecting to MySQL,
183 this string will be appended to SET and executed.
184
185 --socket
186 short form: -S; type: string; group: Connection
187
188 Socket file to use for connection.
189
190 --total-size
191 type: size
192
193 Purge oldest binary logs until their total size is less than this
194 amount.
195
196 This option specifies the value for the "--purge-rules"
197 "total_size" value.
198
199 --user
200 short form: -u; type: string; group: Connection
201
202 User for login if not current user.
203
204 --verbose
205 short form: -v; default: 0
206
207 Print information about binary logs found and purged. By default
208 mk-purge-logs operates silently, except for errors which are
209 printed to STDERR. Specifying this option prints extra information
210 to STDOUT about what the tool is doing.
211
212 --version
213 Show version and exit.
214
216 These DSN options are used to create a DSN. Each option is given like
217 "option=value". The options are case-sensitive, so P and p are not the
218 same option. There cannot be whitespace before or after the "=" and if
219 the value contains whitespace it must be quoted. DSN options are
220 comma-separated. See the maatkit manpage for full details.
221
222 • A
223
224 dsn: charset; copy: yes
225
226 Default character set.
227
228 • D
229
230 dsn: database; copy: yes
231
232 Default database.
233
234 • F
235
236 dsn: mysql_read_default_file; copy: yes
237
238 Only read default options from the given file
239
240 • h
241
242 dsn: host; copy: yes
243
244 Connect to host.
245
246 • p
247
248 dsn: password; copy: yes
249
250 Password to use when connecting.
251
252 • P
253
254 dsn: port; copy: yes
255
256 Port number to use for connection.
257
258 • S
259
260 dsn: mysql_socket; copy: yes
261
262 Socket file to use for connection.
263
264 • u
265
266 dsn: user; copy: yes
267
268 User for login if not current user.
269
271 You can download Maatkit from Google Code at
272 <http://code.google.com/p/maatkit/>, or you can get any of the tools
273 easily with a command like the following:
274
275 wget http://www.maatkit.org/get/toolname
276 or
277 wget http://www.maatkit.org/trunk/toolname
278
279 Where "toolname" can be replaced with the name (or fragment of a name)
280 of any of the Maatkit tools. Once downloaded, they're ready to run; no
281 installation is needed. The first URL gets the latest released version
282 of the tool, and the second gets the latest trunk code from Subversion.
283
285 The environment variable "MKDEBUG" enables verbose debugging output in
286 all of the Maatkit tools:
287
288 MKDEBUG=1 mk-....
289
291 You need Perl, DBI, DBD::mysql, and some core packages that ought to be
292 installed in any reasonably new version of Perl.
293
295 For a list of known bugs see
296 <http://www.maatkit.org/bugs/mk-purge-logs>.
297
298 Please use Google Code Issues and Groups to report bugs or request
299 support: <http://code.google.com/p/maatkit/>. You can also join
300 #maatkit on Freenode to discuss Maatkit.
301
302 Please include the complete command-line used to reproduce the problem
303 you are seeing, the version of all MySQL servers involved, the complete
304 output of the tool when run with "--version", and if possible,
305 debugging output produced by running with the "MKDEBUG=1" environment
306 variable.
307
309 This program is copyright 2010-2011 Percona Inc. Feedback and
310 improvements are welcome.
311
312 THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
313 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
314 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
315
316 This program is free software; you can redistribute it and/or modify it
317 under the terms of the GNU General Public License as published by the
318 Free Software Foundation, version 2; OR the Perl Artistic License. On
319 UNIX and similar systems, you can issue `man perlgpl' or `man
320 perlartistic' to read these licenses.
321
322 You should have received a copy of the GNU General Public License along
323 with this program; if not, write to the Free Software Foundation, Inc.,
324 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
325
327 Daniel Nichter, Baron Schwartz
328
330 This tool is part of Maatkit, a toolkit for power users of MySQL.
331 Maatkit was created by Baron Schwartz; Baron and Daniel Nichter are the
332 primary code contributors. Both are employed by Percona. Financial
333 support for Maatkit development is primarily provided by Percona and
334 its clients.
335
337 This manual page documents Ver 0.9.0 Distrib 7540 $Revision: 7531 $.
338
339
340
341perl v5.34.0 2021-07-22 MK-PURGE-LOGS(1)