MMM Master-master-mysql

I starting trying to set up a test environment for feeling out master-master replication with mysql. I can do all this on one machine by running 2 mysqld processes from different configurations, on different ports, sockets, data directories, users etcetera.

All the stuff for the “A” side will be “-a” and “B” “-b”

cp /etc/my.cnf /etc/my-a.cnf /etc/my-b.cnf 
mkdir /var/lib/mysql-a
mkdir /var/lib/mysql-b

Then edit your cnf files for each side.

# Note this is not meant to be pasted in as you whole conf file! These are the params you need to find and change.
user            = mysql
socket          = /var/run/mysqld/mysqld-a.sock
port            = 3310
basedir         = /usr
datadir         = /var/lib/mysql-a
tmpdir          = /tmp/mysql-a

Before we get into setting up the actual replication lets that we can run these 2 mysqlds at the same time. Try to start one side.

mysqld --defaults-file=/etc/mysql/my-a-side.cnf &

Apparmor! Arg. Add this for a and b sides:

/var/lib/mysql-a/ r,
/var/lib/mysql-a/** rwk,
/var/run/mysqld/ w,
/var/run/mysqld/mysqld-a.sock w,

Try to start up both. Wrap that exec up into a script and make one for the b side too.

./ && ./

and to shut them down

mysqladmin -u root -P 3310 -h shutdown

We’ll need to setups the datadirs - or if you have a data to start with you can put it in the data dir. Or else something like this for each of your $DATADIRs.

mysql_install_db --user=mysql --datadir=$DATADIR