[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
mysqld_multi
, A Program for Managing Multiple MySQL Servers
mysqld_multi
is meant for managing several mysqld
processes that listen for connections on different Unix socket files and
TCP/IP ports. It can start or stop servers, or report their current status.
The program searches for groups named [mysqld#]
in
`my.cnf' (or in the file named by the --config-file=...
option on
the command line).
#
can be any positive integer. This number
is referred to in the following discussion as the option group number,
or GNR. Group numbers distinquish option groups from one another and are
used as arguments to mysqld_multi
to specify which servers you want
to start, stop, or obtain the status of. Options listed in these groups
are the same as you would use in the usual [mysqld]
group used for starting mysqld
. (See, for example, 2.4.2.2 Starting and Stopping MySQL Automatically.) However, when using multiple servers it is necessary that each one
use its own value for options such as the Unix socket file and TCP/IP port
number. For more information on which options should be specified in a
multiple-server environment, see 5.9 Running Multiple MySQL Servers on the Same Machine.
To invoke mysqld_multi
, use the following syntax:
shell> mysqld_multi [OPTIONS] {start|stop|report} [GNR[,GNR]...] |
start
, stop
, and report
indicate the operation you want
to perform. You can perform the operation on a single server or multiple
servers, depending on the GNR list that follows the option name.
If there is no list, mysqld_multi
performs the operation for all
servers in the option file.
Each GNR value represents an option group number or range of group numbers.
The value should be the number at the end of the group name in the
option file. For example, the GNR for a group named [mysqld17]
is 17
. To specify a range of numbers, separate the first and last
numbers by a dash. The GNR value 10-13 represents groups [mysqld10]
through [mysqld13]
. Multiple groups or group ranges can be specified
on the command line, separated by commas. There must be no whitespace
characters (spaces or tabs) in the GNR list. (Anything after a whitespace
character is ignored.)
This command starts a single server using option group [mysqld17]
:
shell> mysqld_multi start 17 |
This command stops serveral servers, using option groups [mysql8]
and [mysqld10]
through [mysqld13]
:
shell> mysqld_multi start 8,10-13 |
For an example of how you might set up an option file, use this command:
shell> mysqld_multi --example |
mysqld_multi
supports the following options:
--config-file=...
mysqld_multi
looks for [mysqld#]
option groups. It does not
affect where mysqld_multi
reads its own options, which are always
taken from the [mysqld_multi]
group in the usual `my.cnf' file.
Without this option, all options are read from the usual `my.cnf' file.
--example
--help
--log=...
--mysqladmin=...
mysqladmin
binary to be used to stop servers.
--mysqld=...
mysqld
binary to be used. Note that you can specify
mysqld_safe
as the value for this option also. The options are passed
to mysqld
. Just make sure you have the directory where mysqld
is
located in your PATH
environment variable setting or fix mysqld_safe
.
--no-log
--password=...
mysqladmin
.
--tcp-ip
stop
and
report
operations.
--user=...
mysqladmin
.
--version
Some notes about mysqld_multi
:
mysqld
services (using the mysqladmin
program) has the same
password and username for all the data directories accessed (to the
mysql
database). And make sure that the user has the SHUTDOWN
privilege! If you have many data directories and many different mysql
databases with different passwords for the MySQL root
user,
you may want to create a common multi_admin
user for each using the
same password (see below). Example how to do it:
shell> mysql -u root -S /tmp/mysql.sock -proot_password -e "GRANT SHUTDOWN ON *.* TO multi_admin@localhost IDENTIFIED BY 'multipass'" |
mysqld
running in each
data directory, that you have (just change the socket, -S=...
).
pid-file
is very important, if you are using mysqld_safe
to start mysqld
(for example, --mysqld=mysqld_safe
) Every
mysqld
should have its own pid-file
. The advantage
using mysqld_safe
instead of mysqld
directly here is,
that mysqld_safe
"guards" every mysqld
process and will
restart it, if a mysqld
process terminates due to a signal
sent using kill -9
, or for other reasons such as a segmentation
fault. Please note that the
mysqld_safe
script may require that you start it from a certain
place. This means that you may have to cd
to a certain directory,
before you start the mysqld_multi
. If you have problems starting,
please see the mysqld_safe
script. Check especially the lines:
-------------------------------------------------------------------------- MY_PWD=`pwd` # Check if we are starting this relative (for the binary release) if test -d $MY_PWD/data/mysql -a -f ./share/mysql/english/errmsg.sys -a \ -x ./bin/mysqld -------------------------------------------------------------------------- |
See section mysqld_safe
.
The above test should be successful, or you may encounter problems.
mysqld
servers with the same data
directory. Use separate data directories, unless you know what
you are doing!
See section 5.9 Running Multiple MySQL Servers on the Same Machine.
mysqld
.
--user
for mysqld
, but in order to
do this you need to run the mysqld_multi
script as the Unix root
user. Having the option in the config file doesn't matter; you will
just get a warning, if you are not the superuser and the mysqlds
are started under your Unix account. Important: Make
sure that the pid-file
and the data directory are
read+write(+execute for the latter one) accessible for that
Unix user, who the specific mysqld
process is started
as. Do not use the Unix root account for this, unless you
know what you are doing!
mysqld_multi
be sure that you
understand the meanings of
the options that are passed to the mysqld
servers and why you
would want to have separate mysqld
processes. Starting multiple
servers with the same data directory will not give you extra
performance in a threaded system!
See section 5.9 Running Multiple MySQL Servers on the Same Machine.
The following example shows how you might set up an option file for use with
mysqld_multi
.
The first and fifth [mysqld#]
group were intentionally left out from
the example. You may have "gaps" in the option file. This gives you
more flexibility. The order in which the mysqld
programs are started or
stopped depends on the order in which they appear in the option file.
# This file should probably be in your home dir (~/.my.cnf) # or /etc/my.cnf # Version 2.1 by Jani Tolonen [mysqld_multi] mysqld = /usr/local/bin/mysqld_safe mysqladmin = /usr/local/bin/mysqladmin user = multi_admin password = multipass [mysqld2] socket = /tmp/mysql.sock2 port = 3307 pid-file = /usr/local/mysql/var2/hostname.pid2 datadir = /usr/local/mysql/var2 language = /usr/local/share/mysql/english user = john [mysqld3] socket = /tmp/mysql.sock3 port = 3308 pid-file = /usr/local/mysql/var3/hostname.pid3 datadir = /usr/local/mysql/var3 language = /usr/local/share/mysql/swedish user = monty [mysqld4] socket = /tmp/mysql.sock4 port = 3309 pid-file = /usr/local/mysql/var4/hostname.pid4 datadir = /usr/local/mysql/var4 language = /usr/local/share/mysql/estonia user = tonu [mysqld6] socket = /tmp/mysql.sock6 port = 3311 pid-file = /usr/local/mysql/var6/hostname.pid6 datadir = /usr/local/mysql/var6 language = /usr/local/share/mysql/japanese user = jani |
See section 4.3.2 Using Option Files.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |