Creating a MySQL cluster, using mysql-server docker containers, on multiple servers

 ̄綄美尐妖づ 提交于 2021-02-10 14:46:32

问题


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-

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

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

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

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.

来源:https://stackoverflow.com/questions/62837078/creating-a-mysql-cluster-using-mysql-server-docker-containers-on-multiple-serv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!