欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 游戏 > 环境搭建---部署rabbitmq集群

环境搭建---部署rabbitmq集群

2025/4/4 6:08:17 来源:https://blog.csdn.net/weixin_43694134/article/details/142139139  浏览:    关键词:环境搭建---部署rabbitmq集群

rabbitmq下载:https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.34/rabbitmq-server-generic-unix-3.8.34.tar.xz
erlang下载:https://github.com/erlang/otp/releases/download/OTP-24.3.4.1/otp_src_24.3.4.1.tar.gz

配置主机名

[root@zhcs-cvm-01]# hostnamectl set-hostname zhcs-cvm-01
[root@zhcs-cvm-01]# hostname zhcs-cvm-01
[root@zhcs-cvm-02]# hostnamectl set-hostname zhcs-cvm-02
[root@zhcs-cvm-02]# hostname zhcs-cvm-02
[root@zhcs-cvm-03]# hostnamectl set-hostname zhcs-cvm-03
[root@zhcs-cvm-03]# hostname zhcs-cvm-03

配置hosts文件

[root@zhcs-cvm-01 sbin]# cat /etc/hosts
10.206.0.44 zhcs-cvm-01
10.206.0.45 zhcs-cvm-02
10.206.1.46 zhcs-cvm-03
[root@zhcs-cvm-02 sbin]# cat /etc/hosts
10.206.0.44 zhcs-cvm-01
10.206.0.45 zhcs-cvm-02
10.206.1.46 zhcs-cvm-03
[root@zhcs-cvm-03 sbin]# cat /etc/hosts
10.206.0.44 zhcs-cvm-01
10.206.0.45 zhcs-cvm-02
10.206.1.46 zhcs-cvm-03

配置免密登陆:(三台均配置)

[root@zhcs-cvm-01]# ssh-keygen -t rsa
[root@zhcs-cvm-01]# cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
[root@zhcs-cvm-01]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@zhcs-cvm-02
[root@zhcs-cvm-01]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@zhcs-cvm-03

安装erlang:

[root@zhcs-cvm-01]# tar -xf otp_src_24.3.4.1.tar.gz
[root@zhcs-cvm-01]# cd otp_src_24.3.4.1/
[root@zhcs-cvm-01]# ./configure --prefix=/opt/erlang
[root@zhcs-cvm-01]# make && make install
[root@zhcs-cvm-01]# vim /etc/profile
ERL_HOME=/opt/erlang
PATH=$ERL_HOME/bin:$PATH
export ERL_HOME PATH
[root@zhcs-cvm-01]# source /etc/profile

同步cookie文件

[root@zhcs-cvm-01]# scp /root/.erlang.cookie root@zhcs-cvm-02:/root/.erlang.cookie 
[root@zhcs-cvm-01]# scp /root/.erlang.cookie root@zhcs-cvm-03:/root/.erlang.cookie 

安装rabbitmq:

三台均操作:

[root@zhcs-cvm-01]# tar -xf rabbitmq-server-generic-unix-3.8.34.tar.xz
[root@zhcs-cvm-01]# cd rabbitmq_server-3.8.34
[root@zhcs-cvm-01]# ./sbin/rabbitmq-plugins enable rabbitmq_management
[root@zhcs-cvm-01]# ./sbin/rabbitmq-server -detached

只在其他节点操作:

[root@zhcs-cvm-01 sbin]# ./rabbitmqctl stop_app
[root@zhcs-cvm-01 sbin]# ./rabbitmqctl reset
[root@zhcs-cvm-01 sbin]# ./rabbitmqctl join_cluster rabbit@zhcs-cvm-01
[root@zhcs-cvm-01 sbin]# ./rabbitmqctl start_app

创建用户授权

[root@zhcs-cvm-01 sbin]# ./rabbitmqctl add_user admin password
[root@zhcs-cvm-01 sbin]# ./rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
[root@zhcs-cvm-01 sbin]# ./rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions --vhost   

虚拟主机 用户名 “对哪些实体有配置权限” “对哪些实体有写权限” “对哪些实体有读权限”

rabbitmqctl set_permissions --vhost "/" fkjava ".*" ".*" ".*"

查看集群状态

[root@zhcs-cvm-01 sbin]#./rabbitmqctl cluster_status
Cluster status of node rabbit@zhcs-cvm-01 ...
BasicsCluster name: rabbit@zhcs-cvm-01Disk Nodesrabbit@zhcs-cvm-01
rabbit@zhcs-cvm-02
rabbit@zhcs-cvm-03Running Nodesrabbit@zhcs-cvm-01
rabbit@zhcs-cvm-02
rabbit@zhcs-cvm-03Versionsrabbit@zhcs-cvm-01: RabbitMQ 3.8.34 on Erlang 24.3.4.1
rabbit@zhcs-cvm-02: RabbitMQ 3.8.34 on Erlang 24.3.4.1
rabbit@zhcs-cvm-03: RabbitMQ 3.8.34 on Erlang 24.3.4.1Maintenance statusNode: rabbit@zhcs-cvm-01, status: not under maintenance
Node: rabbit@zhcs-cvm-02, status: not under maintenance
Node: rabbit@zhcs-cvm-03, status: not under maintenanceAlarms(none)Network Partitions(none)ListenersNode: rabbit@zhcs-cvm-01, interface: [::], port: 15672, protocol: http, purpose: HTTP API
Node: rabbit@zhcs-cvm-01, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@zhcs-cvm-01, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Node: rabbit@zhcs-cvm-02, interface: [::], port: 15672, protocol: http, purpose: HTTP API
Node: rabbit@zhcs-cvm-02, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@zhcs-cvm-02, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Node: rabbit@zhcs-cvm-03, interface: [::], port: 15672, protocol: http, purpose: HTTP API
Node: rabbit@zhcs-cvm-03, interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Node: rabbit@zhcs-cvm-03, interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0Feature flagsFlag: 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: user_limits, state: enabled
Flag: virtual_host_metadata, state: enabled

在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词