Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Rebuilding an existing slave from a master using cold-copying of /var/lib/mysql, would this be the proper process/order? Anything missing?

  1. master mysql> SHOW MASTER STATUS\G (take notes)
  2. slave mysql> STOP SLAVE;
  3. Shut down master and slave mysqld
  4. Move existing slave:/var/lib/mysql out of the way
  5. Copy master:/var/lib/mysql to slave:/var/lib/mysql
  6. Start master mysqld
  7. Start slave mysqld
  8. slave mysql> CHANGE MASTER TO MASTER_HOST='masterserver',
    -> MASTER_USER='replicationusername',
    -> MASTER_PASSWORD='replcationpassword',
    -> MASTER_LOG_FILE='logfilefromshowmasterstatus',
    -> MASTER_LOG_POS=positionfromshowmasterstatus;
  9. slave mysql> start slave;
share|improve this question
    
There will be some time between "SHOW MASTER STATUS" and shutting down mysqld. Might I suggest using "FLUSH TABLES WITH READ LOCK;" then "SHOW MASTER STATUS;" (Take notes). FLUSH tables will make sure all changes are written to disk and with read lock will make sure the database does not change afterward. –  racyclist Oct 13 '10 at 21:11
add comment

3 Answers

up vote 0 down vote accepted

I'd suggest referring to a following link:

MySQL MySQL 5.1 Reference Manual 16.1.1 How to Set Up Replication

share|improve this answer
add comment

Other pieces to add to the mix:

step 6.5 Check permissions after moving files

Step 7 - restart slave with mysqld_safe --skip-slave-start &

share|improve this answer
add comment

1.- Stop master and slave mysqld.

2.- On slave move /var/lib/mysq/ to someplace else.

3.- Copy /var/lib/mysql from master to slave.

4.- Check permissions on slave.

5.- On slave (/etc/my.cnf) set --skip-slave-start

6.- Start master and slave mysqld

7.- On slave point to the new master binlog file just created, on position 4.

8.- start slave io_thread, then see if everything is okay

9.- start slave sql_thread and wait the slave to get up to date.

That's it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.