zoukankan      html  css  js  c++  java
  • rabbitmq 端口作用以及修改方法

    rabbitmq 端口

    参考 https://www.rabbitmq.com/networking.html#ports
    
    Port Access
    
    RabbitMQ nodes bind to ports (open server TCP sockets) in order to accept client and CLI tool connections. Other processes and tools such as SELinux may prevent RabbitMQ from binding to a port. When that happens, the node will fail to start.
    
    CLI tools, client libraries and RabbitMQ nodes also open connections (client TCP sockets). Firewalls can prevent nodes and CLI tools from communicating with each other. Make sure the following ports are accessible:
    
        4369: epmd, a peer discovery service used by RabbitMQ nodes and CLI tools
        5672, 5671: used by AMQP 0-9-1 and 1.0 clients without and with TLS
        25672: used for inter-node and CLI tools communication (Erlang distribution server port) and is allocated from a dynamic range (limited to a single port by default, computed as AMQP port + 20000). Unless external connections on these ports are really necessary (e.g. the cluster uses federation or CLI tools are used on machines outside the subnet), these ports should not be publicly exposed. See networking guide for details.
        35672-35682: used by CLI tools (Erlang distribution client ports) for communication with nodes and is allocated from a dynamic range (computed as server distribution port + 10000 through server distribution port + 10010). See networking guide for details.
        15672: HTTP API clients, management UI and rabbitmqadmin (only if the management plugin is enabled)
        61613, 61614: STOMP clients without and with TLS (only if the STOMP plugin is enabled)
        1883, 8883: MQTT clients without and with TLS, if the MQTT plugin is enabled
        15674: STOMP-over-WebSockets clients (only if the Web STOMP plugin is enabled)
        15675: MQTT-over-WebSockets clients (only if the Web MQTT plugin is enabled)
        15692: Prometheus metrics (only if the Prometheus plugin is enabled)
    
    

    默认5672端口号修改

    第一种方法:

    在/etc/rabbitmq/rabbitmq.conf配置文件中加上如下配置:
    
    listeners.tcp.default = 5678
    
    或者
    
    [
      {rabbit, [
          {tcp_listeners, [5678]}
        ]
      }
    ]
    

    上面的示例将更改RabbitMQ监听AMQP0-9-1和AMQP 1.0协议客户端的连接端口从5672到5678。

    参考 https://www.rabbitmq.com/configure.html

    A minimalistic example configuration file follows:
    
    # this is a comment
    listeners.tcp.default = 5673
    
    The same example in the classic config format:
    
    %% this is a comment
    [
      {rabbit, [
          {tcp_listeners, [5673]}
        ]
      }
    ].
    
    This example will alter the port RabbitMQ listens on for AMQP 0-9-1 and AMQP 1.0 client connections from 5672 to 5673.
    

    RabbitMQ服务器源存储库包含一个名为RabbitMQ.conf.example的配置文件示例,它包含你可能想要设置的大多数配置项的示例(省略了一些非常模糊的匹配项)。

    第二种方法:

    在/etc/rabbitmq/rabbitmq-env.conf配置文件中添加如下配置:

    NODE_PORT=5673

    1
    
    rabbitmq-env.conf配置文件中的配置优先级高于rabbitmq.conf配置文件中的配置
    

    默认15672端口号更改

    参考 https://www.rabbitmq.com/management.html#configuration

    listeners.tcp.default = 5672
    
    collect_statistics_interval = 10000
    
    ## Note: this uses the core `load_definitions` key over
    ## now deprecated `management.load_definitions`
    # load_definitions = /path/to/exported/definitions.json
    
    management.tcp.port = 15672
    management.tcp.ip   = 0.0.0.0
    
    management.ssl.port       = 15671
    management.ssl.ip         = 0.0.0.0
    management.ssl.cacertfile = /path/to/ca_certificate.pem
    management.ssl.certfile   = /path/to/server_certificate.pem
    management.ssl.keyfile    = /path/to/server_key.pem
    
    management.http_log_dir = /path/to/rabbit/logs/http
    
    management.rates_mode = basic
    
    # Configure how long aggregated data (such as message rates and queue
    # lengths) is retained.
    # Your can use 'minute', 'hour' and 'day' keys or integer key (in seconds)
    management.sample_retention_policies.global.minute    = 5
    management.sample_retention_policies.global.hour  = 60
    management.sample_retention_policies.global.day = 1200
    
    management.sample_retention_policies.basic.minute   = 5
    management.sample_retention_policies.basic.hour = 60
    
    management.sample_retention_policies.detailed.10 = 5
    

    在/etc/rabbitmq/rabbitmq.conf配置文件中加上如下配置:

    management.tcp.port = 15673
    

    默认25672端口号更改

    参考 https://www.rabbitmq.com/networking.html

    Inter-node Communication Port Range
    
    RabbitMQ nodes will use a port from a certain range known as the inter-node communication port range. The same port is used by CLI tools when they need to contact the node. The range can be modified.
    
    RabbitMQ nodes communicate with CLI tools and other nodes using a port known as the distribution port. It is dynamically allocated from a range of values. For RabbitMQ, the default range is limited to a single value computed as RABBITMQ_NODE_PORT (AMQP 0-9-1 and AMQP 1.0 port) + 20000, which results in using port 25672. This single port can be configured using the RABBITMQ_DIST_PORT environment variable.
    

    25672端口用于节点间和CLI工具通信(Erlang分发服务器端口),并从动态范围分配(默认情况下仅限于单个端口,计算方式为AMQP 0-9-1和AMQP 1.0端口+20000),默认情况下通过 RABBITMQ_NODE_PORT 计算是25672,也可以通过RABBITMQ_DIST_PORT环境变量配置

    rabbitmq-env.conf

    在/etc/rabbitmq/rabbitmq-env.conf配置文件中添加如下配置:

    通过设置 RABBITMQ_NODE_PORT计算 RABBITMQ_DIST_PORT 端口:

    RABBITMQ_NODE_PORT=5674
    

    RABBITMQ_DIST_PORT = Default: RABBITMQ_NODE_PORT + 20000

    RABBITMQ_DIST_PORT 这个可以自己设置,也可以根据规则 RABBITMQ_NODE_PORT + 20000 算出来

    RABBITMQ_DIST_PORT=25674
    

    上面两种方案一种是直接设置节点和CLI工具通信的分发端口,另外一种是通过设置RabbitMQ服务器和客户端之间通信端口并计算得到25674端口号。

    默认4369端口号更改

    EPMD默认端口号是4369,但是可以使用ERL_EPMD_PORT环境变量更改。

    ERL_EPMD_PORT Port used by epmd, a component in inter-node and CLI tool communication.
    Default: 4369

    列出在当前运行的epmd中绑定注册的端口号及监听的分发端口:

    [root@mq ~]# epmd -names
    epmd: up and running on port 4369 with data:
    name rabbit at port 25672
    [root@mq ~]# 
    

    修改端口号参考

    https://www.rabbitmq.com/networking.html#epmd

    EPMD Interface
    
    epmd will listen on all interfaces by default. It can be limited to a number of interfaces using the ERL_EPMD_ADDRESS environment variable:
    
    # makes epmd listen on loopback IPv6 and IPv4 interfaces
    export ERL_EPMD_ADDRESS="::1"
    
    When ERL_EPMD_ADDRESS is changed, both RabbitMQ node and epmd on the host must be stopped. For epmd, use
    
    # Stops local epmd process.
    # Use after shutting down RabbitMQ.
    epmd -kill
    
    to terminate it. The service will be started by the local RabbitMQ node automatically on boot.
    
    The loopback interface will be implicitly added to that list (in other words, epmd will always bind to the loopback interface).
    EPMD Port
    
    The default epmd port is 4369, but this can be changed using the ERL_EPMD_PORT environment variable:
    
    # makes epmd bind to port 4369
    export ERL_EPMD_PORT="4369"
    
    All hosts in a cluster must use the same port.
    
    When ERL_EPMD_PORT is changed, both RabbitMQ node and epmd on the host must be stopped. For epmd, use
    
    # Stops local epmd process.
    # Use after shutting down RabbitMQ.
    epmd -kill
    
    to terminate it. The service will be started by the local RabbitMQ node automatically on boot.
    

    修改epmd守护进程绑定的端口号:

    export ERL_EPMD_PORT="4369"
    

    杀死epmd守护进程指令:

    epmd -kill
    

    当然直接在系统中使用export命令设置环境变量是可以生效的,但是只要系统重启环境变量就失效;可以在/etc/profile或/root/.bashrc文件配置系统环境变量,然后source 文件名就可以永久生效了。

  • 相关阅读:
    解决 Cordova 打包 vue项目为 APP 后,在安卓平台下 touchMove 事件不生效的问题
    解决微信内置浏览器里,下拉无法捕获 touchEnd 事件
    记录 React-native 项目中的各种坑坑
    内存型游戏外挂讲解
    浅谈数据抓取的几种方法
    php链表笔记:合并两个有序链表
    php链表笔记:链表的检测
    php链表笔记:单链表反转
    使用UUID和int自增主键的区别
    lumen框架使用Elasticsearch详解
  • 原文地址:https://www.cnblogs.com/fb010001/p/14609766.html
Copyright © 2011-2022 走看看