签到成功

知道了

CNDBA社区CNDBA社区

Centos 7 Rabbitmq集群安装

2023-02-19 22:06 815 0 原创 RabbitMQ
作者: hbhe0316

1.设置hostname,三天服务器分别执行命令http://www.cndba.cn/hbhe0316/article/116449

hostnamectl set-hostname node01
hostnamectl set-hostname node02
hostnamectl set-hostname node03

2.设置3台服务器
node01、node02、node03节点:

[root@node01 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.110 node01
192.168.56.111 node02
192.168.56.112 node03

[root@node02 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.110 node01
192.168.56.111 node02
192.168.56.112 node03


[root@node03 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.110 node01
192.168.56.111 node02
192.168.56.112 node03

3.关闭selinux

[root@node01 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
[root@node01 ~]# setenforce 0

[root@node02 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
[root@node02 ~]# setenforce 0

[root@node03 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
[root@node03 ~]# setenforce 0

4.关闭防火墙http://www.cndba.cn/hbhe0316/article/116449

[root@node01 ~]# systemctl stop firewalld
[root@node01 ~]# systemctl disable firewalld

[root@node02 ~]# systemctl stop firewalld
[root@node02 ~]# systemctl disable firewalld

[root@node03 ~]# systemctl stop firewalld
[root@node03 ~]# systemctl disable firewalld

5.安装rabbitmq

[root@node01 ~]# yum install epel-release socat -y
[root@node01 ~]# rpm -ivh erlang-21.3-1.el7.x86_64.rpm
[root@node01 ~]# rpm -ivh rabbitmq-server-3.8.8-1.el7.noarch.rpm

[root@node02 ~]# yum install epel-release socat -y
[root@node02 ~]# rpm -ivh erlang-21.3-1.el7.x86_64.rpm
[root@node02 ~]# rpm -ivh rabbitmq-server-3.8.8-1.el7.noarch.rpm

[root@node03 ~]# yum install epel-release socat -y
[root@node03 ~]# rpm -ivh erlang-21.3-1.el7.x86_64.rpm
[root@node03 ~]# rpm -ivh rabbitmq-server-3.8.8-1.el7.noarch.rpm

6.开启远程登录

[root@node01 ~]# rabbitmq-plugins enable rabbitmq_management
[root@node01 ~]# rabbitmq-plugins enable rabbitmq_mqtt

[root@node02 ~]# rabbitmq-plugins enable rabbitmq_management
[root@node02 ~]# rabbitmq-plugins enable rabbitmq_mqtt

[root@node03 ~]# rabbitmq-plugins enable rabbitmq_management
[root@node03 ~]# rabbitmq-plugins enable rabbitmq_mqtt

7.添加账户以及权限http://www.cndba.cn/hbhe0316/article/116449

[root@node01 ~]# rabbitmqctl add_user admin wwwwww 
[root@node01 ~]# rabbitmqctl set_user_tags admin administrator 
[root@node01 ~]# rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*" 

[root@node02 ~]# rabbitmqctl add_user admin wwwwww 
[root@node02 ~]# rabbitmqctl set_user_tags admin administrator 
[root@node02 ~]# rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*" 

[root@node03 ~]# rabbitmqctl add_user admin wwwwww 
[root@node03 ~]# rabbitmqctl set_user_tags admin administrator 
[root@node03 ~]# rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"

8.在node02、node03节点执行命令http://www.cndba.cn/hbhe0316/article/116449

[root@node02 ~]# systemctl stop rabbitmq-server
[root@node03 ~]# systemctl stop rabbitmq-server

9.拷贝.erlang.cookie到node02、node03节点http://www.cndba.cn/hbhe0316/article/116449

[root@node01 ~]# scp /var/lib/rabbitmq/.erlang.cookie node03:/var/lib/rabbitmq/.erlang.cookie
[root@node01 ~]# scp /var/lib/rabbitmq/.erlang.cookie node03:/var/lib/rabbitmq/.erlang.cookie

10.重启node02、node03http://www.cndba.cn/hbhe0316/article/116449

[root@node02 ~]# systemctl restart rabbitmq-server
[root@node03 ~]# systemctl restart rabbitmq-server

11.node02加入集群http://www.cndba.cn/hbhe0316/article/116449

[root@node02 ~]# rabbitmqctl stop_app
Stopping rabbit application on node rabbit@node02 ...
[root@node02 ~]# rabbitmqctl reset
Resetting node rabbit@node02 ...
[root@node02 ~]# rabbitmqctl join_cluster rabbit@node01
Clustering node rabbit@node02 with rabbit@node01
[root@node02 ~]# rabbitmqctl start_app
Starting node rabbit@node02 ...
[root@node02 ~]# rabbitmqctl cluster_status

12.node03加入集群

[root@node03 ~]# rabbitmqctl stop_app
Stopping rabbit application on node rabbit@node03 ...
[root@node03 ~]# rabbitmqctl reset
Resetting node rabbit@node03 ...
[root@node03 ~]# rabbitmqctl join_cluster rabbit@node01
Clustering node rabbit@node03 with rabbit@node01
[root@node03 ~]# rabbitmqctl start_app
Starting node rabbit@node03 ...
[root@node03 ~]# rabbitmqctl cluster_status

13.登录http://192.168.56.110:15672 查看集群状态http://www.cndba.cn/hbhe0316/article/116449http://www.cndba.cn/hbhe0316/article/116449

14.查看集群状态http://www.cndba.cn/hbhe0316/article/116449

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

Cluster name: rabbit@node01

Disk Nodes

rabbit@node01
rabbit@node02
rabbit@node03

Running Nodes

rabbit@node01
rabbit@node02
rabbit@node03

Versions

rabbit@node01: RabbitMQ 3.8.8 on Erlang 21.3
rabbit@node02: RabbitMQ 3.8.8 on Erlang 21.3
rabbit@node03: RabbitMQ 3.8.8 on Erlang 21.3

Maintenance status

Node: rabbit@node01, status: not under maintenance
Node: rabbit@node02, status: not under maintenance
Node: rabbit@node03, status: not under maintenance

Alarms

(none)

Network Partitions

(none)

Listeners

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

Feature flags

Flag: drop_unroutable_metric, state: enabled
Flag: empty_basic_get_metric, state: enabled
Flag: implicit_default_bindings, state: enabled
Flag: maintenance_mode_status, state: enabled
Flag: quorum_queue, state: enabled
Flag: virtual_host_metadata, state: enabled

版权声明:本文为博主原创文章,未经博主允许不得转载。

Rabbitmq

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
hbhe0316

hbhe0316

关注

1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。

  • 889
    原创
  • 1
    翻译
  • 13
    转载
  • 24
    评论
  • 访问:1141785次
  • 积分:1523
  • 等级:核心会员
  • 排名:第6名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ