MySQL Forums
Forum List  »  Replication

Re: Urgent a master/slave replication not running
Posted by: Norbert Noel Tagana
Date: February 18, 2008 12:47AM

I. Configure The Master
First we have to edit /etc/my.cnf. We have to enable networking for MySQL, and MySQL should listen on all IP addresses, therefore we comment out these lines (if existant):

#skip-networking
#bind-address = 127.0.0.1

Furthermore we have to tell MySQL for which database it should write logs (these logs are used by the slave to see what has changed on the master), which log file it should use, and we have to specify that this MySQL server is the master. We want to replicate the database sugarcrm, so we put the following lines into /etc/my.cnf:

log-bin =
binlog-do-db=sugarcrm
server-id=1

Then restart MySQL:
service mysqld restart

Then we log into the MySQL database as root and create a user with replication privileges:
mysql -u root -p
Enter password:
Now we are on the MySQL shell.
GRANT REPLICATION SLAVE ON *.* TO 'root'@'192.36.253.29' IDENTIFIED BY ' ';

FLUSH PRIVILEGES;
Next (still on the MySQL shell) do this:
USE exampledb;

FLUSH TABLES WITH READ LOCK;

SHOW MASTER STATUS;
The last command will show something like this:

+---------------+----------+--------------+------------------+
| File | Position | Binlog_do_db | Binlog_ignore_db |
+---------------+----------+--------------+------------------+
| mysql-bin.006 | 183 | sugarcrm | |
+---------------+----------+--------------+------------------+
1 row in set (0.00 sec)

Write down this information, we will need it later on the slave!
Then leave the MySQL shell:
quit;
II. Configure The Slave
Now we have to tell MySQL on the slave that it is the slave, that the master is 192.36.253.28, and that the master database to watch is sugarcrm. Therefore we add the following lines to /etc/my.cnf:

server-id=2
master-host=192.36.253.28
master-user=root
master-password=
master-connect-retry=60
replicate-do-db=sugarcrm

Then restart MySQL:
service mysqld restart



Finally, we must do this:
mysql -u root -p
Enter password:
STOP SLAVE;
In the next command (still on the MySQL shell) you have to replace the values appropriately:
CHANGE MASTER TO MASTER_HOST='192.36.253.29', MASTER_USER='root', MASTER_PASSWORD=' ', MASTER_LOG_FILE='mysql-bin.006', MASTER_LOG_POS=183;

To start MySQL slave: START SLAVE;
To show the slave status: SHOW SLAVE STATUS\G;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Urgent a master/slave replication not running
7246
February 18, 2008 12:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.