L. Hagen
Basic Pleskian
- Server operating system version
- Ubuntu 22.04
- Plesk version and microupdate number
- Obsidian v18
For a few days I’ve been struggling with a MySQL + Docker + ClusterIP (floating IP or virtual IP) 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 1.1.1.1 (which is the primary server in the cluster) it works well this way.
I’m really guessing that it has something to do with the Docker/Plesk, because a replication with the default installed MariaDB, which is also running on the servers, but outside the docker works fine.
There is also a thread in https://forums.docker.com/t/docker-mysql-replication-fails-with-connection-error-when-server-has-second-ip-address/132395 and a nice guy tried to help me. He has setup the configuration on Docker but not with Plesk and it was working. So it looks like that there is any communication problem with the Docker/Plesk. But what and how to resolve?
BTW: I have also tried to use other ports and have turned of my firewalls for testing purposes.
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 1.1.1.1 (which is the primary server in the cluster) it works well this way.
Setup
The docker is simply configured with this on IP 1.1.1.1 and host with IP 2.2.2.2Now user `replication` is created viadocker 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
Then I start the replication withCREATE USER 'replicator'@'%' IDENTIFIED BY 'replsecrep';
ALTER USER 'replicator'@'%' IDENTIFIED WITH mysql_native_password BY 'replsecrep';
GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'%';
FLUSH PRIVILEGES;
The databases run and work wonderfully and can also be used withCHANGE MASTER TO
MASTER_HOST = '1.1.1.1',
MASTER_PORT = 33060,
MASTER_USER = 'replicator',
MASTER_PASSWORD = REPLPW;
START SLAVE;
from the other server. Withmysql --host=1.1.1.1 --port=33060 -u replicator --password=REPLPW
mysql --host=2.2.2.2 --port=33060 -u replicator --password=REPLPW
I can see that the replication is started and running.SHOW SLAVE STATUS\G;
Problem
Now I assign the ClusterIP to Plesk and restart my Docker containers. But as soon as I start the replication and display the status after 60sec always the error messageThis 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.Last_IO_Error: error connecting to master 'replicator@1.1.1.1:33060' - retry-time: 60 retries: 5 message: Can't connect to MySQL server on '1.1.1.1:33060' (110)
I’m really guessing that it has something to do with the Docker/Plesk, because a replication with the default installed MariaDB, which is also running on the servers, but outside the docker works fine.
There is also a thread in https://forums.docker.com/t/docker-mysql-replication-fails-with-connection-error-when-server-has-second-ip-address/132395 and a nice guy tried to help me. He has setup the configuration on Docker but not with Plesk and it was working. So it looks like that there is any communication problem with the Docker/Plesk. But what and how to resolve?
BTW: I have also tried to use other ports and have turned of my firewalls for testing purposes.