mgora / rebuild_slave

Automatically rebuild mariadb slaves quickly using this Ansible playbook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logo

Automatic Replica Creation Utility For MariaDB

Description

This playbook will automatically create/rebuild and configure a replication slave. It can be run from any host that can access your database servers via SSH. This is designed to work on both MariaDB and MariaDB ColumnStore systems.

On the master, it will:

  1. Launch MariaBackup.
  2. Create a streaming snapshot of your data directory using xbstream/mbstream.
  3. Compress the stream with pigz.
  4. Stream to the slave via socat.

On the slave, it will:

  1. Receive the stream.
  2. Decompress.
  3. Prepare the backup.
  4. Find the GTID or binary log position.
  5. Register with the master.
  6. Start slave replication.

Prerequisites

  • Ansible
  • Git
  • Ports 4444 and 3306 must be open between your master and slave.
  • Port 22 must be open to your servers from whatever machine you run the playbook from.
  • Create replication user following this example:
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'idbrep'@'10.%' IDENTIFIED BY 'C0lumnStore!';

Setup

  • git clone https://github.com/toddstoffel/rebuild_slave.git
  • cd to cloned folder
  • Edit the inventory/hosts file with your own information
  • Edit the inventory/group_vars/all.yml file with your own information
  • Run ansible-playbook create_slave.yml

About

Automatically rebuild mariadb slaves quickly using this Ansible playbook