首页 文章

RabbitMQ使用哪些端口?

提问于
浏览
118

RabbitMQ Server使用或需要在防火墙上为节点集群打开哪些端口?

我的 /usr/lib/rabbitmq/bin/rabbitmq-env 设置在下面,我假设是需要的(35197) .

SERVER_ERL_ARGS="+K true +A30 +P 1048576 \   
-kernel inet_default_connect_options [{nodelay,true}] \  
-kernel inet_dist_listen_min 35197 \   
-kernel inet_dist_listen_max 35197"

我没有触及 rabbitmq.config 设置自定义 tcp_listener 所以它应该监听默认的5672 .

以下是相关的netstat行:

tcp        0      0 0.0.0.0:4369           0.0.0.0:*           LISTEN      728/epmd 
tcp        0      0 0.0.0.0:35197          0.0.0.0:*           LISTEN      5126/beam
tcp6       0      0 :::5672                :::*                LISTEN      5126/beam

我的问题是:

  • 对于其他节点能够连接到集群,是否需要打开所有3个端口4369,5672和35197?

  • 为什么5662不是在tcp上运行而不仅仅是tcp6?

4 回答

  • 65

    To find out what ports rabbitmq uses

    $ epmd -names
    

    Outputs:

    epmd: up and running on port 4369 with data:
    name rabbit at port 25672
    

    Run these as root:

    lsof -i :4369
    lsof -i :25672
    

    More about epmd options.

  • 13

    端口访问

    防火墙和其他安全工具可能会阻止RabbitMQ绑定到端口 . 当发生这种情况时,RabbitMQ将无法启动 . 确保可以打开以下端口:

    4369:epmd,RabbitMQ节点和CLI工具使用的对等发现服务

    5672,5671:AMQP 0-9-1和1.0客户端使用没有和使用TLS

    25672:由Erlang发行版用于节点间和CLI工具通信,并从动态范围分配(默认情况下限于单个端口,计算为AMQP端口20000) . 有关详情,请参阅网络指南

    15672:HTTP API客户端和rabbitmqadmin(仅当启用了管理插件时)

    61613,61614:没有和使用TLS的STOMP客户端(仅当启用了STOMP插件时)

    1883,8883 :(如果启用了MQTT插件,则没有和使用TLS的MQTT客户端

    15674:STOMP-over-WebSockets客户端(仅当启用了Web STOMP插件时)

    15675:MQTT-over-WebSockets客户端(仅当启用了Web MQTT插件时)

    参考文档:https://www.rabbitmq.com/install-windows-manual.html

  • 6

    PORT 4369:Erlang使用Port Mapper守护程序(epmd)来解析集群中的节点名称 . 节点必须能够到达彼此并且端口映射器守护程序才能使群集工作 .

    由inet_dist_listen_min / max设置的端口35197防火墙必须允许此范围内的流量在群集节点之间传递

    RabbitMQ管理控制台:

    用于RabbitMQ版本3.x的

    • PORT 15672
      169 PORT 55672 for RabbitMQ pre 3.x.

    PORT 5672 RabbitMQ主端口 .

    对于节点集群,它们必须在 3519743695672 上相互打开 .

    对于任何想要使用消息队列的服务器,只需要 5672 .

  • 134

    RabbitMQ使用哪些端口?

    默认值:5672,手册有答案 . 它在 RABBITMQ_NODE_PORT 变量中定义 .

    https://www.rabbitmq.com/configure.html#define-environment-variables

    The number might be differently if changed by someone in the rabbitmq configuration file:

    vi /etc/rabbitmq/rabbitmq-env.conf
    

    Ask the computer to tell you:

    sudo nmap -p 1-65535 localhost
    
    Starting Nmap 5.51 ( http://nmap.org ) at 2014-09-19 13:50 EDT
    Nmap scan report for localhost (127.0.0.1)
    Host is up (0.00041s latency).
    PORT      STATE         SERVICE
    443/tcp   open          https
    5672/tcp  open          amqp
    15672/tcp open  unknown
    35102/tcp open  unknown
    59440/tcp open  unknown
    

    哦,看,5672和15672

    Use netstat:

    netstat -lntu
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State
    tcp        0      0 0.0.0.0:15672               0.0.0.0:*                   LISTEN
    tcp        0      0 0.0.0.0:55672               0.0.0.0:*                   LISTEN
    tcp        0      0 :::5672                     :::*                        LISTEN
    

    哦,看看5672 .

    use lsof:

    eric@dev ~$ sudo lsof -i | grep beam
    beam.smp  21216    rabbitmq   17u  IPv4 33148214      0t0  TCP *:55672 (LISTEN)
    beam.smp  21216    rabbitmq   18u  IPv4 33148219      0t0  TCP *:15672 (LISTEN)
    

    use nmap from a different machine, find out if 5672 is open:

    sudo nmap -p 5672 10.0.1.71
    Starting Nmap 5.51 ( http://nmap.org ) at 2014-09-19 13:19 EDT
    Nmap scan report for 10.0.1.71
    Host is up (0.00011s latency).
    PORT     STATE SERVICE
    5672/tcp open  amqp
    MAC Address: 0A:40:0E:8C:75:6C (Unknown)    
    Nmap done: 1 IP address (1 host up) scanned in 0.13 seconds
    

    Try to connect to a port manually with telnet, 5671 is CLOSED:

    telnet localhost 5671
    Trying 127.0.0.1...
    telnet: connect to address 127.0.0.1: Connection refused
    

    Try to connect to a port manually with telnet, 5672 is OPEN:

    telnet localhost 5672
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    

    Check your firewall:

    sudo cat /etc/sysconfig/iptables
    

    它应该告诉你哪些端口是打开的:

    -A INPUT -p tcp -m tcp --dport 5672 -j ACCEPT
    

    Reapply your firewall:

    sudo service iptables restart
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Unloading modules:                               [  OK  ]
    iptables: Applying firewall rules:                         [  OK  ]
    

相关问题