swarm 其他节点无法访问wordpress
来源:7-4 在swarm集群里通过service部署wordpress
yjcia
2018-05-07
实验环境:
三台阿里云服务器
master:59.110.224.16 iZ2zebnlswk1d44x5zohfoZ
worker1:47.94.164.5 iZ2ze5ys0umutubelpncwsZ
worker2:47.104.105.70 iZm5e8mciwctrh1zj1f7r3Z
操作系统 centos ,3306端口已开,8089端口已开
步骤:
1.docker network create -d overlay demo
2.docker service create --name mysql --env MYSQL_ROOT_PASSWORD=root --env MYSQL_DATABASE=wordpress --network demo --mount type=volume,source=mysql-data,destination=/var/lib/mysql -p 3306:3306 mysql:5.7
mysql 服务此时被安装在47.104.105.70上
3.docker service create --name wordpress -p 8089:80 --env WORDPRESS_DB_PASSWORD=root --env WORDPRESS_DB_HOST=47.104.105.70:3306 --network demo wordpress
现象:
1.在创建mysql service时,我必须要-p 3306:3306 才能让wordpress服务访问到
2.在创建wordpress service时,我必须要写明WORDPRESS_DB_HOST=47.104.105.70:3306,也就是指定mysql所在的IP以及端口号3306
只有这样写我才能打开wordpress,但是虽然可以打开但是其他节点缺无法访问到
docker service ls 结果如下:
yqtfn4z75ai3 mysql replicated 1/1 mysql:5.7 *:3306->3306/tcp
ymkaere3fnml wordpress replicated 1/1 wordpress:latest *:8089->80/tcp
master->docker network ls ->存在demo的overlay
worker1->docker network ls ->不存在demo的overlay
worker2->docker network ls ->存在demo的overlay
[root@iZ2zebnlswk1d44x5zohfoZ ~]# docker service logs wordpress
wordpress.1.quo67ighyp3n@iZ2zebnlswk1d44x5zohfoZ | WordPress not found in /var/www/html - copying now...
wordpress.1.quo67ighyp3n@iZ2zebnlswk1d44x5zohfoZ | Complete! WordPress has been successfully copied to /var/www/html
wordpress.1.quo67ighyp3n@iZ2zebnlswk1d44x5zohfoZ | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.0.0.13. Set the 'ServerName' directive globally to suppress this message
wordpress.1.quo67ighyp3n@iZ2zebnlswk1d44x5zohfoZ | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.0.0.13. Set the 'ServerName' directive globally to suppress this message
wordpress.1.quo67ighyp3n@iZ2zebnlswk1d44x5zohfoZ | [Mon May 07 10:17:31.562835 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.5 configured -- resuming normal operations
wordpress.1.quo67ighyp3n@iZ2zebnlswk1d44x5zohfoZ | [Mon May 07 10:17:31.562890 2018] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
wordpress.1.quo67ighyp3n@iZ2zebnlswk1d44x5zohfoZ | 10.255.0.2 - - [07/May/2018:10:17:45 +0000] "GET / HTTP/1.1" 200 18718 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
wordpress.1.quo67ighyp3n@iZ2zebnlswk1d44x5zohfoZ | 10.255.0.2 - - [07/May/2018:10:17:46 +0000] "GET /favicon.ico HTTP/1.1" 200 227 "http://59.110.224.16:8089/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
访问:59.110.224.16:8089
访问其他IP都不行
4回答
-
麦兜搞IT
2018-06-02
为了排除基础网络问题,如果是阿里云或者AWS等,可以让三台机器之间通过内网IP全部打通,安全策略采用允许三台之间之间能相互访问任何其他机器的tcp/udp端口。
122018-06-11 -
Mx钢哥
2020-01-06
我也是 本机搭建的几台虚拟机 能加入swarm集群, 互相之间不能访问
012020-01-07 -
慕无忌8241360
2019-11-22
老哥,我和你一样的问题,你最后解决了吗?
00 -
yjcia
提问者
2018-05-10
通过vagrant 虚拟出的三台linux服务器就没有阿里云的问题,一切正常。
初步怀疑是不是阿里云底层网络有做了限制。
032018-06-02
相似问题