Loading...
CentOS 6.7 配置文件的方式部署RabbitMQ消息中间件集群

RabbitMQ笔记 2015/12/18 RabbitMQ , CentOS

CentOS 6.7 配置文件的方式部署RabbitMQ消息中间件

#准备工作

分别在名为centos1、centos2的Centos 6.7 Linux上安装部署独立节点的RabbitMQ:http://imethan.cn/blog/article/78


#安装完成后停止RabbitMQ节点服务

[root@centos1 bin]# rabbitmqctl stop

[root@centos2 bin]# rabbitmqctl stop


#配置文件方式部署说明

默认安装部署的RabbitMQ并没有生成配置文件,采用的是运行时参数配置和策略(runtime parameters and policies);自定义配置时,需要手动的创建配置文:rabbitmq-env.conf(environment variables)、rabbitmq.config(a configuration file),创建的配置文件置于“/etc/rabbitmq”目录下。


#创建环境变量配置文件:rabbitmq-env.conf(这步配置可以略过)

将节点名称更改为“imethan@centos1”


vi /etc/rabbitmq/rabbitmq-env.conf

#example rabbitmq-env.conf file entries

#Rename the node

NODENAME=rabbit@centos1

#Config file location and new filename bunnies.config

#CONFIG_FILE=/etc/rabbitmq/testdir/bunnies


#创建配置文件:rabbitmq.config

分别在centos1、centos2上创建如下配置文件:

vi /etc/rabbitmq/rabbitmq.config


[

    {mnesia, [{dump_log_write_threshold, 1000}]},

    {rabbit, [{tcp_listeners, [5673]},{cluster_nodes,{['rabbit@centos1','rabbit@centos2'], disc}}]},

    {rabbitmq_management, [{listener, [{port, 45672}]}]}

].


#创建完成后启动centos1上的RabbitMQ Master节点和重置centos2上的RabbitMQ Slave节点

#在Master节点上执行

[root@centos1 bin]# rabbitmq-server -detached


#在Slave节点上执行

[root@centos2 bin]# rabbitmqctl stop_app

[root@centos2 bin]# rabbitmqctl reset

[root@centos2 bin]# rabbitmqctl start_app


#确认集群配置是否成功

[root@centos2 bin]# rabbitmqctl cluster_status

Cluster status of node rabbit@centos2 ...

[{nodes,[{disc,[rabbit@centos1,rabbit@centos2]}]},

 {running_nodes,[rabbit@centos1,rabbit@centos2]},

 {cluster_name,<<"rabbit@centos1.imethan.cn">>},

 {partitions,[]}]


NameFile descriptors (?)Socket descriptors (?)Erlang processesMemoryDisk spaceInfo+/-
rabbit@centos1
20
1024 available
1
829 available
176
1048576 available
38MB
395MB high watermark
13GB
48MB low watermark
Disc 1 Stats
rabbit@centos2
20
1024 available
1
829 available
175
1048576 available
38MB
395MB high watermark
12GB
48MB low watermark
Disc 1




#参考文档

http://www.rabbitmq.com/configure.html

http://jessesnet.com/development-notes/2015/rabbitmq-cluster/




Comments