Last active
January 1, 2016 09:19
-
-
Save meteozond/8124148 to your computer and use it in GitHub Desktop.
Create mysql replication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Usage rpl.sh <db root password> <remote host_name> | |
# Just run on future slave machine: | |
# cd /var/lib/mysql/; nc -l -p 8888 | pigz -d | tar xvf - -C .; chown -R mysql:mysql . | |
backup=/var/lib/mysql/backup | |
mkdir -p $backup | |
path="$backup/`date "+%Y-%m-%d-%H-%M"`/"; | |
time innobackupex --user=root --password=$1 --parallel=64 --slave-info --no-timestamp $path; | |
time innobackupex --use-memory=4g --apply-log $path; | |
cd $path; | |
time tar -c . | pv --size `du -csb . | grep total | cut -f1` | pigz | nc $2 8888; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment