美文网首页
rabbitMQ搭建

rabbitMQ搭建

作者: droid_zf | 来源:发表于2019-05-24 14:44 被阅读0次

    1.环境和版本

    服务器:centos
    rabbitmq版本号:rabbitmq-server-3.3.5-34.el7.noarch

    • 使用端口号
    节点名 AMQP Web MQTT STOMP
    rabbit 5672 15672 1883 61613
    rabbit2 5673 15673 1884 61614
    rabbit3 5674 15674 1885 61615

    AMQP协议端口默认:5672
    Web页面默认端口:15672
    MQTT协议默认端口:1883
    STOMP协议默认端口:61613
    默认登录用户名(admin权限):guest
    默认登录密码:guest

    • 备注:外网连接需更改firewall防火墙配置

    firewall-cmd --permanent --zone=public --add-port=15672/tcp
    systemctl restart firewalld

    2.步骤

    2.1安装rabbitmq和相关软件
    yum -y install wget vim bash-completion lrzsz nmap telnet tree net-tools bind-utils lsof ntpdate iotop
    erlang
    wget -O/etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    yum -y install erlang
    yum -y install rabbitmq-server
    #查看安装结果
    rpm -qa | grep rabbitmq
    #开启Web管理页面:
    rabbitmq-plugins enable rabbitmq_management
    #开启MQTT协议:
    rabbitmq-plugins enable rabbitmq_mqtt
    
    2.2配置
    配置并启动第一个节点
    #停止默认启动的那个节点
    sudo rabbitmqctl stop_app
    sudo rabbitmqctl stop
    RABBITMQ_NODE_PORT=5672 RABBITMQ_NODENAME=rabbit@localhost rabbitmq-server -detached
    
    配置并启动第二个节点
    RABBITMQ_NODE_PORT=5673 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}] -rabbitmq_stomp tcp_listeners [61614] -rabbitmq_mqtt tcp_listeners [1884]" RABBITMQ_NODENAME=rabbit2@localhost rabbitmq-server -detached
    #加入集群
    #停掉rabbit2节点应用
    rabbitmqctl -n rabbit2@localhost stop_app
    rabbitmqctl -n rabbit2@localhost reset
    #将rabbit2添加到rabbit节点中
    rabbitmqctl -n rabbit2@localhost join_cluster rabbit@localhost
    rabbitmqctl -n rabbit2@localhost start_app
    
    配置并启动第三个节点
    RABBITMQ_NODE_PORT=5674 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15674}] -rabbitmq_stomp tcp_listeners [61615] -rabbitmq_mqtt tcp_listeners [1885]" RABBITMQ_NODENAME=rabbit3@localhost rabbitmq-server -detached
    #停掉rabbit3节点应用
    rabbitmqctl -n rabbit3@localhost stop_app
    rabbitmqctl -n rabbit3@localhost reset
    #将rabbit3添加到rabbit节点中
    rabbitmqctl -n rabbit3@localhost join_cluster rabbit@localhost
    rabbitmqctl -n rabbit3@localhost start_app
    

    相关文章

      网友评论

          本文标题:rabbitMQ搭建

          本文链接:https://www.haomeiwen.com/subject/qfigzqtx.html