MySQL Replication: Difference between revisions
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 |
||
(11 intermediate revisions by the same user not shown) | |||
Line 22: | Line 22: | ||
# <tt>'''mysql> GRANT REPLICATION SLAVE ON *.* TO 'mysql-ha'@'<IP Address of Slave>' IDENTIFIED BY '<Password>';'''</tt> | # <tt>'''mysql> GRANT REPLICATION SLAVE ON *.* TO 'mysql-ha'@'<IP Address of Slave>' IDENTIFIED BY '<Password>';'''</tt> | ||
# <tt>'''mysql> FLUSH PRIVILEGES;'''</tt> | # <tt>'''mysql> FLUSH PRIVILEGES;'''</tt> | ||
# <tt>'''mysql> RESET MASTER;'''</tt> | |||
# <tt>'''mysql> FLUSH TABLES WITH READ LOCK;'''</tt> | # <tt>'''mysql> FLUSH TABLES WITH READ LOCK;'''</tt> | ||
# <tt>'''mysql> SHOW MASTER STATUS;'''</tt> | |||
On the MASTER Server SECOND WINDOW | On the MASTER Server SECOND WINDOW | ||
# Take a dump of the MySQL environment. | |||
## <tt>'''# mysqldump -p -uroot --all-databases > alldb.sql'''</tt> | |||
## SCP this information over to the slave server. | |||
# <tt>'''# mysql -p -uroot'''</tt> | # <tt>'''# mysql -p -uroot'''</tt> | ||
# <tt>'''mysql> | # <tt>'''mysql> UNLOCK TABLES;'''</tt> | ||
On the SLAVE Server | On the SLAVE Server | ||
# <tt>'''# mysql -p -uroot'''</tt> | # <tt>'''# mysql -p -uroot'''</tt> | ||
# <tt>'''mysql> CHANGE MASTER TO MASTER_HOST='<IP Address of Master>', MASTER_USER='mysql-ha', MASTER_PASSWORD='<Password>', MASTER_LOG_FILE='mysql-bin. | # <tt>'''mysql> STOP SLAVE;'''</tt> | ||
# <tt>'''mysql> \q'''</tt> | |||
# Restore the backup from the master server. | |||
## <tt>'''# mysql -p -uroot < alldb.sql'''</tt> | |||
# <tt>'''# mysql -p -uroot'''</tt> | |||
# <tt>'''mysql> RESET SLAVE;'''</tt> | |||
# <tt>'''mysql> CHANGE MASTER TO MASTER_HOST='<IP Address of Master>', MASTER_USER='mysql-ha', MASTER_PASSWORD='<Password>', MASTER_LOG_FILE='mysql-bin.<######>', MASTER_LOG_POS=<###>;'''</tt> | |||
# <tt>'''mysql> START SLAVE;'''</tt> | # <tt>'''mysql> START SLAVE;'''</tt> | ||
On the MASTER Server MAIN WINDOW | On the MASTER Server MAIN WINDOW | ||
# <tt>'''mysql> UNLOCK TABLES;'''</tt> | # <tt>'''mysql> UNLOCK TABLES;'''</tt> | ||
[[Category:Software]] | |||
[[Category:MySQL]] |
Latest revision as of 16:41, 30 September 2013
Open two windows to the Master Server and one window to the Slave Server
On the MASTER Server MAIN WINDOW
- # service mysqld stop
- # vi /data/chroot/etc/my.cnf
log-bin = mysql-bin server-id = 1
- # service mysqld start
On the SLAVE Server
- # service mysqld stop
- # vi /data/chroot/etc/my.cnf
server-id = 2
- service mysqld start
On the MASTER Server MAIN WINDOW
- # mysql -p -uroot
- mysql> GRANT REPLICATION SLAVE ON *.* TO 'mysql-ha'@'<IP Address of Slave>' IDENTIFIED BY '<Password>';
- mysql> FLUSH PRIVILEGES;
- mysql> RESET MASTER;
- mysql> FLUSH TABLES WITH READ LOCK;
- mysql> SHOW MASTER STATUS;
On the MASTER Server SECOND WINDOW
- Take a dump of the MySQL environment.
- # mysqldump -p -uroot --all-databases > alldb.sql
- SCP this information over to the slave server.
- # mysql -p -uroot
- mysql> UNLOCK TABLES;
On the SLAVE Server
- # mysql -p -uroot
- mysql> STOP SLAVE;
- mysql> \q
- Restore the backup from the master server.
- # mysql -p -uroot < alldb.sql
- # mysql -p -uroot
- mysql> RESET SLAVE;
- mysql> CHANGE MASTER TO MASTER_HOST='<IP Address of Master>', MASTER_USER='mysql-ha', MASTER_PASSWORD='<Password>', MASTER_LOG_FILE='mysql-bin.<######>', MASTER_LOG_POS=<###>;
- mysql> START SLAVE;
On the MASTER Server MAIN WINDOW
- mysql> UNLOCK TABLES;