• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion
  • Inviting everyone to the UX test of a new security feature in the WP Toolkit
    For WordPress site owners, threats posed by hackers are ever-present. Because of this, we are developing a new security feature for the WP Toolkit. If the topic of WordPress website security is relevant to you, we would be grateful if you could share your experience and help us test the usability of this feature. We invite you to join us for a 1-hour online session via Google Meet. Select a convenient meeting time with our friendly UX staff here.

Issue Docker with MySQL blocks communication

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.

Setup​

The docker is simply configured with this on IP 1.1.1.1 and host with IP 2.2.2.2
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
Now user `replication` is created via
CREATE USER 'replicator'@'%' IDENTIFIED BY 'replsecrep';
ALTER USER 'replicator'@'%' IDENTIFIED WITH mysql_native_password BY 'replsecrep';
GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'%';
FLUSH PRIVILEGES;
Then I start the replication with
CHANGE MASTER TO
MASTER_HOST = '1.1.1.1',
MASTER_PORT = 33060,
MASTER_USER = 'replicator',
MASTER_PASSWORD = REPLPW;
START SLAVE;
The databases run and work wonderfully and can also be used with
mysql --host=1.1.1.1 --port=33060 -u replicator --password=REPLPW
mysql --host=2.2.2.2 --port=33060 -u replicator --password=REPLPW
from the other server. With
SHOW SLAVE STATUS\G;
I can see that the replication is started and running.

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 message
Last_IO_Error: error connecting to master '[email protected]:33060' - retry-time: 60 retries: 5 message: Can't connect to MySQL server on '1.1.1.1: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/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.
 
Back
Top