Master-Master Replication With MySQL 5 On Fedora 8 - Page 2

3 Replication

3.1 Firewall Configuration On Both Systems

Versions of system-config-firewall-tui before 1.0.12-4.x had a bug in conjunction with custom rules (they were not aquired) - so check which version is installed on your system.

yum list installed | grep firewall

If the installed version is lower than 1.0.12-4.x you have to update to the new version. While I was writing this howto, the new version was only available in the updates-testing repository.

yum --enablerepo=updates-testing update system-config-firewall-tui

In order that the mysql servers are able to connect each other you have to open the port 3306 (tcp) on both systems.

system-config-firewall

Click on "Customize"

Insert the MySQL-port into the section "Other Ports" as shown on the screenshot below and click on "OK" to save the settings.
Click on "OK".

3.2 Log Directory On Both Systems

In order that the MySQL server is able to create log-files we have to create a directory and pass the ownership to MySQL.

mkdir /var/log/mysql/
chown mysql:mysql /var/log/mysql/

3.3 MySQL Configuration

In the next two steps we adjust the MySQL configuration on both systems for master-master replication.

3.3.1 System 1

vi /etc/my.cnf

Add the following lines to the section [mysqld]:

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

master-host = 192.168.0.200
master-user = slave1_user
master-password = %mysql_slaveuser_password%
master-connect-retry = 60
replicate-do-db = exampledb

log-bin = /var/log/mysql/mysql-bin.log
binlog-do-db = exampledb

relay-log = /var/lib/mysql/slave-relay.log
relay-log-index = /var/lib/mysql/slave-relay-log.index

expire_logs_days = 10
max_binlog_size = 500M

Afterwards restart the MySQL server.

/etc/init.d/mysqld restart

3.3.2 System 2

vi /etc/my.cnf

Add the following lines to the section [mysqld]:

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

master-host = 192.168.0.100
master-user = slave2_user
master-password = %mysql_slaveuser_password%
master-connect-retry = 60
replicate-do-db = exampledb

log-bin= /var/log/mysql/mysql-bin.log
binlog-do-db = exampledb

relay-log = /var/lib/mysql/slave-relay.log
relay-log-index = /var/lib/mysql/slave-relay-log.index

expire_logs_days = 10
max_binlog_size = 500M

Afterwards restart the MySQL server.

/etc/init.d/mysqld restart

Previous||Next