Hi FCarlo
If you did mean you want to run two whole MySQL servers on the same computer, I'd start along the lines of giving yourself two IP addresses and confinue from there to separate the configuration, data, and startup files.
I took a look at a system with MySQL 5.1.37 and made some notes which perhaps will helpt:
The file /etc/init.d/mysql contains the warning:
Code:
# NOTE: Copying this script and changing the CONF variable here isn't
# enough to run multiple instances of mysqld. Debian/Ubuntu doesn't
# currently support such a configuration out of the box.
CONF=/etc/mysql/my.cnf
You can either make two config files or probably just two startup files, the second of which starts your second mysqld with enough command line flags to separate it from the first. I'd experiment by having one run from the standard /etc/init.d/mysql.conf, and try starting a second by hand with extra command line arguments to separate it from the first. Then I'd make a new /etc/init.d/mysqld2 based on the first one, but with the appropriate flags.
IP Addresses: imagining you already have your server on 192.168.0.32, you get another IP address alias:
Code:
ifconfig eth0:33 192.168.0.33
I'm guessing you'll have two domain names set up, either
Code:
db1.example.com. A 192.168.0.32
db2.example.com. A 192.168.0.33
or
db.example1.com. A 192.168.0.32
db.example2.com. A 192.168.0.33
And then one mysqld is started bound to 192.168.0.32, the second to 192.168.0.33. Note that normally mysql binds to all addresses, including 127.0.0.1. If it's only bound to 192.168.0.32, you'll no longer be able to reach it as localhost and will have to use its name or IP address.
You'll need a second data directory
Code:
mkdir /var/lib/mysql2
chmod 755 /var/lib/mysqld2
chown mysql:mysql /var/lib/mysqld
Getting it working will 'simply' be a question of finding all the file paths which might clash. Reading through the configs, I notice these things which need to change:
Code:
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
Their matching command line versions are
Code:
--pid-file=/var/run/mysqld/mysqld2.pid
--socket=/var/run/mysqld/mysqld2.sock
--datadir=/var/lib/mysql2
You'll need to read the details in http://dev.mysql.com/doc/refman/4.1/...r-options.html
Hope this is helpful. Let us know how you get on.
Kind regards,
Jonathan.
Bookmarks