2

I'm trying to create an MySQL cluster of 3 nodes using mysql-server docker containers.

I have 3 separate cloud instances and docker is setup on all 3 of them. Each server will have only 1 container running on it - to achieve High Availability when in cluster.

I start the containers on all 3 servers, individually, with the command

docker run --name=db -p 3301:3306 -v db:/var/lib/mysql -d mysql/mysql-server

I'm mapping the port 3306 of container to my server's 3301 port. I've also created a new user 'clusteradmin' for remote access.

Next, from mysql-shell, I ran following command - for all 3 servers

dba.configureInstance('clusteradmin@serverIp:3301')

I get similar message for all- enter image description here

Note that it says 'This instance reports its own address as 39xxxxxxxxxx:3306'.

Next I create a cluster in one of the server successfully. But, when adding the other 2 servers to this cluster, I'm getting the following error

enter image description here

On checking the logs for that particular server, I see the following lines

enter image description here

It says 'peer address a9yyyyyyyyyy:33061 is not valid'. This is because, since the containers are running on different servers, the container-id is not recognised by other containers on other server.

I tried many options but to no avail. One method was to use report-host and report-port options when starting the container, like so

docker run --name=db2 -p 3301:3306 -v db2:/var/lib/mysql -d mysql/mysql-server --report-host=139.59.11.215 --report-port=3301

But, the issue with this approch is that, during dba.configureInstance(), it wants to update the port to default value and throws error like so

enter image description here

Anybody who has managed to create such a cluster of mysql-server containers running on different servers, I would really appreciate pointers in this regard.

Rick James
  • 135,179
  • 13
  • 127
  • 222
Chandra Kanth
  • 348
  • 2
  • 13

1 Answers1

0

I have gone over the documentation and source code but have not found an explanation why listening and advertising different ports is problematic.

I have solved the problem by using --port 3301 when invoking mysql-server:

docker run --name=db2 -p 3301:3301 -v db2:/var/lib/mysql -d mysql/mysql-server --report-host=139.59.11.215 --port 3301
mac-p
  • 140
  • 1
  • 6