Setting Up Master-Master Replication On Four Nodes With MySQL 5 On Debian Etch - Page 2
4 Setting Up ReplicationNow we set up master-master replication in /etc/mysql/my.cnf. The crucial configuration options for master-master replication are auto_increment_increment and auto_increment_offset:
Let's assume we have N MySQL nodes (N=4 in this example), then auto_increment_increment has the value N on all nodes, and each node must have a different value for auto_increment_offset (1, 2, ..., N). We also need to configure log-slave-updates because otherwise replication will work only, for example, from server1 to server2, but not to server3 and server4. Now let's configure our four MySQL nodes: server1: vi /etc/mysql/my.cnf Search for the section that starts with [mysqld], and put the following options into it (commenting out all existing conflicting options):
Then restart MySQL: /etc/init.d/mysql restart Now do the same on server2... server2: vi /etc/mysql/my.cnf
/etc/init.d/mysql restart ...server3... server3: vi /etc/mysql/my.cnf
/etc/init.d/mysql restart ... and server4: server4: vi /etc/mysql/my.cnf
/etc/init.d/mysql restart Before we continue, we must make sure that no slave processes are running on server1 to server4: server1/server2/server3/server4: /usr/bin/mysqladmin --user=root --password=yourrootsqlpassword stop-slave Next we lock the exampledb database on server1, find out about the master status of server1, create an SQL dump of exampledb (that we will import into exampledb on server2, server3, and server4 so that all four databases contain the same data), and unlock the database so that it can be used again: server1: mysql -u root -p On the MySQL shell, run the following commands: server1: USE exampledb; The last command should show something like this (please write it down, we'll need it later on): mysql> SHOW MASTER STATUS; Now don't leave the MySQL shell, because if you leave it, the database lock will be removed, and this is not what we want right now because we must create a database dump now. While the MySQL shell is still open, we open a second command line window where we create the SQL dump snapshot.sql and transfer it to server2, server3, and server4 (using scp): server1: cd /tmp scp snapshot.sql root@192.168.0.102:/tmp scp snapshot.sql root@192.168.0.103:/tmp Afterwards, you can close the second command line window. On the first command line window, we can now unlock the database and leave the MySQL shell: server1: UNLOCK TABLES;
4.1 Setting Up Replication On server2(This chapter is for server2 only!) On server2, we can now import the SQL dump snapshot.sql like this: server2: /usr/bin/mysqladmin --user=root --password=yourrootsqlpassword stop-slave Afterwards, we must find out about the master status of server2 as well and write it down: mysql -u root -p USE exampledb; SHOW MASTER STATUS; mysql> SHOW MASTER STATUS; Then unlock the tables: UNLOCK TABLES; and run the following command to make server2 a slave of server1 (it is important that you replace the values in the following command with the values you got from the SHOW MASTER STATUS; command that we ran on server1!): CHANGE MASTER TO MASTER_HOST='192.168.0.100', MASTER_USER='slaveuser_for_s2', MASTER_PASSWORD='slave_user_for_server2_password', MASTER_LOG_FILE='mysql-bin.000010', MASTER_LOG_POS=98; Finally start the slave: START SLAVE; Then check the slave status: SHOW SLAVE STATUS \G It is important that both Slave_IO_Running and Slave_SQL_Running have the value Yes in the output (otherwise something went wrong, and you should check your setup again and take a look at /var/log/syslog to find out about any errors): mysql> SHOW SLAVE STATUS \G Afterwards, you can leave the MySQL shell on server2: quit Now the replication from server1 to server2 is set up. Next we must configure replication from server2 to server3.
|
www.seamlessenterprise.com
One number. One voicemail. Seize the lead. Sprint Mobile Integration.
www.seamlessenterprise.com
One Number. One Voicemail.
Make it easier for clients to reach you. Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com
One number. One voicemail. Sprint Mobile Integration.
www.seamlessenterprise.com
AT&T Synaptic Compute as a Service. Boost your power on demand.
Trial: IBM Cognos Express Reporting, Analysis & Planning




print: 

Recent comments
1 hour 1 min ago
1 hour 14 min ago
2 hours 21 min ago
6 hours 37 min ago
7 hours 6 min ago
21 hours 2 min ago
1 day 5 hours ago
1 day 12 hours ago
1 day 15 hours ago
1 day 17 hours ago