(mysql.info) multiple-unix-servers
Info Catalog
(mysql.info) multiple-windows-servers
(mysql.info) multiple-servers
(mysql.info) multiple-server-clients
5.13.2 Running Multiple Servers on Unix
---------------------------------------
The easiest way is to run multiple servers on Unix is to compile them
with different TCP/IP ports and Unix socket files so that each one is
listening on different network interfaces. Compiling in different base
directories for each installation also results automatically in a
separate, compiled-in data directory, log file, and PID file location
for each server.
Assume that an existing 4.1.8 server is configured for the default
TCP/IP port number (3306) and Unix socket file (`/tmp/mysql.sock'). To
configure a new 5.0.19 server to have different operating parameters,
use a `configure' command something like this:
shell> ./configure --with-tcp-port=PORT_NUMBER \
--with-unix-socket-path=FILE_NAME \
--prefix=/usr/local/mysql-5.0.19
Here, PORT_NUMBER and FILE_NAME must be different from the default
TCP/IP port number and Unix socket file pathname, and the -prefix value
should specify an installation directory different from the one under
which the existing MySQL installation is located.
If you have a MySQL server listening on a given port number, you can
use the following command to find out what operating parameters it is
using for several important configurable variables, including the base
directory and Unix socket filename:
shell> mysqladmin --host=HOST_NAME --port=PORT_NUMBER variables
With the information displayed by that command, you can tell what
option values _not_ to use when configuring an additional server.
Note that if you specify `localhost' as a hostname, `mysqladmin'
defaults to using a Unix socket file connection rather than TCP/IP.
From MySQL 4.1 onward, you can explicitly specify the connection
protocol to use by using the -protocol={TCP|SOCKET|PIPE|MEMORY} option.
You don't have to compile a new MySQL server just to start with a
different Unix socket file and TCP/IP port number. It is also possible
to use the same server binary and start each invocation of it with
different parameter values at runtime. One way to do so is by using
command-line options:
shell> mysqld_safe --socket=FILE_NAME --port=PORT_NUMBER
To start a second server, provide different -socket and -port option
values, and pass a -datadir=PATH option to `mysqld_safe' so that the
server uses a different data directory.
Another way to achieve a similar effect is to use environment variables
to set the Unix socket filename and TCP/IP port number:
shell> MYSQL_UNIX_PORT=/tmp/mysqld-new.sock
shell> MYSQL_TCP_PORT=3307
shell> export MYSQL_UNIX_PORT MYSQL_TCP_PORT
shell> mysql_install_db --user=mysql
shell> mysqld_safe --datadir=/path/to/datadir &
This is a quick way of starting a second server to use for testing. The
nice thing about this method is that the environment variable settings
apply to any client programs that you invoke from the same shell. Thus,
connections for those clients are automatically directed to the second
server.
environment-variables, includes a list of other environment
variables you can use to affect `mysqld'.
For automatic server execution, the startup script that is executed at
boot time should execute the following command once for each server
with an appropriate option file path for each command:
shell> mysqld_safe --defaults-file=FILE_NAME
Each option file should contain option values specific to a given
server.
On Unix, the `mysqld_multi' script is another way to start multiple
servers. See mysqld-multi.
Info Catalog
(mysql.info) multiple-windows-servers
(mysql.info) multiple-servers
(mysql.info) multiple-server-clients
automatically generated byinfo2html