Reprovision a MySQL Replica using rsync
The steps below will guide you through the process of restoring a MySQL Replica node by using rsync.
The following process has the following caveats:
- You can sustain downtime on the node used as a source.
- You can either ssh between hosts as root, or have root level access to temporarily change file ownership.
Steps
Establish
sshas root between hosts, or if you can't set up ssh as root, on the target host,chownownership of mysql target directories to tungsten, then runrsyncas command in Step 3 as the tungsten user.On failed host:
Shut down mysql if it is still running.
Determine all mysql data directories (datadir, binary log dir, etc) e.g.
/var/lib/mysqlClear out database files from the failed host.
shell> rm -rf /var/lib/mysql/*
On Source host:
Wait for the rsync to complete.
On Source host:
Restart mysql.
Bring the replicator online.
shell> trepctl onlineWait for replication to catch up, then use
cctrlto recover the node.cctrl> datasource sourcenode recover
On restored, target, host:
Fix the ownership on ALL data directories, e.g.
shell> chown -R mysql: /var/lib/mysqlStart mysql.
Bring the replicator online.
shell> trepctl onlineWait for replication to catch up, then use
cctrlto recover the nodecctrl> datasource targetnode recover