需求:在centos上开启docker跑mysql,在ubuntu上开启docker跑tomcat

要求tomcat使用mysql

两台虚拟机,分别装了 centos 和 ubuntu

使用ifconfig 修改 ip:ifconfig ens33 10.151.134.163

这样打的话 会设置默认的netmask,没有发现,很坑

后来要重启网卡重新设置才有效果,(ifconfig ens33 down , ifconfig ens33 up, ifconfig ens33 10.151.134.163 netmask 255.255.255.0)

顺便添加路由 route add -net 10.151.134.0 netmask 255.255.255.0 gw 10.151.134.2 或 route add defalut gw 10.151.134.2 添加默认网关

还有就是ping了可以ping通,但是telnet显示 no route to host,排查了许久发现是 centos 的防火墙没开 :firewall-cmd --list-port 查看端口,firewall-cmd --zone=public --add-port xxxx 添加防火墙(如果不加上--permanent参数, reload 之后会把之前开的端口取消掉,所以一定要加)

搞了一个小时,本来十几分钟能做完的,防止踩坑,记录下来

相关文章:

  • 2021-07-31
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-24
  • 2021-07-23
  • 2021-10-09
猜你喜欢
  • 2022-12-23
  • 2021-12-07
  • 2021-04-15
  • 2021-05-14
  • 2021-09-05
  • 2021-10-19
  • 2021-06-05
相关资源
相似解决方案