To understand mariadb replication I created the next docker containers:
docker run -e TZ=America/Denver --name mariadb1 --network=camino_nw \
-e MARIADB_SERVER_ID=1 -e MARIADB_LOG_BIN=mysql-bin -e MARIADB_LOG_BASENAME=mariadb1 \
-e MARIADB_BINLOG_FORMAT=mixed -p 127.0.0.1:53301:3306 \
-v /home/jcz/Documents/dockerMariadbData1:/var/lib/mysql:z \
-e MARIADB_ROOT_PASSWORD=S3cretPw -d mariadb:latest
docker run -e TZ=America/Denver --name mariadb2 --network=camino_nw \
-e MARIADB_SERVER_ID=2 -e MARIADB_LOG_BIN=mysql-bin -e MARIADB_LOG_BASENAME=mariadb2 \
-e MARIADB_BINLOG_FORMAT=mixed -p 127.0.0.1:53302:3306 \
-v /home/jcz/Documents/dockerMariadbData2:/var/lib/mysql:z \
-e MARIADB_ROOT_PASSWORD=S3cretPw -d mariadb:latest
docker run -e TZ=America/Denver --name mariadb3 --network=camino_nw \
-e MARIADB_SERVER_ID=3 -e MARIADB_LOG_BIN=mysql-bin -e MARIADB_LOG_BASENAME=mariadb3 \
-e MARIADB_BINLOG_FORMAT=mixed -p 127.0.0.1:53303:3306 \
-v /home/jcz/Documents/dockerMariadbData3:/var/lib/mysql:z \
-e MARIADB_ROOT_PASSWORD=S3cretPw -d mariadb:latest
The master is mariadb1 and for this one I executed:
CREATE USER 'replication_user'@'%' IDENTIFIED BY 'S3cretPw';
GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'%';
For each of the slaves mariadb2 and mariadb3 I run:
CHANGE MASTER TO MASTER_HOST='mariadb1', MASTER_USER='replication_user', MASTER_PASSWORD='S3cretPw', MASTER_PORT=3306, MASTER_CONNECT_RETRY=10;
CHANGE MASTER TO MASTER_USE_GTID = slave_pos;
I also started the slaves with START SLAVE;
After running the
SHOW SLAVE STATUS \G
I got the next error:
Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MariaDB server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).
How can this happen if I used
MARIADB_SERVER_ID=1
MARIADB_SERVER_ID=2
MARIADB_SERVER_ID=3
for each of my containers?
I am trying to follow: