RabbitMQ是一个由erlang开发的AMQP(Advanced Message Queue)的开源实现。
高级消息列队协议,应用于应用层,面向消息中间件设计的他可以接收客户端的请求的消息,传递给后端的主机。
Binding key只用来把Exchange和Queue绑定在一起,并没有实际的路由关系,而Routing key则是将生产者发送的消息路由到exchange绑定到的Queue里面。
Host | 网络信息 |
---|---|
rabbitmq-node1 | ens33:192.168.43.176 |
rabbitmq-node2 | ens33:192.168.43.104 |
rabbitmq-node3 | ens33:192.168.43.23 |
[root@localhost ~]# rpm -ivh erlang-18.1-1.el7.centos.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:erlang-18.1-1.el7.centos ################################# [100%]
[root@localhost ~]# yum -y install socat
[root@localhost ~]# rpm -ivh rabbitmq-server-3.6.15-1.el7.noarch.rpm
warning: rabbitmq-server-3.6.15-1.el7.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:rabbitmq-server-3.6.15-1.el7 ################################# [100%]
[root@localhost ~]# hostname rabbitmq-node1
[root@localhost ~]# vim /etc/hosts
192.168.43.176 rabbitmq-node1
192.168.43.104 rabbitmq-node2
192.168.43.23 rabbitmq-node3
[root@localhost ~]# bash
[root@rabbitmq-node1 ~]# reboot
[root@localhost ~]# rpm -ivh erlang-18.1-1.el7.centos.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:erlang-18.1-1.el7.centos ################################# [100%]
[root@localhost ~]# yum -y install socat
[root@localhost ~]# rpm -ivh rabbitmq-server-3.6.15-1.el7.noarch.rpm
warning: rabbitmq-server-3.6.15-1.el7.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:rabbitmq-server-3.6.15-1.el7 ################################# [100%]
[root@localhost ~]# hostname rabbitmq-node2
[root@localhost ~]# vim /etc/hosts
192.168.43.176 rabbitmq-node1
192.168.43.104 rabbitmq-node2
192.168.43.23 rabbitmq-node3
[root@localhost ~]# bash
[root@rabbitmq-node1 ~]# reboot
[root@localhost ~]# rpm -ivh erlang-18.1-1.el7.centos.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:erlang-18.1-1.el7.centos ################################# [100%]
[root@localhost ~]# yum -y install socat
[root@localhost ~]# rpm -ivh rabbitmq-server-3.6.15-1.el7.noarch.rpm
warning: rabbitmq-server-3.6.15-1.el7.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:rabbitmq-server-3.6.15-1.el7 ################################# [100%]
[root@localhost ~]# vim /etc/hosts
192.168.43.176 rabbitmq-node1
192.168.43.104 rabbitmq-node2
192.168.43.23 rabbitmq-node3
[root@localhost ~]# hostname rabbitmq-node3
[root@localhost ~]# bash
[root@rabbitmq-node1 ~]# reboot
[root@rabbitmq-node1 ~]# systemctl start rabbitmq-server
[root@rabbitmq-node1 ~]# rabbitmqctl cluster_status
Cluster status of node 'rabbit@rabbitmq-node1'
[{nodes,[{disc,['rabbit@rabbitmq-node1']}]},
{running_nodes,['rabbit@rabbitmq-node1']},
{cluster_name,<<"rabbit@rabbitmq-node1">>},
{partitions,[]},
{alarms,[{'rabbit@rabbitmq-node1',[]}]}]
[root@rabbitmq-node2 ~]# systemctl start rabbitmq-server.service
[root@rabbitmq-node2 ~]# rabbitmqctl cluster_status
Cluster status of node 'rabbit@rabbitmq-node2'
[{nodes,[{disc,['rabbit@rabbitmq-node2']}]},
{running_nodes,['rabbit@rabbitmq-node2']},
{cluster_name,<<"rabbit@rabbitmq-node2">>},
{partitions,[]},
{alarms,[{'rabbit@rabbitmq-node2',[]}]}]
[root@rabbitmq-node3 ~]# systemctl start rabbitmq-server.service
[root@rabbitmq-node3 ~]# rabbitmqctl cluster_status
Cluster status of node 'rabbit@rabbitmq-node3'
[{nodes,[{disc,['rabbit@rabbitmq-node3']}]},
{running_nodes,['rabbit@rabbitmq-node3']},
{cluster_name,<<"rabbit@rabbitmq-node3">>},
{partitions,[]},
{alarms,[{'rabbit@rabbitmq-node3',[]}]}]
[root@rabbitmq-node1 ~]# cat /var/lib/rabbitmq/.erlang.cookie
ZXJQWSRSOTPJOWVOGUWG[root@rabbitmq-node1 ~]#
[root@rabbitmq-node1 ~]# iptables -F
[root@rabbitmq-node1 ~]# systemctl stop firewalld
[root@rabbitmq-node1 ~]# setenforce 0
[root@rabbitmq-node1 ~]# iptables-save
[root@rabbitmq-node2 ~]# echo "ZXJQWSRSOTPJOWVOGUWG" > /var/lib/rabbitmq/.erlang.cookie
[root@rabbitmq-node2 ~]# reboot
[root@rabbitmq-node3 ~]# echo "ZXJQWSRSOTPJOWVOGUWG" > /var/lib/rabbitmq/.erlang.cookie
[root@rabbitmq-node3 ~]# reboot
[root@rabbitmq-node2 ~]# systemctl restart rabbitmq-server.service
[root@rabbitmq-node2 ~]# rabbitmqctl cluster_status
Cluster status of node 'rabbit@rabbitmq-node2'
[{nodes,[{disc,['rabbit@rabbitmq-node2']}]},
{running_nodes,['rabbit@rabbitmq-node2']},
{cluster_name,<<"rabbit@rabbitmq-node2">>},
{partitions,[]},
{alarms,[{'rabbit@rabbitmq-node2',[]}]}]
[root@rabbitmq-node2 ~]# iptables -F
[root@rabbitmq-node2 ~]# systemctl stop firewalld
[root@rabbitmq-node2 ~]# setenforce 0
[root@rabbitmq-node2 ~]# iptables-save
[root@rabbitmq-node3 ~]# systemctl restart rabbitmq-server.service
[root@rabbitmq-node3 ~]# rabbitmqctl cluster_status
Cluster status of node 'rabbit@rabbitmq-node3'
[{nodes,[{disc,['rabbit@rabbitmq-node3']}]},
{running_nodes,['rabbit@rabbitmq-node3']},
{cluster_name,<<"rabbit@rabbitmq-node3">>},
{partitions,[]},
{alarms,[{'rabbit@rabbitmq-node3',[]}]}]
[root@rabbitmq-node3 ~]# iptables -F
[root@rabbitmq-node3 ~]# systemctl stop firewalld
[root@rabbitmq-node3 ~]# setenforce 0
[root@rabbitmq-node3 ~]# iptables-save
[root@rabbitmq-node2 ~]# rabbitmqctl stop_app
Stopping rabbit application on node 'rabbit@rabbitmq-node2'
[root@rabbitmq-node2 ~]# rabbitmqctl join_cluster rabbit@rabbitmq-node1
Clustering node 'rabbit@rabbitmq-node2' with 'rabbit@rabbitmq-node1'
[root@rabbitmq-node2 ~]# rabbitmqctl start_app
Starting node 'rabbit@rabbitmq-node2'
[root@rabbitmq-node3 ~]# rabbitmqctl stop_app
Stopping rabbit application on node 'rabbit@rabbitmq-node3'
[root@rabbitmq-node3 ~]# rabbitmqctl join_cluster rabbit@rabbitmq-node1
Clustering node 'rabbit@rabbitmq-node3' with 'rabbit@rabbitmq-node1'
[root@rabbitmq-node3 ~]# rabbitmqctl start_app
Starting node 'rabbit@rabbitmq-node3'
[root@rabbitmq-node1 ~]# rabbitmqctl cluster_status
Cluster status of node 'rabbit@rabbitmq-node1'
[{nodes,[{disc,['rabbit@rabbitmq-node1','rabbit@rabbitmq-node2',
'rabbit@rabbitmq-node3']}]},
{running_nodes,['rabbit@rabbitmq-node3','rabbit@rabbitmq-node2',
'rabbit@rabbitmq-node1']},
{cluster_name,<<"rabbit@rabbitmq-node1">>},
{partitions,[]},
{alarms,[{'rabbit@rabbitmq-node3',[]},
{'rabbit@rabbitmq-node2',[]},
{'rabbit@rabbitmq-node1',[]}]}]
[root@rabbitmq-node1 ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
amqp_client
cowlib
cowboy
rabbitmq_web_dispatch
rabbitmq_management_agent
rabbitmq_management
Applying plugin configuration to rabbit@rabbitmq-node1... started 6 plugins.
[root@rabbitmq-node1 ~]# rabbitmqctl delete_user guest
Deleting user "guest"
[root@rabbitmq-node1 ~]# rabbitmqctl add_user rabbitmq 123.com
Creating user "rabbitmq"
[root@rabbitmq-node1 ~]# rabbitmqctl set_user_tags rabbitmq administrator
Setting tags for user "rabbitmq" to [administrator]
[root@rabbitmq-node1 ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
amqp_client
cowlib
cowboy
rabbitmq_web_dispatch
rabbitmq_management_agent
rabbitmq_management
[root@rabbitmq-node1 ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
amqp_client
cowlib
cowboy
rabbitmq_web_dispatch
rabbitmq_management_agent
rabbitmq_management
[root@rabbitmq-node1 ~]# firefox http://192.168.43.176:15672
[root@rabbitmq-node1 ~]# cd /var/lib/rabbitmq/mnesia/rabbit@rabbitmq-node1/queues/
[root@rabbitmq-node1 queues]# ls
558D7QT8LLHGY08V5IUGO6RSQ
[root@rabbitmq-node1 queues]# cd 558D7QT8LLHGY08V5IUGO6RSQ/
[root@rabbitmq-node1 558D7QT8LLHGY08V5IUGO6RSQ]# ls
0.idx journal.jif
[root@rabbitmq-node2 ~]# cd /var//lib/rabbitmq/mnesia/rabbit@rabbitmq-node2/queues/
[root@rabbitmq-node2 queues]# ls
558D7QT8LLHGY08V5IUGO6RSQ
[root@rabbitmq-node2 queues]# cd 558D7QT8LLHGY08V5IUGO6RSQ/
[root@rabbitmq-node2 558D7QT8LLHGY08V5IUGO6RSQ]# ls
0.idx journal.jif
[root@rabbitmq-node3 ~]# cd /var//lib/rabbitmq/mnesia/rabbit@rabbitmq-node3/queues/
[root@rabbitmq-node3 queues]# ls
558D7QT8LLHGY08V5IUGO6RSQ
[root@rabbitmq-node3 queues]# cd 558D7QT8LLHGY08V5IUGO6RSQ/
[root@rabbitmq-node3 558D7QT8LLHGY08V5IUGO6RSQ]# ls
0.idx journal.jif