This is an Ubuntu-based container that creates a network MySQL slaves.
You need a few items in place before building the container.
- SSH keys to the master; refer here for how to generate SSH keys.
- Copy and rename your private SSH key to
/scripts/keyz
and/scripts/keyz.pub
docker build --tag=mysql-replicator .
Open docker-run.sh
and modify each parameter
- Slave's MySQL server ID (id)
- Host address to master
- Master's MySQL credential
- Slave's MySQL credential
- Replicant's credential in master (
keyz
) - Remove container link if master is not another Docker container
After you're done, run ./docker-run.sh
to create container.
docker exec -ti [container name] /root/scripts/repstart.sh
docker exec -ti [container name] /root/sccripts/repcheck.sh
You might have a need to make this slave container a master to other slaves. Follow these steps:
- Start SSH service:
docker exec -ti mysql-slave service mysql start
- Create a new user in container:
docker exec -ti mysql-slave adduser user
- Set password
- Create new SSH key, authorize it in the new master with
ssh-copy-id
There are still too many input needed to get this right, hence too many ways for this to go wrong. Continous refinement is needed to normalize operation and minimize parameters.
Also, as containers go up and down, connections may break and settings may run off. They are all fixable, but it means the architecture is fragile.
Further work is needed to make it robust.