Setting up MySQL master - master replication

gijs007 picture gijs007 · Dec 23, 2013 · Viewed 10.1k times · Source

I currently have one master server and want to add another master server for fail over.

On the primary server I've added the following to "my.ini"

server-id = 1
replicate-same-server-id = 0
auto-increment-increment = 2
auto-increment-offset = 1
log_bin=mysql-bin
log_error=mysql-bin.err
binlog_do_db=1
binlog_do_db=2
binlog_do_db=3
binlog_do_db=4

Once adding:

master-host = [IP]
master-user = [usernameslaveuser]
master-password = [password]
master-connect-retry = 30

The mysql server no longer starts up... So I decided to first get the secondary server to work properly.

Problem 2: On the new server I've copied over my user files from the "data"/mysql dir of the primary. I've also imported all databases with MySQL work bench.

Then I added this to "my.ini":

server-id=2
replicate-same-server-id = 0
auto-increment-increment = 2
auto-increment-offset = 2

master-host = [IP]
master-user = [usernameslaveuser]
master-password = [password]
master-connect-retry = 30
log_bin=mysql-bin
log_error=mysql-bin.err
binlog_do_db=1
binlog_do_db=2
binlog_do_db=3
binlog_do_db=4

The server starts up fine, so I decided to add a table inside a replicating database on the master but the changes where not copied over to the secondary server...

I googled a bit and found that I have to run some commands in the mysql command line to make replication work. But when I open this on the secondary server it doesn't start... When opening it in the command prompt it says mysql.exe: unknown variable 'server-id=2"

Both servers are running Windows Server 2012 R2 and have MySQL 5.6.15 64bit installed. Can someone guide me true the last part of setting this up?

Answer

rsb picture rsb · Mar 24, 2014

Specifying as below in my.cnf(linux) or my.ini(windows) file is no longer supported in latest versions of MySQL

master-host = [IP]
master-user = [usernameslaveuser]
master-password = [password]
master-connect-retry = 30  

You should execute this query instead:

CHANGE MASTER TO MASTER_HOST='host name/ip',MASTER_USER='user',MASTER_PASSWORD='pwd',              MASTER_PORT=3306, MASTER_CONNECT_RETRY=30;