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

目录

一、环境

1、映射、域名、三墙

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

二、部署三台rabbitmq-3.8.15实例

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 — RabbitMQicon-default.png?t=N7T8http://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 进行登录 

rabbitmq-3.8.15集群、集群镜像模式安装部署_第1张图片

三、部署集群

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

rabbitmq-3.8.15集群、集群镜像模式安装部署_第2张图片

三、设置为镜像模式

[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 "/" ...

 验证

[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

你可能感兴趣的:(1024程序员节)