This repository provides a ready-to-use Docker Compose setup for a MySQL master-slave replication cluster managed by ProxySQL. It is ideal for testing, development, and learning about MySQL replication and ProxySQL load balancing.
master/
: MySQL master configuration and initialization.slave/
: MySQL slave configurations and initialization.proxysql/
: ProxySQL configuration and persistent data files.docker-compose.yml
: Service definitions for master, slaves, and ProxySQL.
- mysql-master: MySQL master node (port 3306)
- mysql-slave1: MySQL slave node 1 (port 3307)
- mysql-slave2: MySQL slave node 2 (port 3308)
- proxysql: ProxySQL instance (ports 6032 for admin, 6033 for MySQL traffic)
-
Install Docker and Docker Compose
- Make sure Docker is running on your system.
-
Clone this repository
git clone https://github.com/sakibbuddy/proxysql_master_slave.git cd proxysql_master_slave
-
Start the cluster
docker-compose up -d
-
Check service status
docker-compose ps
-
Access MySQL and ProxySQL
- MySQL Master:
localhost:3306
- MySQL Slave1:
localhost:3307
- MySQL Slave2:
localhost:3308
- ProxySQL Admin:
localhost:6032
- ProxySQL MySQL:
localhost:6033
- MySQL Master:
- Default MySQL root password is
password
(change indocker-compose.yml
for production). - Initialization SQL and custom configs are loaded from the respective folders.
- ProxySQL configuration is in
proxysql/proxysql.cnf
.
To stop and remove all containers:
docker-compose down
Problem | Possible Fix |
---|---|
❌ Replication lag or slaves not syncing | Check GTID settings and slave status (SHOW SLAVE STATUS\G ) |
❌ ProxySQL health check fails | Confirm monitor user credentials and hostgroups |
❌ Can't connect to master/slave | Verify container ports, firewall, and network |
🐳 Containers restart / crash | Inspect logs & check volume mounts |
❗ ProxySQL not routing reads | Confirm query rules and hostgroup IDs |
Feel free to modify configs for your own replication or ProxySQL experiments!