How To Set Up Database Replication In MySQL On Ubuntu 9.10 - Page 2
4 Configuring The SlaveNow we must configure the slave. Open /etc/mysql/my.cnf and make sure you have the following settings in the [mysqld] section: server2: vi /etc/mysql/my.cnf
The value of server-id must be unique and thus different from the one on the master! Restart MySQL afterwards: /etc/init.d/mysql restart Before we start setting up the replication, we create an empty database exampledb on server2: mysql -u root -p CREATE DATABASE exampledb; On server2, we can now import the SQL dump snapshot.sql like this: /usr/bin/mysqladmin --user=root --password=yourrootsqlpassword stop-slave Now connect to MySQL again... mysql -u root -p ... 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='slave_user', MASTER_PASSWORD='slave_password', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=19467;
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; That's it! Now whenever exampledb is updated on the master, all changes will be replicated to exampledb on the slave. Test it!
5 Links
|



Recent comments
12 hours 20 min ago
13 hours 56 min ago
18 hours 16 min ago
22 hours 7 min ago
1 day 9 hours ago
1 day 16 hours ago
1 day 18 hours ago
1 day 20 hours ago
1 day 20 hours ago
1 day 20 hours ago