1MK-SLAVE-DELAY(1) User Contributed Perl Documentation MK-SLAVE-DELAY(1)
2
3
4
6 mk-slave-delay - Make a MySQL slave server lag behind its master.
7
9 Usage: mk-slave-delay [OPTION...] SLAVE-HOST [MASTER-HOST]
10
11 mk-slave-delay starts and stops a slave server as needed to make it lag
12 behind the master. The SLAVE-HOST and MASTER-HOST use DSN syntax, and
13 values are copied from the SLAVE-HOST to the MASTER-HOST if omitted.
14
15 To hold slavehost one minute behind its master for ten minutes:
16
17 mk-slave-delay --delay 1m --interval 15s --run-time 10m slavehost
18
20 The following section is included to inform users about the potential
21 risks, whether known or unknown, of using this tool. The two main
22 categories of risks are those created by the nature of the tool (e.g.
23 read-only tools vs. read-write tools) and those created by bugs.
24
25 mk-slave-delay is generally very low-risk. It simply starts and stops
26 the replication SQL thread. This might cause monitoring systems to
27 think the slave is having trouble.
28
29 At the time of this release, we know of no bugs that could cause
30 serious harm to users.
31
32 The authoritative source for updated information is always the online
33 issue tracking system. Issues that affect this tool will be marked as
34 such. You can see a list of such issues at the following URL:
35 <http://www.maatkit.org/bugs/mk-slave-delay>.
36
37 See also "BUGS" for more information on filing bugs and getting help.
38
40 "mk-slave-delay" watches a slave and starts and stops its replication
41 SQL thread as necessary to hold it at least as far behind the master as
42 you request. In practice, it will typically cause the slave to lag
43 between "--delay" and "--delay"+"--interval" behind the master.
44
45 It bases the delay on binlog positions in the slave's relay logs by
46 default, so there is no need to connect to the master. This works well
47 if the IO thread doesn't lag the master much, which is typical in most
48 replication setups; the IO thread lag is usually milliseconds on a fast
49 network. If your IO thread's lag is too large for your purposes,
50 "mk-slave-delay" can also connect to the master for information about
51 binlog positions.
52
53 If the slave's I/O thread reports that it is waiting for the SQL thread
54 to free some relay log space, "mk-slave-delay" will automatically
55 connect to the master to find binary log positions. If "--ask-pass"
56 and "--daemonize" are given, it is possible that this could cause it to
57 ask for a password while daemonized. In this case, it exits.
58 Therefore, if you think your slave might encounter this condition, you
59 should be sure to either specify "--use-master" explicitly when
60 daemonizing, or don't specify "--ask-pass".
61
62 The SLAVE-HOST and optional MASTER-HOST are both DSNs. See "DSN
63 OPTIONS". Missing MASTER-HOST values are filled in with values from
64 SLAVE-HOST, so you don't need to specify them in both places.
65 "mk-slave-delay" reads all normal MySQL option files, such as
66 ~/.my.cnf, so you may not need to specify username, password and other
67 common options at all.
68
69 "mk-slave-delay" tries to exit gracefully by trapping signals such as
70 Ctrl-C. You cannot bypass "--[no]continue" with a trappable signal.
71
73 mk-slave-delay requires the following privileges: PROCESS, REPLICATION
74 CLIENT, and SUPER.
75
77 If you specify "--quiet", there is no output. Otherwise, the normal
78 output is a status message consisting of a timestamp and information
79 about what "mk-slave-delay" is doing: starting the slave, stopping the
80 slave, or just observing.
81
83 This tool accepts additional command-line arguments. Refer to the
84 "SYNOPSIS" and usage information for details.
85
86 --ask-pass
87 Prompt for a password when connecting to MySQL.
88
89 --charset
90 short form: -A; type: string
91
92 Default character set. If the value is utf8, sets Perl's binmode
93 on STDOUT to utf8, passes the mysql_enable_utf8 option to
94 DBD::mysql, and runs SET NAMES UTF8 after connecting to MySQL. Any
95 other value sets binmode on STDOUT without the utf8 layer, and runs
96 SET NAMES after connecting to MySQL.
97
98 --config
99 type: Array
100
101 Read this comma-separated list of config files; if specified, this
102 must be the first option on the command line.
103
104 --[no]continue
105 default: yes
106
107 Continue replication normally on exit. After exiting, restart the
108 slave's SQL thread with no UNTIL condition, so it will run as usual
109 and catch up to the master. This is enabled by default and works
110 even if you terminate "mk-slave-delay" with Control-C.
111
112 --daemonize
113 Fork to the background and detach from the shell. POSIX operating
114 systems only.
115
116 --defaults-file
117 short form: -F; type: string
118
119 Only read mysql options from the given file. You must give an
120 absolute pathname.
121
122 --delay
123 type: time; default: 1h
124
125 How far the slave should lag its master.
126
127 --help
128 Show help and exit.
129
130 --host
131 short form: -h; type: string
132
133 Connect to host.
134
135 --interval
136 type: time; default: 1m
137
138 How frequently "mk-slave-delay" should check whether the slave
139 needs to be started or stopped.
140
141 --log
142 type: string
143
144 Print all output to this file when daemonized.
145
146 --password
147 short form: -p; type: string
148
149 Password to use when connecting.
150
151 --pid
152 type: string
153
154 Create the given PID file when daemonized. The file contains the
155 process ID of the daemonized instance. The PID file is removed
156 when the daemonized instance exits. The program checks for the
157 existence of the PID file when starting; if it exists and the
158 process with the matching PID exists, the program exits.
159
160 --port
161 short form: -P; type: int
162
163 Port number to use for connection.
164
165 --quiet
166 short form: -q
167
168 Don't print informational messages about operation. See OUTPUT for
169 details.
170
171 --run-time
172 type: time
173
174 How long "mk-slave-delay" should run before exiting. The default
175 is to run forever.
176
177 --set-vars
178 type: string; default: wait_timeout=10000
179
180 Set these MySQL variables. Immediately after connecting to MySQL,
181 this string will be appended to SET and executed.
182
183 --socket
184 short form: -S; type: string
185
186 Socket file to use for connection.
187
188 --use-master
189 Get binlog positions from master, not slave. Don't trust the
190 binlog positions in the slave's relay log. Connect to the master
191 and get binlog positions instead. If you specify this option
192 without giving a MASTER-HOST on the command line, "mk-slave-delay"
193 examines the slave's SHOW SLAVE STATUS to determine the hostname
194 and port for connecting to the master.
195
196 "mk-slave-delay" uses only the MASTER_HOST and MASTER_PORT values
197 from SHOW SLAVE STATUS for the master connection. It does not use
198 the MASTER_USER value. If you want to specify a different username
199 for the master than the one you use to connect to the slave, you
200 should specify the MASTER-HOST option explicitly on the command
201 line.
202
203 --user
204 short form: -u; type: string
205
206 User for login if not current user.
207
208 --version
209 Show version and exit.
210
212 These DSN options are used to create a DSN. Each option is given like
213 "option=value". The options are case-sensitive, so P and p are not the
214 same option. There cannot be whitespace before or after the "=" and if
215 the value contains whitespace it must be quoted. DSN options are
216 comma-separated. See the maatkit manpage for full details.
217
218 · A
219
220 dsn: charset; copy: yes
221
222 Default character set.
223
224 · D
225
226 dsn: database; copy: yes
227
228 Default database.
229
230 · F
231
232 dsn: mysql_read_default_file; copy: yes
233
234 Only read default options from the given file
235
236 · h
237
238 dsn: host; copy: yes
239
240 Connect to host.
241
242 · p
243
244 dsn: password; copy: yes
245
246 Password to use when connecting.
247
248 · P
249
250 dsn: port; copy: yes
251
252 Port number to use for connection.
253
254 · S
255
256 dsn: mysql_socket; copy: yes
257
258 Socket file to use for connection.
259
260 · u
261
262 dsn: user; copy: yes
263
264 User for login if not current user.
265
267 You can download Maatkit from Google Code at
268 <http://code.google.com/p/maatkit/>, or you can get any of the tools
269 easily with a command like the following:
270
271 wget http://www.maatkit.org/get/toolname
272 or
273 wget http://www.maatkit.org/trunk/toolname
274
275 Where "toolname" can be replaced with the name (or fragment of a name)
276 of any of the Maatkit tools. Once downloaded, they're ready to run; no
277 installation is needed. The first URL gets the latest released version
278 of the tool, and the second gets the latest trunk code from Subversion.
279
281 The environment variable "MKDEBUG" enables verbose debugging output in
282 all of the Maatkit tools:
283
284 MKDEBUG=1 mk-....
285
287 You need Perl, DBI, DBD::mysql, and some core packages that ought to be
288 installed in any reasonably new version of Perl.
289
291 For a list of known bugs see
292 <http://www.maatkit.org/bugs/mk-slave-delay>.
293
294 Please use Google Code Issues and Groups to report bugs or request
295 support: <http://code.google.com/p/maatkit/>. You can also join
296 #maatkit on Freenode to discuss Maatkit.
297
298 Please include the complete command-line used to reproduce the problem
299 you are seeing, the version of all MySQL servers involved, the complete
300 output of the tool when run with "--version", and if possible,
301 debugging output produced by running with the "MKDEBUG=1" environment
302 variable.
303
305 This program is copyright 2007-2011 Sergey Zhuravlev and Baron
306 Schwartz. Feedback and improvements are welcome.
307
308 THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
309 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
310 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
311
312 This program is free software; you can redistribute it and/or modify it
313 under the terms of the GNU General Public License as published by the
314 Free Software Foundation, version 2; OR the Perl Artistic License. On
315 UNIX and similar systems, you can issue `man perlgpl' or `man
316 perlartistic' to read these licenses.
317
318 You should have received a copy of the GNU General Public License along
319 with this program; if not, write to the Free Software Foundation, Inc.,
320 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
321
323 Sergey Zhuravlev, Baron Schwartz
324
326 This tool is part of Maatkit, a toolkit for power users of MySQL.
327 Maatkit was created by Baron Schwartz; Baron and Daniel Nichter are the
328 primary code contributors. Both are employed by Percona. Financial
329 support for Maatkit development is primarily provided by Percona and
330 its clients.
331
333 This manual page documents Ver 1.0.23 Distrib 7540 $Revision: 7477 $.
334
335
336
337perl v5.28.0 2011-06-08 MK-SLAVE-DELAY(1)