Christophe CasalegnoAutoimmune warrior, Entrepreneur & Bio/Hacker

ReplikSQL: MySQL/MariaDB replication in Bash

ReplikSQL

ReplikSQL is a GPL-licensed Bash script for automating replication setup between MySQL or MariaDB servers on Linux. It radically simplifies what can be a complex process, reducing it to a single command line.

Main features

– Automatic master-slave replication setup.
– Intelligent detection of the MySQL/MariaDB version in use.
– Secure creation and management of the replication user.
– Checks server-id values *before* starting the procedure.
– Supports configurations with dedicated replication IPs.
– Designed to be used from a bastion host.
– Supports unusual SSH ports, including different ports on each machine.

Usage

After downloading the script, basic usage is extremely simple.

Note: personally, I copy this script to /usr/local/bin under the name replisql and run it directly as the appropriate user, just like any other command.

Options

RepliSQL v2 – bootstrap bidirectional MySQL replication
Required:
  --master-pub|-M     Master's public IP
  --master-pw|-P      Master MySQL root password
  --slave-pub|-S      Slave's public IP
  --slave-pw|-p       Slave MySQL root password
Optional:
  --master-priv|-m    Master's private IP (default = master-pub)
  --slave-priv|-s     Slave's private IP  (default = slave-pub)
  --master-ssh-port   Master SSH port (default 65022)
  --slave-ssh-port    Slave SSH port  (default 65022)
  --help|-h           Show this help

Todo list

– Add an option to use GTID (in progress)
– Add a –dry-run option to simulate the configuration without applying it
– Add a verbose mode to display actions in real time.

Resources

– Script: repliksql.sh

—
Christophe Casalegno
You can follow me on: Telegram | Facebook | LinkedIn | X | YouTube | Twitch

Christophe Casalegno Brain 0verride

Keep it simple
and direct!