千万PV----RabbitMQ集群配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了千万PV----RabbitMQ集群配置相关的知识,希望对你有一定的参考价值。

RabbitMQ简介:
RabbitMQ是一个消息代理(message broker),主要功能就是接收和转发消息。向RabbitMQ发送消息的程序叫做Producer(生产者)。从队列接收消息的程序叫做Consumer(消费者)。
队列(queue)用来存储消息,可以理解成一个无限容量的缓冲区。多个Producer可以向一个队列发送消息,多个Consumer也可以从一个队列接收消息。
技术分享图片
实验环境配置:(操作系统:CentOS7)
rabbitma01 192.168.120.138(磁盘节点)
rabbitma02 192.168.120.139(内存节点)
rabbitma03 192.168.120.140(内存节点)
--------------使用Centos7.4自带的YUM源安装--三台都一样------需要公网环境-------

#更改主机名
[[email protected] ~]# vim /etc/hostname
mq01.localdomain (操作相同,只是主机名01、02、03)
[[email protected] ~]# vim /etc/hosts
192.168.120.138 mq01
192.168.120.139 mq02
192.168.120.140 mq03
#重启系统
[[email protected] ~]#init 6
#三台防火墙都关闭
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# setenforce 0
[[email protected] ~]# yum install epel-release -y
[[email protected] ~]# yum install rabbitmq-server -y
--------------------磁盘节点01-------------------------
#优化路径
[[email protected] ~]# ln -s /usr/lib/rabbitmq/bin/ /usr/bin/
[[email protected] ~]# rabbitmq-plugins list
#开启rabbitmq
[[email protected] ~]# rabbitmq-plugins enable rabbitmq_management
[[email protected] ~]# systemctl start rabbitmq-server.service
[[email protected] ~]# rabbitmqctl cluster_status
Cluster status of node [email protected] ...br/>[{nodes,[{disc,[[email protected]]}]},
{running_nodes,[[email protected]]},
br/>{cluster_name,<<"[email protected]">>},
{partitions,[]}]
...done. ###连接成功###
[[email protected] ~]# netstat -ntap | grep 5672
tcp 0 0 0.0.0.0:15672 0.0.0.0:
LISTEN 3018/beam
tcp 0 0 0.0.0.0:25672 0.0.0.0: LISTEN 3018/beam
tcp6 0 0 :::5672 :::
LISTEN 3018/beam

---------------------内存节点02----------------------------
[[email protected] ~]# ln -s /usr/lib/rabbitmq/bin/* /usr/bin/
[[email protected] ~]# rabbitmq-plugins enable rabbitmq_management
[[email protected] ~]# systemctl start rabbitmq-server.service
[[email protected] ~]# rabbitmqctl cluster_status
Cluster status of node [email protected] ...
br/>[{nodes,[{disc,[[email protected]]}]},
{running_nodes,[[email protected]]},
br/>{cluster_name,<<"[email protected]">>},
{partitions,[]}]
...done.

--------------------内存节点03-----------------------------------
[[email protected] ~]# ln -s /usr/lib/rabbitmq/bin/* /usr/bin/
[[email protected] ~]# rabbitmq-plugins enable rabbitmq_management
[[email protected] ~]# systemctl start rabbitmq-server.service
[[email protected] ~]# rabbitmqctl cluster_status
Cluster status of node [email protected] ...
br/>[{nodes,[{disc,[[email protected]]}]},
{running_nodes,[[email protected]]},
br/>{cluster_name,<<"[email protected]">>},
{partitions,[]}]
...done.
####操作都相同#####
##关闭三台rabbitmq服务##
[[email protected] ~]# systemctl stop rabbitmq-server.service

##进入第一台##
[[email protected] ~]# vim /var/lib/rabbitmq/.erlang.cookie
SNBTPYOBNPXOMBFNWAZA ##(复制序列号)

##进入第二台##
[[email protected] ~]# vim /var/lib/rabbitmq/.erlang.cookie
SNBTPYOBNPXOMBFNWAZA ##将第一台的序列号复制粘贴下来,要一致
##进入第三台##
[[email protected] ~]# vim /var/lib/rabbitmq/.erlang.cookie
SNBTPYOBNPXOMBFNWAZA ##都和第一台一致

##三台服务启动##
[[email protected] ~]# systemctl start rabbitmq-server.service
================在02、03上操作-----内存节点=======
[[email protected] ~]# rabbitmqctl stop_app
Stopping node [email protected] ...
...done.
##以内存模式进行添加##
[[email protected] ~]# rabbitmqctl join_cluster --ram [email protected]
Clustering node [email protected] with [email protected] ...
...done.
##开启app##
[[email protected] ~]# rabbitmqctl start_app
Starting node [email protected] ...
...done.

##第三台同样操作##
[[email protected] ~]# rabbitmqctl stop_app
Stopping node [email protected] ...
...done.
[[email protected] ~]# rabbitmqctl join_cluster --ram [email protected]
Clustering node [email protected] with [email protected] ...
...done.
##开启app##
[[email protected] ~]# rabbitmqctl start_app
Starting node [email protected] ...
...done.
###验证群集状态###
[[email protected] ~]# rabbitmqctl cluster_status
Cluster status of node [email protected] ...
br/>[{nodes,[{disc,[[email protected]]},{ram,[[email protected],[email protected]]}]},
{running_nodes,[[email protected],[email protected],[email protected]]},
br/>{cluster_name,<<"[email protected]">>},
{partitions,[]}]
...done.

##登录磁盘节点##
http://192.168.120.138:15672/
默认账户和密码都是guest
技术分享图片
技术分享图片
增加消息队列
queues->
name:aa //消息队列的名称
durability:durable //是否支持持久化br/>node:[email protected]
arguments:x-ha-policy = all

add queue 完成
技术分享图片
技术分享图片
技术分享图片
技术分享图片
技术分享图片










以上是关于千万PV----RabbitMQ集群配置的主要内容,如果未能解决你的问题,请参考以下文章

RabbmitMQ集群搭建流程

zookeeper+jstorm的集群搭建

千万级负载神器 LVSNginx及HAProxy工作原理大图详解!

千万PV网站中RabbitMQ安装集群

Springboot整合es集群实现千万级数据量导入

搭建cassandra 集群