zoukankan      html  css  js  c++  java
  • RabbitMQ集群搭建

    准备三个节点,系统为CentOS7

    Node IP
    rabbitmq01 172.50.0.64
    rabbitmq02 172.50.0.65
    rabbitmq03 172.50.0.66

    这里把node1作为master节点。

    1、修改各节点hosts

    # vim /etc/hosts
    172.50.0.64     rabbitmq01
    172.50.0.65     rabbitmq02
    172.50.0.66     rabbitmq03
    

    2、在各节点安装rabbitmq-server,并启动服务

    # yum install -y rabbitmq-server
    # systemctl start rabbitmq-server
    # systemctl enable rabbitmq-server
    

    3、启用各节点RabbitMQ Web管理插件,监听15672端口

    # rabbitmq-plugins list            
    # rabbitmq-plugins enable rabbitmq_management      
    	The following plugins have been enabled:
    	  mochiweb
    	  webmachine
    	  rabbitmq_web_dispatch
    	  amqp_client
    	  rabbitmq_management_agent
    	  rabbitmq_management
    	Plugin configuration has changed. Restart RabbitMQ for changes to take effect.
    
    # systemctl start rabbitmq-server
    # netstat -tnlp 
    

    4、用浏览器访问

    http://172.16.100.186:15672/
    默认账号和密码都是guest;
    

    5、将master节点的cookie文件复制到各slave节点

    # scp /var/lib/rabbitmq/.erlang.cookie node2:/var/lib/rabbitmq/
    # scp /var/lib/rabbitmq/.erlang.cookie node3:/var/lib/rabbitmq/
    

    6、停止slave上的app,并将slave节点加入到集群

    # rabbitmqctl stop_app
    # rabbitmqctl join_cluster rabbit@node1
    # rabbitmqctl start_app
    

    7、将各slave加入集群后,查看集群状态

    # rabbitmqctl cluster_status
    Cluster status of node 'rabbit@rabbitmq01' ...
    [{nodes,[{disc,['rabbit@rabbitmq01','rabbit@rabbitmq02',
                    'rabbit@rabbitmq03']}]},
     {running_nodes,['rabbit@rabbitmq02','rabbit@rabbitmq03',
                     'rabbit@rabbitmq01']},
     {cluster_name,<<"rabbit@rabbitmq01">>},
     {partitions,[]}]
    ...done.
    

    8、使用haproxy创建LB集群,在haproxy server上单独创建一个配置文件

    # vim /etc/rabbitmq.cfg
    listen rabbitmq :5672
            mode tcp
            balance roundrobin
            server rabbit01 172.50.0.64:5672 check inter 5000
            server rabbit02 172.50.0.65:5672 check inter 5000
            server rabbit03 172.50.0.66:5672 check inter 5000
    
    listen rabbitmqui :15672
            mode http
            balance roundrobin
            server rabbit01 172.50.0.64:15672 check inter 5000
            server rabbit02 172.50.0.65:15672 check inter 5000
            server rabbit03 172.50.0.66:15672 check inter 5000
    
    # haproxy -f /etc/rabbitmq.cfg
    

    9、用浏览器访问haproxy server的地址和端口
    http://172.16.100.186:15672/

  • 相关阅读:
    检测服务器是否开启重协商功能(用于CVE-2011-1473漏洞检测)
    Wireshark解密HTTPS流量的两种方法
    text2pcap: 将hex转储文本转换为Wireshark可打开的pcap文件
    Hibernate框架(五)Hibernate主键生成策略
    HIbernate框架(四)实现添加操作
    Hibernaete框架(三)搭建hibernate环境(重点)
    Hibernate框架(二)什么是orm思想(重点)
    Hibernate框架(一)Hibernate框架是什么?
    拦截器和过滤器的区别
    谈谈java中遍历Map的几种方法
  • 原文地址:https://www.cnblogs.com/keithtt/p/6528199.html
Copyright © 2011-2022 走看看