Announcement

Announcement Module
Collapse
No announcement yet.

Set up a slave with copy of another slave

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Set up a slave with copy of another slave

    Hi,
    I've got a master-slave pair, now I need to duplicate the slave.
    Is it possible to stop slave MySQL, copy all datadir files, and then simply run the new slave?

  • #2
    You can absolutely copy a slave, as a rule of thumb I'd usually lock the tables completely (or shut down the slave whilst copying the files) whilst copying the files though:
    STOP SLAVE;
    FLUSH TABLES WITH READ LOCK;

    rsync <datadir> newslave:<new_mysql_datadir>

    UNLOCK TABLES;
    START SLAVE;
    ^^ should do it, make sure to keep the MySQL client window open whilst the tables are locked (usually easier to keep that session open in a screen session)

    Note: If the servers are all MySQL/Percona 5.6 remember to remove/rename the auto.cnf file before starting up the new server. The auto.cnf file defines the servers UUID (a bit like server_id used to be in /etc/my.cnf, but globally unique and it's stored in the data_directory now), and thus needs to be unique (auto-generated) for each and every slave. The Percona guys wrote about this recently, check (http://www.mysqlperformanceblog.com/...loning-slaves/) for more info.
    Last edited by carshann; 01-25-2014, 02:44 AM. Reason: typos!

    Comment


    • #3
      Thank you!

      Comment

      Working...
      X