写点什么

RabbitMQ 基础知识

作者:龙空白白
  • 2022 年 6 月 23 日
  • 本文字数:3744 字

    阅读完需:约 12 分钟

RabbitMQ基础知识

RabbitMQ 基础知识

一、RabbitMQ 概述

RabbitMQ 是一款使用Erlang语言开发的,实现 AMQP(高级消息队列协议)的开源消息中间件,它具有以下特性


  • 开源、性能优秀,稳定性保障

  • 支持持久化,传输确认,发布确认,可靠性消息投递模式(confirm)、返回模式(return)等保证了 MQ 的可靠性

  • 集群模式丰富,HA 模式,多台 RabbitMQ 服务器可以组成一个集群,形成一个逻辑 Broker

  • 支持多种语言客户端。RabbitMQ 几乎支持所有常用编程语言,包括 Java、.NET、Ruby 等

  • 提供多种工作模式,工作模式有:简单模式、工作队列模式、发布订阅模式、路由模式、通配符模式

二、Linux 环境下载安装 RabbitMQ

1.下载 Erlang 和 RabbitMQ

RabbitMQ 是基于 Erlang 语言开发的,所以在先安装 RabbitMQ 之前先安装 Erlang 语言


  • Erlang 官网下载地址: https://packagecloud.io/rabbitmq/erlang



下载 RabbitMQ


  • RabbitMQ 下载地址:https://packagecloud.io/rabbitmq/rabbitmq-server


2.Linux 环境下安装 Erlang 和 RabbitMQ

在 Erlang 的安装目录下安装 Erlang


[root@bp18425116f0cojd1vnz modules]# yum install erlang-23.3.4.11-1.el7.x86_64.rpmalinux3-updates                                                                                                                       59 kB/s | 4.1 kB     00:00    alinux3-plus                                                                                                                          96 kB/s | 2.5 kB     00:00    alinux3-plus                                                                                                                          51 MB/s | 4.9 MB     00:00    alinux3-powertools                                                                                                                    88 kB/s | 3.0 kB     00:00    alinux3-os                                                                                                                           154 kB/s | 3.8 kB     00:00    Docker CE Stable - x86_64                                                                                                             18 kB/s | 3.5 kB     00:00    Extra Packages for Enterprise Linux Modular 3 - x86_64                                                                                39 kB/s |  10 kB     00:00    Extra Packages for Enterprise Linux 8 - x86_64                                                                                       178 kB/s | 4.7 kB     00:00    Extra Packages for Enterprise Linux 8 - x86_64                                                                                        40 MB/s |  11 MB     00:00    
复制代码


检查 Erlang 是否安装成功,按两次 Ctrl+C 退出命令模式


[root@bp18425116f0cojd1vnz bin]# erl -vErlang/OTP 23 [erts-11.2.2.10] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]
Eshell V11.2.2.10 (abort with ^G)1> BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
复制代码


在 RabbitMQ 的安装目录下安装 socat


[root@bp18425116f0cojd1vnz modules]# yum -y install socatLast metadata expiration check: 0:13:23 ago on Wed 22 Jun 2022 10:58:12 AM CST.Module yaml error: Unexpected key in data: static_context [line 9 col 3]Module yaml error: Unexpected key in data: static_context [line 9 col 3]Package socat-1.7.3.3-2.1.al8.x86_64 is already installed.Dependencies resolved.Nothing to do.Complete!
复制代码


在 RabbitMQ 的安装目录下 RabbitMQ


[root@bp18425116f0cojd1vnz modules]# yum install rabbitmq-server-3.8.34-1.el8.noarch.rpmLast metadata expiration check: 0:24:38 ago on Wed 22 Jun 2022 10:58:12 AM CST.Module yaml error: Unexpected key in data: static_context [line 9 col 3]Module yaml error: Unexpected key in data: static_context [line 9 col 3]Dependencies resolved.===================================================================================================================================================================== Package                                    Architecture                      Version                                  Repository                               Size=====================================================================================================================================================================Installing: rabbitmq-server                            noarch                            3.8.34-1.el8                             @commandline                             15 M
复制代码


检查 RabbitMQ 服务是否安装成功


[root@bp18425116f0cojd1vnz bin]# rpm -qa|grep rabbitmqrabbitmq-server-3.8.34-1.el8.noarch
复制代码


启动 RabbitMQ 服务


[root@bp18425116f0cojd1vnz modules]# systemctl start rabbitmq-server
复制代码


查看 RabbitMQ 启动状态


[root@bp18425116f0cojd1vnz bin]# systemctl status rabbitmq-server● rabbitmq-server.service - RabbitMQ broker   Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: enabled)   Active: active (running) since Wed 2022-06-22 17:18:54 CST; 2s ago  Process: 3927019 ExecStop=/usr/sbin/rabbitmqctl shutdown (code=exited, status=69) Main PID: 3929124 (beam.smp)   Status: "Initialized"    Tasks: 21 (limit: 12371)   Memory: 96.1M   CGroup: /system.slice/rabbitmq-server.service           ├─3929124 /usr/lib64/erlang/erts-11.2.2.10/bin/beam.smp -W w -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stb>           ├─3929139 erl_child_setup 32768           ├─3929185 inet_gethost 4           └─3929186 inet_gethost 4
Jun 22 17:18:53 bp18425116f0cojd1vnz rabbitmq-server[3929124]: TLS Library: OpenSSL - OpenSSL 1.0.2o-fips 27 Mar 2018Jun 22 17:18:53 bp18425116f0cojd1vnz rabbitmq-server[3929124]: Doc guides: https://rabbitmq.com/documentation.htmlJun 22 17:18:53 bp18425116f0cojd1vnz rabbitmq-server[3929124]: Support: https://rabbitmq.com/contact.htmlJun 22 17:18:53 bp18425116f0cojd1vnz rabbitmq-server[3929124]: Tutorials: https://rabbitmq.com/getstarted.htmlJun 22 17:18:53 bp18425116f0cojd1vnz rabbitmq-server[3929124]: Monitoring: https://rabbitmq.com/monitoring.htmlJun 22 17:18:53 bp18425116f0cojd1vnz rabbitmq-server[3929124]: Logs: /var/log/rabbitmq/rabbit@bp18425116f0cojd1vnz.logJun 22 17:18:53 bp18425116f0cojd1vnz rabbitmq-server[3929124]: /var/log/rabbitmq/rabbit@bp18425116f0cojd1vnz_upgrade.logJun 22 17:18:53 bp18425116f0cojd1vnz rabbitmq-server[3929124]: Config file(s): (none)Jun 22 17:18:54 bp18425116f0cojd1vnz rabbitmq-server[3929124]: Starting broker... completed with 3 plugins.Jun 22 17:18:54 bp18425116f0cojd1vnz systemd[1]: Started RabbitMQ broker.
复制代码


开启 RabbitMQ 的 Web 插件管理


[root@bp18425116f0cojd1vnz modules]# rabbitmq-plugins enable rabbitmq_managementEnabling plugins on node rabbit@bp18425116f0cojd1vnz:rabbitmq_managementThe following plugins have been configured:  rabbitmq_management  rabbitmq_management_agent  rabbitmq_web_dispatchApplying plugin configuration to rabbit@bp18425116f0cojd1vnz...Plugin configuration unchanged
复制代码


服务器测试是否能够访问


[root@bp18425116f0cojd1vnz rabbitmq]# wget http://127.0.0.1:15672--2022-06-22 17:21:12--  http://127.0.0.1:15672/Connecting to 127.0.0.1:15672... connected.HTTP request sent, awaiting response... 200 OKLength: 2884 (2.8K) [text/html]Saving to: ‘index.html’
index.html 100%[==================================================================================>] 2.82K --.-KB/s in 0s
2022-06-22 17:21:12 (384 MB/s) - ‘index.html’ saved [2884/2884]
复制代码


开放端口访问


[root@bp18425116f0cojd1vnz rabbitmq]# firewall-cmd --zone=public --add-port=5672/tcp --permanent[root@bp18425116f0cojd1vnz rabbitmq]# firewall-cmd --zone=public --add-port=15672/tcp --permanent
复制代码


查看开放的端口


firewall-cmd --list-ports
复制代码


发布于: 刚刚阅读数: 3
用户头像

龙空白白

关注

还未添加个人签名 2021.04.12 加入

IT行业 后端开发

评论

发布
暂无评论
RabbitMQ基础知识_RabbitMQ_龙空白白_InfoQ写作社区