Hi All,
I am trying to create a Mariadb master-slave replication in docker swarm with docker-compose. My goal is to have a redundant DB server with two different external storages( one for the master and one for the slave) in order to prevent data lost in case of storage failure.
I have tried with the following yml, but when I create a table on the master, it is not transferred to the slave:
version: '3.9'
services:
db-master:
image: mariadb:latest
container_name: db-master
restart: always
environment:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: db
MYSQL_USER: user
MYSQL_PASSWORD: userpass
volumes:
- ./master/my.cnf:/etc/mysql/my.cnf
- ./master/:/var/lib/mysql
command: --log-bin=mysql-bin --server-id=1
db-slave:
image: mariadb:latest
container_name: db-slave
restart: always
environment:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: db
MYSQL_USER: user
MYSQL_PASSWORD: userpass
volumes:
- ./slave/my.cnf:/etc/mysql/my.cnf
- ./slave/:/var/lib/mysql
command: --log-bin=mysql-bin --server-id=2 --slave-skip-errors=all --skip-slave-start
Here is the my.cnf master:
[mysqld]
server-id = 1
log-bin = mysql-bin
binlog_format = ROW
Slave my.cnf:
[mysqld]
server-id = 2
relay-log = mysql-relay-bin
log-slave-updates = 1
replicate-do-db = db
Could you please help me understand what the problem could be?
Any help will be appreciated!