2
3
4
6 mysqld_multi - manage multiple MySQL servers
7
9 mysqld_multi [options] {start|stop|report} [GNR[,GNR] ...]
10
12 mysqld_multi is designed to manage several mysqld processes that listen
13 for connections on different Unix socket files and TCP/IP ports. It can
14 start or stop servers, or report their current status. The MySQL
15 Instance Manager is an alternative means of managing multiple servers
16 (see mysqlmanager(8)).
17
18 mysqld_multi searches for groups named [mysqldN] in my.cnf (or in the
19 file named by the --config-file option). N can be any positive
20 integer. This number is referred to in the following discussion as the
21 option group number, or GNR. Group numbers distinguish option groups
22 from one another and are used as arguments to mysqld_multi to specify
23 which servers you want to start, stop, or obtain a status report for.
24 Options listed in these groups are the same that you would use in the
25 [mysqld] group used for starting mysqld. (See, for example,
26 Section 4.15.2.2, “Starting and Stopping MySQL Automatically”.)
27 However, when using multiple servers, it is necessary that each one use
28 its own value for options such as the Unix socket file and TCP/IP port
29 number. For more information on which options must be unique per server
30 in a multiple-server environment, see Section 10, “Running Multiple
31 MySQL Servers on the Same Machine”.
32
33 To invoke mysqld_multi, use the following syntax:
34
35 shell> mysqld_multi [options] {start|stop|report} [GNR[,GNR] ...]
36
37 start, stop, and report indicate which operation to perform. You can
38 perform the designated operation for a single server or multiple
39 servers, depending on the GNR list that follows the option name. If
40 there is no list, mysqld_multi performs the operation for all servers
41 in the option file.
42
43 Each GNR value represents an option group number or range of group
44 numbers. The value should be the number at the end of the group name in
45 the option file. For example, the GNR for a group named [mysqld17] is
46 17. To specify a range of numbers, separate the first and last numbers
47 by a dash. The GNR value 10-13 represents groups [mysqld10] through
48 [mysqld13]. Multiple groups or group ranges can be specified on the
49 command line, separated by commas. There must be no whitespace
50 characters (spaces or tabs) in the GNR list; anything after a
51 whitespace character is ignored.
52
53 This command starts a single server using option group [mysqld17]:
54
55 shell> mysqld_multi start 17
56
57 This command stops several servers, using option groups [mysqld8] and
58 [mysqld10] through [mysqld13]:
59
60 shell> mysqld_multi stop 8,10-13
61
62 For an example of how you might set up an option file, use this
63 command:
64
65 shell> mysqld_multi --example
66
67 mysqld_multi supports the following options:
68
69 · --help
70
71 Display a help message and exit.
72
73 · --config-file=file_name
74
75 Specify the name of an alternative option file. This affects where
76 mysqld_multi looks for [mysqldN] option groups. Without this option,
77 all options are read from the usual my.cnf file. The option does not
78 affect where mysqld_multi reads its own options, which are always
79 taken from the [mysqld_multi] group in the usual my.cnf file.
80
81 · --example
82
83 Display a sample option file.
84
85 · --log=file_name
86
87 Specify the name of the log file. If the file exists, log output is
88 appended to it.
89
90 · --mysqladmin=prog_name
91
92 The mysqladmin binary to be used to stop servers.
93
94 · --mysqld=prog_name
95
96 The mysqld binary to be used. Note that you can specify mysqld_safe
97 as the value for this option also. If you use mysqld_safe to start
98 the server, you can include the mysqld or ledir options in the
99 corresponding [mysqldN] option group. These options indicate the
100 name of the server that mysqld_safe should start and the pathname of
101 the directory where the server is located. (See the descriptions for
102 these options in mysqld_safe(1).) Example:
103
104 [mysqld38]
105 mysqld = mysqld-debug
106 ledir = /opt/local/mysql/libexec
107
108 · --no-log
109
110 Print log information to stdout rather than to the log file. By
111 default, output goes to the log file.
112
113 · --password=password
114
115 The password of the MySQL account to use when invoking mysqladmin.
116 Note that the password value is not optional for this option, unlike
117 for other MySQL programs.
118
119 · --silent
120
121 Silent mode; disable warnings.
122
123 · --tcp-ip
124
125 Connect to each MySQL server via the TCP/IP port instead of the Unix
126 socket file. (If a socket file is missing, the server might still be
127 running, but accessible only via the TCP/IP port.) By default,
128 connections are made using the Unix socket file. This option affects
129 stop and report operations.
130
131 · --user=user_name
132
133 The username of the MySQL account to use when invoking mysqladmin.
134
135 · --verbose
136
137 Be more verbose.
138
139 · --version
140
141 Display version information and exit.
142
143
144 Some notes about mysqld_multi:
145
146 · Most important: Before using mysqld_multi be sure that you
147 understand the meanings of the options that are passed to the mysqld
148 servers and why you would want to have separate mysqld processes.
149 Beware of the dangers of using multiple mysqld servers with the same
150 data directory. Use separate data directories, unless you know what
151 you are doing. Starting multiple servers with the same data
152 directory does not give you extra performance in a threaded system.
153 See Section 10, “Running Multiple MySQL Servers on the Same
154 Machine”.
155
156 · Important: Make sure that the data directory for each server is
157 fully accessible to the Unix account that the specific mysqld
158 process is started as. Do not use the Unix root account for this,
159 unless you know what you are doing. See Section 4.5, “How to Run
160 MySQL as a Normal User”.
161
162 · Make sure that the MySQL account used for stopping the mysqld
163 servers (with the mysqladmin program) has the same username and
164 password for each server. Also, make sure that the account has the
165 SHUTDOWN privilege. If the servers that you want to manage have
166 different usernames or passwords for the administrative accounts,
167 you might want to create an account on each server that has the same
168 username and password. For example, you might set up a common
169 multi_admin account by executing the following commands for each
170 server:
171
172 shell> mysql -u root -S /tmp/mysql.sock -p
173 Enter password:
174 mysql> GRANT SHUTDOWN ON *.*
175 -> TO 'multi_admin'@'localhost' IDENTIFIED BY 'multipass';
176 See Section 5.2, “How the Privilege System Works”. You have to do this
177 for each mysqld server. Change the connection parameters appropriately
178 when connecting to each one. Note that the hostname part of the account
179 name must allow you to connect as multi_admin from the host where you
180 want to run mysqld_multi.
181
182 · The Unix socket file and the TCP/IP port number must be different
183 for every mysqld.
184
185 · The --pid-file option is very important if you are using mysqld_safe
186 to start mysqld (for example, --mysqld=mysqld_safe) Every mysqld
187 should have its own process ID file. The advantage of using
188 mysqld_safe instead of mysqld is that mysqld_safe monitors its
189 mysqld process and restarts it if the process terminates due to a
190 signal sent using kill -9 or for other reasons, such as a
191 segmentation fault. Please note that the mysqld_safe script might
192 require that you start it from a certain place. This means that you
193 might have to change location to a certain directory before running
194 mysqld_multi. If you have problems starting, please see the
195 mysqld_safe script. Check especially the lines:
196
197 ----------------------------------------------------------------
198 MY_PWD=`pwd`
199 # Check if we are starting this relative (for the binary release)
200 if test -d $MY_PWD/data/mysql -a -f ./share/mysql/english/errmsg.sys -a \
201 -x ./bin/mysqld
202 ----------------------------------------------------------------
203 The test performed by these lines should be successful, or you might
204 encounter problems. See mysqld_safe(1).
205
206 · You might want to use the --user option for mysqld, but to do this
207 you need to run the mysqld_multi script as the Unix root user.
208 Having the option in the option file doesn't matter; you just get a
209 warning if you are not the superuser and the mysqld processes are
210 started under your own Unix account.
211
212
213 The following example shows how you might set up an option file for use
214 with mysqld_multi. The order in which the mysqld programs are started
215 or stopped depends on the order in which they appear in the option
216 file. Group numbers need not form an unbroken sequence. The first and
217 fifth [mysqldN] groups were intentionally omitted from the example to
218 illustrate that you can have “gaps” in the option file. This gives you
219 more flexibility.
220
221 # This file should probably be in your home dir (~/.my.cnf)
222 # or /etc/my.cnf
223 # Version 2.1 by Jani Tolonen
224 [mysqld_multi]
225 mysqld = /usr/local/bin/mysqld_safe
226 mysqladmin = /usr/local/bin/mysqladmin
227 user = multi_admin
228 password = multipass
229 [mysqld2]
230 socket = /tmp/mysql.sock2
231 port = 3307
232 pid-file = /usr/local/mysql/var2/hostname.pid2
233 datadir = /usr/local/mysql/var2
234 language = /usr/local/share/mysql/english
235 user = john
236 [mysqld3]
237 socket = /tmp/mysql.sock3
238 port = 3308
239 pid-file = /usr/local/mysql/var3/hostname.pid3
240 datadir = /usr/local/mysql/var3
241 language = /usr/local/share/mysql/swedish
242 user = monty
243 [mysqld4]
244 socket = /tmp/mysql.sock4
245 port = 3309
246 pid-file = /usr/local/mysql/var4/hostname.pid4
247 datadir = /usr/local/mysql/var4
248 language = /usr/local/share/mysql/estonia
249 user = tonu
250 [mysqld6]
251 socket = /tmp/mysql.sock6
252 port = 3311
253 pid-file = /usr/local/mysql/var6/hostname.pid6
254 datadir = /usr/local/mysql/var6
255 language = /usr/local/share/mysql/japanese
256 user = jani
257
258 See Section 3.2, “Using Option Files”.
259
261 Copyright 1997-2007 MySQL AB
262
263 This documentation is NOT distributed under a GPL license. Use of this
264 documentation is subject to the following terms: You may create a
265 printed copy of this documentation solely for your own personal use.
266 Conversion to other formats is allowed as long as the actual content is
267 not altered or edited in any way. You shall not publish or distribute
268 this documentation in any form or on any media, except if you
269 distribute the documentation in a manner similar to how MySQL
270 disseminates it (that is, electronically for download on a Web site
271 with the software) or on a CD-ROM or similar medium, provided however
272 that the documentation is disseminated together with the software on
273 the same medium. Any other use, such as any dissemination of printed
274 copies or use of this documentation, in whole or in part, in another
275 publication, requires the prior written consent from an authorized
276 representative of MySQL AB. MySQL AB reserves any and all rights to
277 this documentation not expressly granted above.
278
279 Please email <docs@mysql.com> for more information.
280
282 For more information, please refer to the MySQL Reference Manual, which
283 may already be installed locally and which is also available online at
284 http://dev.mysql.com/doc/.
285
287 MySQL AB (http://www.mysql.com/). This software comes with no
288 warranty.
289
290
291
292MySQL 5.0 07/04/2007 MYSQLD_MULTI(1)