Tag: mysql master master replication


MySQL Master Master Replication

July 22nd, 2010 — 3:39pm

As described in the previous post about MySQL Master Slave Replication. This is how to setting up MySQL Master Master Replication.

Master address 192.168.10.1
Slave address 192.168.10.2

Setup Slave

* Edit mysql configuration file on /etc/my.cnf

root@slave:~#nano /etc/my.cnf
log-bin=mysql-bin
binlog-ignore-db="mysql"

* Create a Replication Slave privileges on the Slave for the original Master server:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.47-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> GRANT REPLICATION SLAVE ON *.* TO replication@"192.168.10.1" IDENTIFIED BY 'password123#';
mysql> flush privileges;
mysql> exit
Bye

* Restart Slave MySQL service

root@slave:~# killall -9 mysqld mysqld_safe
root@slave:~# /usr/local/mysql/bin/mysqld_safe --user=mysql &

* Get the binary position of the data

mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000005 |      106 |              | mysql            |
+------------------+----------+--------------+------------------+
1 row in set (0.01 sec)

Note the File row and Position row for use on the original Master server.
Continue reading »

Comment » | Linux

Back to top