在多个服务器上使用mysql-server docker容器创建MySQL集群 [英] Creating a MySQL cluster, using mysql-server docker containers, on multiple servers
问题描述
我正在尝试使用
注意,它说此实例报告其自己的地址为39xxxxxxxxxx:3306".
接下来,我成功在其中一台服务器中创建集群.但是,将其他2台服务器添加到此群集时,出现以下错误
在查看该特定服务器的日志时,我看到以下几行
说对等地址a9yyyyyyyyy:33061无效".这是因为,由于容器在不同的服务器上运行,因此容器ID不能被其他服务器上的其他容器识别.
我尝试了许多选择,但无济于事.一种方法是在启动容器时使用 report-host 和 report-port 选项,例如
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
但是,此方法的问题在于,在dba.configureInstance()期间,它想将端口更新为默认值,并引发类似这样的错误
任何设法创建了这样一个在不同服务器上运行的mysql服务器容器集群的人,在此方面,我将非常感激指针.
我已经阅读了文档和源代码,但没有找到解释为什么监听和通告不同端口会造成问题的原因.
我通过调用mysql-server时使用-port 3301
解决了该问题:
docker run --name = db2 -p 3301:3301 -v db2:/var/lib/mysql -d mysql/mysql-server --report-host = 139.59.11.215 --port 3301
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.
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
这篇关于在多个服务器上使用mysql-server docker容器创建MySQL集群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!