|< Day Day Up >|
16.4 Using Multiple Servers
It's common to run a single MySQL server on a host, but it's possible to run multiple servers. Managing multiple servers is of course a more complex undertaking than running a single server because you must make sure that the servers don't interfere with each other. None of the servers can share resources that must be used exclusively by a single server. These resources include the following:
You can ensure that each server uses its own network interfaces by starting each with a unique value for the --port and --socket options. Similarly, to make sure that each server manages a different data directory, start each one with a unique value for the --datadir option. Normally, having distinct data directories is sufficient to ensure distinct sets of log files as well because logs are created by default in the data directory if you specify their names using relative pathnames.
shell> mysqld --install mysql1 shell> mysqld --install mysql2
Installed that way, these servers will read options from the [mysql1] and [mysql2] groups, respectively, in the standard option files.
Another way to install MySQL as a service is to follow the service name with an option naming the file from which the server should read options when it starts:
shell> mysqld --install mysql1 --defaults-file=C:\mysq1.cnf shell> mysqld --install mysql2 --defaults-file=C:\mysq2.cnf
In this case, each server will ignore the standard option files and will instead read options only from the [mysqld] group of the option file named by the --defaults-file option.
On Unix, some administrative assistance is available for controlling multiple servers. mysqld_multi is a Perl script intended to make it easier to manage multiple servers on a single host. It can start or stop servers, or report on whether servers are running. mysqld_multi can either start servers directly, or indirectly by invoking mysqld_safe. (An advantage of using mysqld_safe is that it sets up the error log and monitors the server.) mysqld_multi requires installation of the Perl DBI module.
|< Day Day Up >|