RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件)。RabbitMQ服务器是用Erlang语言编写的,而集群和故障转移是构建在开放电信平台框架上的。所有主要的编程语言均有与代理接口通讯的客户端库。
实验环境
centos6.5_x64
192.168.10.16 mq1_master
192.168.10.14 mq2_slave
4369 erlang发现
5672 client端通信口
25672 server间内部通信口
15672 管理界面ui端口
实验软件
rabbitmq-server-3.7.14-1.el6.noarch.rpm
软件安装
sed -i.bak 's/https/http/g' /etc/yum.repos.d/epel.repo
cp -pv /etc/hosts /etc/hosts.bak
cat /etc/hosts
192.168.10.16 mq1
192.168.10.14 mq2
cp -pv /etc/sysconfig/network /etc/sysconfig/network.bak
cat /etc/sysconfig/network
HOSTNAME=mq1
reboot/init5 重启生效修改主机名
scp /etc/hosts root@192.168.10.14:/etc/
scp -p /etc/sysconfig/network root@192.168.10.14:/etc/sysconfig/ mq1操作
sed -i.bak 's/mq1/mq2/g' /etc/sysconfig/network mq2操作
cp -pv /etc/yum.repos.d/erlang_solutions.repo /etc/yum.repos.d/erlang_solutions.repo.bak
cat /etc/yum.repos.d/erlang_solutions.repo
[erlang-solutions]
name=Centos $releasever - $basearch - Erlang Solutions
baseurl=http://packages.erlang-solutions.com/rpm/centos/$releasever/$basearch
gpgcheck=1
gpgkey=http://packages.erlang-solutions.com/debian/erlang_solutions.asc
enabled=1
yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel erlang socat
yum install -y /root/rabbitmq-server-3.7.14-1.el6.noarch.rpm mq1/m'q2操作
/etc/rc.d/init.d/rabbitmq-server start 启动服务 mq1/mq2操作
chkconfig --level 35 rabbitmq-server on mq1/mq2操作
erl -v
Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]
Eshell V11.0.2 (abort with ^G)
rabbitmqctl status
Status of node rabbit@mq1
rabbitmqctl status
Status of node rabbit@mq2
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user admin admin 添加登入账号 密码
rabbitmqctl set_user_tags admin administrator 给予管理员权限
/etc/init.d/rabbitmq-server restart mq1/mq2操作
cp -pv /var/lib/rabbitmq/.erlang.cookie /var/lib/rabbitmq/.erlang.cookie.bak
scp -p /var/lib/rabbitmq/.erlang.cookie root@192.168.10.14:/var/lib/rabbitmq/ mq1操作
rabbitmqctl stop_app && rabbitmqctl reset
rabbitmqctl join_cluster rabbit@mq1 && rabbitmqctl start_app 配置群集mq2操作
rabbitmqctl cluster_status 查看群集状态mq1操作
Cluster status of node rabbit@mq1 ...
[{nodes,[{disc,[rabbit@mq1,rabbit@mq2]}]},
{running_nodes,[rabbit@mq2,rabbit@mq1]},
{cluster_name,<<"rabbit@mq1">>},
{partitions,[]},
{alarms,[{rabbit@mq2,[]},{rabbit@mq1,[]}]}]
lsof -i:4369
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
epmd 1524 rabbitmq 3u IPv4 10250 0t0 TCP *:epmd (LISTEN)
lsof -i:5672
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
beam.smp 4843 rabbitmq 76u IPv6 15814 0t0 TCP *:amqp (LISTEN)
lsof -i:25672
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
beam.smp 4843 rabbitmq 65u IPv4 15758 0t0 TCP *:25672 (LISTEN)
lsof -i:15672
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
beam.smp 6422 rabbitmq 70u IPv4 49829 0t0 TCP rabbitmq-node1:15672->192.168.10.10:55033 (ESTABLISHED)
beam.smp 6422 rabbitmq 77r IPv4 49821 0t0 TCP *:15672 (LISTEN)
来源:oschina
链接:https://my.oschina.net/u/4349287/blog/4304522