• Docker 启动RabbitMQ 服务,外部不能正常访问


    今天在总结RabbitMQ消息队列服务器时,遇到一个小问题:服务器拉取RabbitMQ 服务器镜像正常,启动RabbitMQ 镜像服务正常,但通过外部访问RabbitMQ 管理端提示无法访问。

    第一步:检查服务器的防火墙状态(firewalld)

    核心指令:

    systemctl status firewalld.service  // 查看防火墙状态

    systemctl stop firewalld.service    //关闭防火墙状态

    1. [root@localhost ~]# systemctl status firewalld.service
    2. ● firewalld.service - firewalld - dynamic firewall daemon
    3. Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
    4. Active: inactive (dead) since 六 2022-06-18 01:33:04 CST; 1 months 13 days ag
    5. Docs: man:firewalld(1)
    6. Main PID: 30715 (code=exited, status=0/SUCCESS)
    7. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAILED:
    8. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAILED:
    9. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAILED:
    10. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAILED:
    11. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAILED:
    12. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAILED:
    13. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAILED:
    14. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAILED:
    15. 618 01:33:02 localhost.localdomain systemd[1]: Stopping firewalld - dynamic f
    16. 618 01:33:04 localhost.localdomain systemd[1]: Stopped firewalld - dynamic fi
    17. Hint: Some lines were ellipsized, use -l to show in full.
    18. [root@localhost ~]# systemctl stop firewalld.service
    19. [root@localhost ~]# systemctl status firewalld.service
    20. ● firewalld.service - firewalld - dynamic firewall daemon
    21. Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
    22. Active: inactive (dead) since 六 2022-06-18 01:33:04 CST; 1 months 13 days ago
    23. Docs: man:firewalld(1)
    24. Main PID: 30715 (code=exited, status=0/SUCCESS)
    25. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAI...
    26. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAI...
    27. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAI...
    28. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAI...
    29. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAI...
    30. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAI...
    31. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAI...
    32. 618 00:04:01 localhost.localdomain firewalld[30715]: WARNING: COMMAND_FAI...
    33. 618 01:33:02 localhost.localdomain systemd[1]: Stopping firewalld - dynam...
    34. 618 01:33:04 localhost.localdomain systemd[1]: Stopped firewalld - dynami...
    35. Hint: Some lines were ellipsized, use -l to show in full.

    结果:问题还是没有解决

    2、检查防火墙日志

    核心指令:tail /var/log/firewalld

    1. [root@localhost log]# tail /var/log/firewalld
    2. 2022-06-18 00:04:01 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t filter -F DOCKER' failed: iptables: No chain/target/match by that name.
    3. 2022-06-18 00:04:01 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t filter -X DOCKER' failed: iptables: No chain/target/match by that name.
    4. 2022-06-18 00:04:01 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t filter -F DOCKER-ISOLATION' failed: iptables: No chain/target/match by that name.
    5. 2022-06-18 00:04:01 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t filter -X DOCKER-ISOLATION' failed: iptables: No chain/target/match by that name.
    6. 2022-06-18 00:04:01 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables: Bad rule (does a matching rule exist in that chain?).

    重点关注错误日志:2022-06-18 00:04:01 WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables: Bad rule (does a matching rule exist in that chain?).

    google 和百度后得知:docker默认会自动添加iptables rule

    解决办法:docker.service禁止修改iptables

    3、修改docker.service 服务,禁用修改iptables.

    [root@localhost system]# vi /lib/systemd/system/docker.service

    1. [Service]
    2. Type=notify
    3. # the default is not to use systemd for cgroups because the delegate issues still
    4. # exists and systemd currently does not support the cgroup feature set required
    5. # for containers run by docker
    6. ExecStart=/usr/bin/dockerd --iptables=false

    在ExecStart 添加 --iptables=false.

    重新启动docker 容器服务:

    1. [root@localhost system]# systemctl daemon-reload
    2. [root@localhost system]# systemctl restart docker

    重新启动RabbitMQ 服务:

    1. [root@localhost system]# docker restart 4b0032
    2. 4b0032
    3. [root@localhost system]# docker ps
    4. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    5. 4b0032878886 6c3c2a225947 "docker-entrypoint.s…" 47 hours ago Up 3 seconds 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp rabbitmq

    RabbitMQ服务管理界面,能够正常方法。

  • 相关阅读:
    云原生(三十) | Kubernetes篇之应用商店-Helm
    Hadoop总结
    基于JAVA+SpringBoot+VUE+微信小程序的前后端分离咖啡小程序
    为什么引用CSS的link标签放在头部,引用JS的script标签放在body结束标签之前?
    我的Vue之旅、02 ES6基础、模块、路径、IO
    guava缓存
    《Java面向对象程序设计》学习笔记——第 15 章 Java 多线程机制
    详解Python中的json库
    回归拟合 | 灰狼算法优化核极限学习机(GWO-KELM)MATLAB实现
    SpringBoot整合MQTT总结
  • 原文地址:https://blog.csdn.net/zhouzhiwengang/article/details/126096229