1、概述
官网:https://www.rabbitmq.com/
RabbitMQ is the most widely deployed open source message broker.
With tens of thousands of users, RabbitMQ is one of the most popular open source message brokers. From T-Mobile to Runtastic, RabbitMQ is used worldwide at small startups and large enterprises.
RabbitMQ is lightweight and easy to deploy on premises and in the cloud. It supports multiple messaging protocols. RabbitMQ can be deployed in distributed and federated configurations to meet high-scale, high-availability requirements.
RabbitMQ runs on many operating systems and cloud environments, and provides a wide range of developer tools for most popular languages.
翻译以后:
RabbitMQ是部署最广泛的开源消息代理。
RabbitMQ拥有成千上万的用户,是最受欢迎的开源消息代理之一。从T-Mobile 到Runtastic,RabbitMQ在全球范围内的小型初创企业和大型企业中都得到使用。
RabbitMQ轻巧,易于在内部和云中部署。它支持多种消息传递协议。RabbitMQ可以部署在分布式和联合配置中,以满足大规模,高可用性的要求。
RabbitMQ可在许多操作系统和云环境上运行,并为大多数流行语言提供了广泛的开发人员工具。
2、安装RabbitMQ
- 下载地址:https://www.rabbitmq.com/download.html
- 环境准备:
CentOS7.x
+Erlang
- RabbitMQ是采用
Erlang
语言开发的,所以系统环境必须提供Erlang支持,第一步就是安装Erlang。
Erlang在1991年由爱立信公司向用户推出了第一个版本,经过不断的改进完善和发展,在1996年爱立信又为所有的Erlang用户提供了一个非常实用且稳定的OTP软件库并在1998年发布了第一个开源版本。Erlang同时支持的操作系统有linux,windows,unix等,可以说适用于主流的操作系统上,尤其是它支持多核的特性非常适合多核CPU,而分布式特性也可以很好融合各种分布式集群。
-
RabbitMQ 与 Erlang版本对照
1)安装Erlang语言
查看系统版本号
lsb_release -a
如果没有这个命令,可以使用
yum install -y redhat-lsb
来安装
[root@bogon ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core
(1)tar包安装
- 下载地址:https://www.erlang.org/downloads
- tar安装比较麻烦,可以参考:https://blog.youkuaiyun.com/tang9140/article/details/39343125
(2)rpm包安装
- 下载地址:https://github.com/rabbitmq/erlang-rpm/releases
# 下载rpm包:CentOS7环境中不要装太高的版本的,22.3.4实测可以
wget https://github.com/rabbitmq/erlang-rpm/releases/download/v22.3.4.21/erlang-22.3.4.21-1.el7.x86_64.rpm
# 安装升级
# U (大写)升级
# v 显示详细安装信息
# h 显示安装进度
# i 安装 install
rpm -Uvh erlang-22.3.4.21-1.el7.x86_64.rpm
(3)yum安装
# 在线安装
yum install -y erlang
2)安装Socat插件
socat 是一个实用的命令行工具。可以端口转发、文件写入、读取文件…
详细介绍:https://www.jianshu.com/p/0326c6199f3d
yum install -y socat
3)安装RabbitMQ
# 需要与erlang版本对应
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.8.15/rabbitmq-server-3.8.15-1.el7.noarch.rpm
rpm -Uvh rabbitmq-server-3.8.15-1.el7.noarch.rpm
# 启动服务
> systemctl start rabbitmq-server
# 查看服务状态
> systemctl status rabbitmq-server
# 停止服务
> systemctl stop rabbitmq-server
# 开机启动服务
> systemctl enable rabbitmq-server
4)配置RabbitMQ
RabbitMQ默认情况下有一个配置文件,定义了RabbitMQ的相关配置信息,默认情况下能够满足日常的开发需求。如果需要修改,就创建一个配置文件进行覆盖。
参考官网:
- https://www.rabbitmq.com/documentation.html
- https://www.rabbitmq.com/configure.html
- https://www.rabbitmq.com/configure.html#config-items
- https://github.com/rabbitmq/rabbitmq-server/blob/add-debug-messages-to-quorum_queue_SUITE/docs/rabbitmq.conf.example
5)相关端口
5672
RabbitMQ的通讯端口25672
RabbitMQ的节点间的CLI通讯端口是15672
RabbitMQ HTTP_API端口,管理员用户才能访问,用于管理RabbitMQ,需要启动Management插件1883
、8883
MQTT插件启动时的端口。61613
、61614
STOMP客户端插件启用的时候的端口。15674
、15675
基于webscoket的STOMP端口和MOTT端口