RabbitMQ系列之RabbitMQ集群

本文的集群是RabbitMq 自身的Cluster搭建 。

#hosts准备:

vim /etc/hosts 

#172.16.3.79 s1     

#172.16.3.105 s2     



172.16.2.10 centos-43     

172.16.2.11 centos-44

#erlang cookie 设置

#path var/lib/rabbitmq/

chmod 755 .erlang.cookie     

vi .erlang.cookie     

cookie     

chomd 600 .erlang.cookie

 #打开EPMD 端口 4369 

[root@centos-43 rabbitmq]# rabbitmqctl stop_app     

Stopping node 'rabbit@centos-43' ...     

...done.     

[root@centos-43 rabbitmq]# rabbitmqctl join_cluster rabbit@centos-44     

Clustering node 'rabbit@centos-43' with 'rabbit@centos-44' ...     

...done.     

[root@centos-43 rabbitmq]# rabbitmqctl start_app     

Starting node 'rabbit@centos-43' ...     

...done.     

[root@centos-43 rabbitmq]# rabbitmqctl cluster_status     

Cluster status of node 'rabbit@centos-43' ...     

[{nodes,[{disc,['rabbit@centos-43','rabbit@centos-44']}]},     

 {running_nodes,['rabbit@centos-44','rabbit@centos-43']},     

 {partitions,[]}]     

...done.

伪集群实例

一台机子启动两个Rabbitmq实例,分别指定不同端口和名称: 

RABBITMQ_NODE_PORT=9991 RABBITMQ_NODENAME=rab /usr/local/rabbitmq/sbin/rabbitmq-server -detached     

RABBITMQ_NODE_PORT=9992 RABBITMQ_NODENAME=rab2 /usr/local/rabbitmq/sbin/rabbitmq-server -detached

你可能感兴趣的:(rabbitmq)