Skip to content

Instantly share code, notes, and snippets.

@meteozond
Last active January 1, 2016 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meteozond/8124148 to your computer and use it in GitHub Desktop.
Save meteozond/8124148 to your computer and use it in GitHub Desktop.
Create mysql replication
#! /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