MySQL Replication: Difference between revisions

From UNIX Systems Administration
Jump to navigation Jump to search
(Created page with "Open two windows to the Master Server and one window to the Slave Server On the MASTER Server MAIN WINDOW # <tt>'''# service mysqld stop'''</tt> # <tt>'''# vi /data/chroot/et...")
 
No edit summary
Line 35: Line 35:
On the MASTER Server MAIN WINDOW
On the MASTER Server MAIN WINDOW
# <tt>'''mysql> UNLOCK TABLES;'''</tt>
# <tt>'''mysql> UNLOCK TABLES;'''</tt>
[[Category:MySQL]]

Revision as of 16:25, 5 January 2012

Open two windows to the Master Server and one window to the Slave Server

On the MASTER Server MAIN WINDOW

  1. # service mysqld stop
  2. # vi /data/chroot/etc/my.cnf
	log-bin         = mysql-bin
	server-id       = 1
  1. # service mysqld start

On the SLAVE Server

  1. # service mysqld stop
  2. # vi /data/chroot/etc/my.cnf
	server-id       = 2
  1. service mysqld start

On the MASTER Server MAIN WINDOW

  1. # mysql -p -uroot
  2. mysql> GRANT REPLICATION SLAVE ON *.* TO 'mysql-ha'@'<IP Address of Slave>' IDENTIFIED BY '<Password>';
  3. mysql> FLUSH PRIVILEGES;
  4. mysql> FLUSH TABLES WITH READ LOCK;

On the MASTER Server SECOND WINDOW

  1. # mysql -p -uroot
  2. mysql> SHOW MASTER STATUS;

On the SLAVE Server

  1. # mysql -p -uroot
  2. mysql> CHANGE MASTER TO MASTER_HOST='<IP Address of Master>', MASTER_USER='mysql-ha', MASTER_PASSWORD='<Password>', MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=323;
  3. mysql> START SLAVE;

On the MASTER Server MAIN WINDOW

  1. mysql> UNLOCK TABLES;