Skip to content

Instantly share code, notes, and snippets.

@danf0rth
Last active June 11, 2021 08:11
Show Gist options
  • Save danf0rth/47c2b3d2ad96b7a93a8b7dc4b2f7fd4b to your computer and use it in GitHub Desktop.
Save danf0rth/47c2b3d2ad96b7a93a8b7dc4b2f7fd4b to your computer and use it in GitHub Desktop.
MariaDB master/slave replication
  • install mariadb-backup package on both servers
  • mariadb-backup --backup --stream | ssh user@slave-host-ip 'cat > xbstream.mb' or xtrabackup --backup --stream=xbstream | ssh root@1.2.3.4 'xbstream -x -C /var/backups/mysql' with xtrabackup
  • mbstream -x xbstream.mb -C /var/backups/mysql
  • mariadb-backup --prepare --target-dir /var/backups/mysql
  • rm -rf /var/lib/mysql/* && cp -r /var/backups/mysql/* /var/lib/mysql/
  • chown -R mysql:mysql /var/lib/mysql
  • service mysql start
  • use your replication user to start replication
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment