rabbitmq-3.8.15集群、集群镜像模式安装部署

目录

一、环境

1、映射、域名、三墙

2、Erlang和socat安装(三台服务器都实行)

二、部署三台rabbitmq-3.8.15实例

[1、rabbitmq官网下载地址 :](#1、rabbitmq官网下载地址 :)

2、解压rabbitmq

3、添加系统变量

4、启动web插件、启动rabbitmq

5、在rabbitmq1上添加用户

三、部署集群

1、向2和3分发.erlang.cookie

2、rabbitmq2加入rabbitmq1节点

3、rabbitmq3同理,查看节点状态

三、设置为镜像模式


一、环境

1、映射、域名、三墙

[root@rabbitmq1 ~]# vim /etc/hosts
192.168.6.83 rabbitmq1
192.168.6.84 rabbitmq2
192.168.6.85 rabbitmq3
[root@rabbitmq1 ~]# hostnamectl set-hostname rabbitmq1
[root@rabbitmq1 ~]# bash
[root@rabbitmq2 ~]# hostnamectl set-hostname rabbitmq2
[root@rabbitmq2 ~]# bash
[root@rabbitmq3 ~]# hostnamectl set-hostname rabbitmq3
[root@rabbitmq3 ~]# bash 
[root@rabbitmq1 ~]# systemctl stop firewalld
[root@rabbitmq1 ~]# setenforce 0
[root@rabbitmq1 ~]# iptables -F 

2、Erlang和socat安装

(三台服务器都实行)

#Erlang安装
#Erlang环境
[root@rabbitmq1 ~]# yum -y install make gcc gcc-c++ build-essential openssl openssl-devel unixODBC unixODBC-devel kernel-devel m4 ncurses-devel
[root@rabbitmq1 ~]# curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash
[root@rabbitmq1 ~]# sudo yum -y install erlang-22.3.4.19-1.el7.x86_64
[root@rabbitmq1 ~]# yum -y install socat

二、部署三台rabbitmq-3.8.15实例

1、rabbitmq官网下载地址 :

Downloading and Installing RabbitMQ --- RabbitMQhttp://www.rabbitmq.com/download.html

获取 rabbitmq-server-generic-unix-3.8.15.tar并拉取到每台服务器

2、解压rabbitmq

[root@rabbitmq2 ~]#   xz -d rabbitmq-server-generic-unix-3.8.15.tar.xz 
[root@rabbitmq2 ~]#   tar xvf rabbitmq-server-generic-unix-3.8.15.tar 
[root@rabbitmq2 ~]#   mv rabbitmq_server-3.8.15/ /usr/local/rabbitmq

3、添加系统变量

    #打开环境变量文件
   [root@rabbitmq2 ~]#  vim /etc/profile
    #添加erlang rabbitmq 到环境变量
    export PATH=$PATH:/usr/local/erlang/bin
    export PATH=$PATH:/usr/local/rabbitmq/sbin
    #重新加载环境变量
   [root@rabbitmq2 ~]#  source /etc/profile

4、启动web插件、启动rabbitmq

    #启动web插件 便于访问
 [root@rabbitmq2 ~]#   rabbitmq-plugins enable rabbitmq_management
    #启动rabbitmq服务
 [root@rabbitmq2 ~]#  rabbitmq-server

5、在rabbitmq1上添加用户

    #添加用户 admin  密码为 123456
    rabbitmqctl add_user admin 123456
    #将admin 设置为管理员权限
    rabbitmqctl set_user_tags admin administrator
    #将admin 设置为远端登录
    rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"

使用 admin 密码 123456 进行登录

三、部署集群

1、向2和3分发.erlang.cookie

[root@rabbitmq1 ~]# scp .erlang.cookie 192.168.6.84:/root
[root@rabbitmq1 ~]# scp .erlang.cookie 192.168.6.85:/root

2、rabbitmq2加入rabbitmq1节点

需要强调一下,集群中至少有一个节点是磁盘节点用于数据持久化,然后剩下的节点都设置为内存节点以提高性能。

这里将 rabbitmq2 添加到集群当中,并成为内存节点,不加--ram 默认是磁盘节点

rabbitmq1默认为磁盘节点

[root@rabbitmq2 ~]# rabbitmqctl stop_app
Stopping rabbit application on node rabbit@rabbitmq2 ...
[root@rabbitmq2 ~]# rabbitmqctl reset
Resetting node rabbit@rabbitmq2 ...
[root@rabbitmq2 ~]# rabbitmqctl join_cluster --ram rabbit@rabbitmq1
Clustering node rabbit@rabbitmq2 with rabbit@rabbitmq1
[root@rabbitmq2 ~]# rabbitmqctl start_app
Starting node rabbit@rabbitmq2 ...

3、rabbitmq3同理,查看节点状态

[root@rabbitmq1 ~]# rabbitmqctl cluster_status
Cluster status of node rabbit@rabbitmq1 ...
Basics

Cluster name: rabbit@rabbitmq1

Disk Nodes

rabbit@rabbitmq1

RAM Nodes

rabbit@rabbitmq2
rabbit@rabbitmq3

Running Nodes

rabbit@rabbitmq1
rabbit@rabbitmq2
rabbit@rabbitmq3

Versions

Node: rabbit@rabbitmq1, status: not under maintenance
Node: rabbit@rabbitmq2, status: not under maintenance
Node: rabbit@rabbitmq3, status: not under maintenance


Maintenance status

Node: rabbit@rabbitmq1, status: not under maintenance
Node: rabbit@rabbitmq2, status: not under maintenance
Node: rabbit@rabbitmq3, status: unknown

三、设置为镜像模式

[root@rabbitmq1 ~]# rabbitmqctl set_policy ha-all "^" '{"ha-mode":"all"}'
Setting policy "ha-all" for pattern "^" to "{"ha-mode":"all"}" with priority "0" for vhost "/" ...

验证

bash 复制代码
[root@rabbitmq1 ~]# rabbitmqctl cluster_status
Cluster status of node rabbit@rabbitmq1 ...
Basics

Cluster name: rabbit@rabbitmq1

Disk Nodes

rabbit@rabbitmq1

RAM Nodes

rabbit@rabbitmq2
rabbit@rabbitmq3

Running Nodes

rabbit@rabbitmq1
rabbit@rabbitmq2
rabbit@rabbitmq3

Versions

rabbit@rabbitmq1: RabbitMQ 3.8.15 on Erlang 22.3.4.19
rabbit@rabbitmq2: RabbitMQ 3.8.15 on Erlang 22.3.4.19
rabbit@rabbitmq3: RabbitMQ 3.8.15 on Erlang 22.3.4.19

Maintenance status

Node: rabbit@rabbitmq1, status: not under maintenance
Node: rabbit@rabbitmq2, status: not under maintenance
Node: rabbit@rabbitmq3, status: not under maintenance

Alarms

(none)

Network Partitions

(none)

Listeners

Node: rabbit@rabbitmq1, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@rabbitmq1, interface: [::], port: 15672, protocol: http, purpose: HTTP API
Node: rabbit@rabbitmq1, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Node: rabbit@rabbitmq2, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@rabbitmq2, interface: [::], port: 15672, protocol: http, purpose: HTTP API
Node: rabbit@rabbitmq2, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Node: rabbit@rabbitmq3, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@rabbitmq3, interface: [::], port: 15672, protocol: http, purpose: HTTP API
Node: rabbit@rabbitmq3, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0


(none)

Network Partitions

(none)

Listeners

Node: rabbit@rabbitmq1, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@rabbitmq1, interface: [::], port: 15672, protocol: http, purpose: HTTP API
Node: rabbit@rabbitmq1, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Node: rabbit@rabbitmq2, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@rabbitmq2, interface: [::], port: 15672, protocol: http, purpose: HTTP API
Node: rabbit@rabbitmq2, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
相关推荐
yaosheng_VALVE7 小时前
稀硫酸介质中 V 型球阀的材质选择与选型要点-耀圣
运维·spring cloud·自动化·intellij-idea·材质·1024程序员节
网安_秋刀鱼10 小时前
java组件安全
web安全·网络安全·1024程序员节
earthzhang202110 小时前
《深入浅出HTTPS》读书笔记(7):安全的密码学Hash算法
网络·网络协议·http·https·1024程序员节
程序员小海绵【vincewm】12 小时前
【设计模式】结合Tomcat源码,分析外观模式/门面模式的特性和应用场景
设计模式·tomcat·源码·外观模式·1024程序员节·门面模式
一个通信老学姐13 小时前
专业140+总分410+东北大学841考研经验东大电子信息与通信工程通信专业基础真题,大纲,参考书
考研·信息与通信·信号处理·1024程序员节
惜.己13 小时前
Jmeter中的监听器(一)
测试工具·jmeter·1024程序员节
纪伊路上盛名在15 小时前
AI制作ppt
1024程序员节
爱搞技术的猫猫16 小时前
实现API接口的自动化
大数据·运维·数据库·性能优化·自动化·产品经理·1024程序员节
FFDUST1 天前
C++ 优先算法 —— 四数之和(双指针)
c语言·开发语言·c++·算法·leetcode·1024程序员节
惜.己1 天前
Jmeter中的配置原件(三)
功能测试·测试工具·jmeter·1024程序员节