RabbitMQ集群

本文详细介绍了RabbitMQ集群的搭建过程,包括IP规划、软件包准备、基础配置如关闭SELinux和防火墙、安装OpenJDK1.8,以及erlang和RabbitMQ的安装。接着,文章讲解了如何配置hostname解析、组建RabbitMQ集群,设置Erlang Cookie,并初始化主从节点。最后,讨论了策略规则的设定,包括数据份数、终端任务过期时间和特征值过期时间,以确保集群的稳定性和高可用性。
摘要由CSDN通过智能技术生成

1 IP规划

本示例中三台服务器信息如下:

主机名 IP地址
MQ01 192.168.11.20
MQ02 192.168.11.21
MQ03 192.168.11.22

2 软件包

rabbitmq.zip下载地址:
https://download.csdn.net/download/Zhuge_Dan/19875254

3 基础配置

操作设备:所有节点

3.1 关闭SELinux

[root@MQ01 ~]# setenforce 0

[root@MQ01 ~]# vi /etc/selinux/config
SELINUX=disabled								#将SELINUX设置为disabled

[root@MQ01 ~]# getenforce 
Permissive

3.2 关闭防火墙或开放需要的业务端口

[root@MQ01 ~]# systemctl stop firewalld								#关闭防火墙

[root@MQ01 ~]# systemctl disable firewalld								#禁止防火墙开机自启

3.3 调整max_open_files

[root@MQ01 ~]# echo '* soft nofile 65535' >> /etc/security/limits.conf

[root@MQ01 ~]# echo '* hard nofile 65535' >> /etc/security/limits.conf

[root@MQ01 ~]# cat /etc/security/limits.conf | tail -2
* soft nofile 65535
* hard nofile 65535

[root@MQ01 ~]# echo 'ulimit -SHn 65535' >> /etc/rc.d/rc.local

[root@MQ01 ~]# cat /etc/rc.d/rc.local | tail -1
ulimit -SHn 65535

[root@MQ01 ~]# chmod +x /etc/rc.d/rc.local								#为rc.local增加可执行权限

3.4 重启检查SELinux、firewalld和open files

[root@MQ01 ~]# reboot

[root@MQ01 ~]# getenforce								#查看SELinux是否关闭成功
Disabled								#关闭成功

[root@MQ01 ~]# systemctl status firewalld								#查看防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
    Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
    Active: inactive (dead)								#防火墙已关闭
      Docs: man:firewalld(1)

[root@MQ01 ~]# systemctl is-enabled firewalld								#查看防火墙是否开机自启
disabled								#防火墙已禁止开机自启

[root@MQ01 ~]# ulimit -a | grep open
open files                      (-n) 65535								#open files已调整为65535

3.5 安装配置OpenJDK1.8

参考文章:《CentOS 7安装配置OpenJDK1.8》
https://blog.csdn.net/Zhuge_Dan/article/details/117448760

4 集群搭建

4.1 hostname解析

操作设备:所有节点
RabbitMQ集群各节点通过hostname进行识别和加入集群,所以首先需要在3台服务器上配置hostname解析。

[root@MQ01 ~]# echo '192.168.11.20 MQ01' >> /etc/hosts

[root@MQ01 ~]# echo '192.168.11.21 MQ02' >> /etc/hosts

[root@MQ01 ~]# echo '192.168.11.22 MQ03' >> /etc/hosts

4.2 安装erlang环境

操作设备:所有节点
3台服务器分别进行RabbitMQ的初始化安装。
上传rabbitmq.zip目录到服务器,以上传到/usr/local/目录下为例。
首先安装erlang环境及其依赖包。

4.2.1 解压缩并编译安装erlang

[root@MQ01 ~]# rpm -ivh /usr/local/rabbitmq/erlang_dependents/*.rpm --force
警告:/usr/local/rabbitmq/erlang_dependents/erlang-asn1-R16B-03.18.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
准备中...                          ################################# [100%]
……
  77:libselinux-python-2.5-14.1.el7   ################################# [ 99%]
  78:libselinux-utils-2.5-14.1.el7    ################################# [100%]

[root@MQ01 ~]# cd /usr/local/rabbitmq/

[root@MQ01 rabbitmq]# tar -zxvf otp_src_21.1.tar.gz
otp_src_21.1/
otp_src_21.1/aclocal.m4
……
otp_src_21.1/xcomp/erl-xcomp-x86_64-saf-linux-gnu.conf
otp_src_21.1/xcomp/erl-xcomp.conf.template

[root@MQ01 rabbitmq]# cd otp_src_21.1

[root@MQ01 otp_src_21.1]# ./configure --prefix=/usr/local/erlang --with-ssl -enable-threads -enable-smmp-support -enable-kernel-poll --enable-hipe --without-javac
Ignoring the --cache-file argument since it can cause the system to be 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值