For a few days I’ve been struggling with a MySQL + Docker + ClusterIP problem. I’m trying to create a failover for my servers. If Server1 fails, Server2 should take over automatically. Both servers are running MySQL 8.0.31 (latest image from the hub) in a Docker container. These databases are synchronized with a replication (master->slave or master-master). That’s the idea…
That works quite well so far. The problem now comes when I assign the cluster IP address as the second IP address to the second server. On server1 (which is the primary server in the cluster) it works well this way.
The databases run and work wonderfully and can also be used with
mysql --host=SERVER_IP_1 --port=33060 -u replicator --password=REPLPW mysql --host=SERVER_IP_2 --port=33060 -u replicator --password=REPLPW
from the other server. But as soon as I start the replication and display the status with
SHOW SLAVE STATUS\G;
comes after 60sec always the error message
Last_IO_Error: error connecting to master 'replicator@SERVER2:33060' - retry-time: 60 retries: 5 message: Can't connect to MySQL server on 'SERVER2:33060' (110)
This only happens if both computers are running in the IP cluster. Unfortunately, I do not understand the cause and am urgently looking for a solution.
I’m really guessing that it has something to do with the docker, because a replication with MariaDB which is also running on the servers but outside the docker works fine.
The very simple docker config looks like this:
docker run \ --name dbname \ -v /root/server-mgmt/mysql/mysql.cnf:/etc/my.cnf \ -e MYSQL_ROOT_PASSWORD=ROOTPW \ -e restart=unless-stopped \ -p 33060:3306 \ -p 33061:33060 \ -d mysql:latest
I’m pretty new with docker and have no really an idea how to make it run, but meanwhile I’m convinced that it has something to do with letting docker run in the described environment.