“RabbitMQ:安装部署”的版本间差异
跳到导航
跳到搜索
小 (Eijux移动页面RabbitMQ:安装部署至RabbitMQ:安装部署、管理后台,不留重定向) |
(→关于) |
||
第3行: | 第3行: | ||
== 关于 == | == 关于 == | ||
RabbitMQ 快速搭建开发环境,因为 RabbitMQ 使用 Erlang 开发,常规方式安装需要先安装 '''Erlang''',再安装 RabbitMQ 比较麻烦,所以这里推荐使用 '''Docker''' 方式部署,一条命令搞定。 | RabbitMQ 快速搭建开发环境,因为 RabbitMQ 使用 Erlang 开发,常规方式安装需要先安装 '''Erlang''',再安装 RabbitMQ 比较麻烦,所以这里推荐使用 '''Docker''' 方式部署,一条命令搞定。 | ||
== CentOS 安装 == | |||
两种方法可以在 RPM 发行版上安装 RabbitMQ 的最新版本:【转自官网: https://www.rabbitmq.com/install-rpm.html】 | |||
# 使用[https://www.rabbitmq.com/install-rpm.html#cloudsmith Cloudsmith.io]或[https://www.rabbitmq.com/install-rpm.html#package-cloud PackageCloud]上的 Yum 存储库安装包。(强烈建议使用此选项) | |||
# 下载软件包并用 rpm 安装。(需要手动安装所有包依赖项) | |||
* 在CentOS上,Erlang包有三种常用的源: | |||
*# '''RabbitMQ提供''':只提供运行 RabbitMQ 所需的组件,官方称零依赖项,容易安装。(如果Erlang只是用来提供运行RabbitMQ的,推荐使用) | |||
*# '''Erlang官方提供''':安装时需要安装依赖多,如果还需要Erlang做相关开发或运行环境,使用该包。 | |||
*# '''EPEL源提供''':但该包版本过低,不推荐使用该方法下载安装。 | |||
** 如果通过 yum 安装:elang在默认的yum存储库中不可用,所以先安装 '''epel存储库''': | |||
**: <syntaxhighlight lang="bash" highlight=""> | |||
# 先安装epel存储库 | |||
yum -y install epel-release | |||
# 再安装 Erlang、socat | |||
yum -y install erlang socat | |||
</syntaxhighlight> | |||
=== 在线安装:使用 Cloudsmith 上的 YUM 库 === | |||
---- | |||
Cloudsmith 提供了带有 RabbitMQ 包的Yum存储库,还可以通过 yum 安装最新的 Erlang 版本。 | |||
==== 安装Yum存储库文件 ==== | |||
设置存储库的一种快速方法是使用 Cloudsmith 提供的'''脚本''': | |||
: 【这不是必须的,但是可以考虑使用,因为它将生成的脚本从公共互联网传输到特定的shell】 | |||
: <syntaxhighlight lang="bash" highlight=""> | |||
## Uses a Cloudsmith-provided Yum repository setup script. | |||
## Always verify what is downloaded before piping it to a privileged shell! | |||
curl -1sLf 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/setup.rpm.sh' | sudo -E bash | |||
</syntaxhighlight> | |||
传统的库文件安装方式:【使用上述的命令,可以替代以下步骤】 | |||
# Yum 将验证其安装的任何包的签名,因此该过程的第一步是导入签名密钥: | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
## primary RabbitMQ signing key | |||
rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | |||
## modern Erlang repository | |||
rpm --import 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key' | |||
## RabbitMQ server repository | |||
rpm --import 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key' | |||
</syntaxhighlight> | |||
# 为 RabbitMQ 和 Modern Erlang 添加 Yum 存储库: | |||
#: 为了使用Yum存储库,必须在 '''/etc/Yum.repos.d/''' 目录下添加一个 '''.repo''' 文件(例如“rabbitmq.repo”): | |||
#: 【.repo 文件根据发行版不同而略有差异,以 CentOS 7 为例】 | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
# In /etc/yum.repos.d/rabbitmq.repo | |||
[rabbitmq_erlang] | |||
name=rabbitmq_erlang | |||
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/7/$basearch | |||
repo_gpgcheck=1 | |||
enabled=1 | |||
# Cloudsmith's repository key and RabbitMQ package signing key | |||
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key | |||
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | |||
gpgcheck=1 | |||
sslverify=1 | |||
sslcacert=/etc/pki/tls/certs/ca-bundle.crt | |||
metadata_expire=300 | |||
pkg_gpgcheck=1 | |||
autorefresh=1 | |||
type=rpm-md | |||
[rabbitmq_erlang-noarch] | |||
name=rabbitmq_erlang-noarch | |||
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/7/noarch | |||
repo_gpgcheck=1 | |||
enabled=1 | |||
# Cloudsmith's repository key and RabbitMQ package signing key | |||
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key | |||
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | |||
gpgcheck=1 | |||
sslverify=1 | |||
sslcacert=/etc/pki/tls/certs/ca-bundle.crt | |||
metadata_expire=300 | |||
pkg_gpgcheck=1 | |||
autorefresh=1 | |||
type=rpm-md | |||
[rabbitmq_erlang-source] | |||
name=rabbitmq_erlang-source | |||
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/7/SRPMS | |||
repo_gpgcheck=1 | |||
enabled=1 | |||
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key | |||
gpgcheck=0 | |||
sslverify=1 | |||
sslcacert=/etc/pki/tls/certs/ca-bundle.crt | |||
metadata_expire=300 | |||
pkg_gpgcheck=1 | |||
autorefresh=1 | |||
type=rpm-md | |||
## | |||
## RabbitMQ server | |||
## | |||
[rabbitmq-server] | |||
name=rabbitmq_server | |||
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/7/$basearch | |||
repo_gpgcheck=1 | |||
enabled=1 | |||
# Cloudsmith's repository key and RabbitMQ package signing key | |||
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key | |||
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | |||
gpgcheck=1 | |||
sslverify=1 | |||
sslcacert=/etc/pki/tls/certs/ca-bundle.crt | |||
metadata_expire=300 | |||
pkg_gpgcheck=1 | |||
autorefresh=1 | |||
type=rpm-md | |||
[rabbitmq_server-noarch] | |||
name=rabbitmq_server-noarch | |||
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/7/noarch | |||
repo_gpgcheck=1 | |||
enabled=1 | |||
# Cloudsmith's repository key and RabbitMQ package signing key | |||
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key | |||
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | |||
gpgcheck=1 | |||
sslverify=1 | |||
sslcacert=/etc/pki/tls/certs/ca-bundle.crt | |||
metadata_expire=300 | |||
pkg_gpgcheck=1 | |||
autorefresh=1 | |||
type=rpm-md | |||
[rabbitmq_server-source] | |||
name=rabbitmq_server-source | |||
baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/7/SRPMS | |||
repo_gpgcheck=1 | |||
enabled=1 | |||
gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key | |||
gpgcheck=0 | |||
sslverify=1 | |||
sslcacert=/etc/pki/tls/certs/ca-bundle.crt | |||
metadata_expire=300 | |||
pkg_gpgcheck=1 | |||
autorefresh=1 | |||
type=rpm-md | |||
</syntaxhighlight> | |||
==== 用Yum安装包 ==== | |||
【操作根据发行版不同而略有差异,以 CentOS 7 为例】 | |||
# 更新 Yum 软件包元数据: | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
yum update -y | |||
</syntaxhighlight> | |||
# 然后安装软件包: | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
yum install socat logrotate -y | |||
yum install erlang rabbitmq-server -y | |||
</syntaxhighlight> | |||
#* logrotate 程序是一个日志文件管理工具。用于分割日志文件,删除旧的日志文件,并创建新的日志文件,起到“转储”作用,可以节省磁盘空间。 | |||
=== 在线安装:使用 PackageCloud 上的 YUM 库 === | |||
---- | |||
PackageCloud 提供了包含 RabbitMQ 包的Yum存储库,也可以用于通过 yum 安装最新的 Erlang 版本。 | |||
使用示例:[https://blog.csdn.net/weixin_40584261/article/details/106826044 CSDN:Centos7安装RabbitMQ最新版3.8.5,史上最简单实用安装步骤] | |||
==== 安装Yum存储库文件 ==== | |||
设置存储库的一种快速方法是使用 PackageCloud 提供的'''脚本''': | |||
: 【这不是必须的,但是可以考虑使用,因为它将生成的脚本从公共互联网传输到特定的shell】 | |||
: <syntaxhighlight lang="bash" highlight=""> | |||
## Uses a PackageCloud-provided Yum repository setup script. | |||
## Always verify what is downloaded before piping it to a privileged shell! | |||
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash | |||
</syntaxhighlight> | |||
传统的库文件安装方式:【使用上述的命令,可以替代以下步骤】 | |||
# Yum 将验证其安装的任何包的签名,因此该过程的第一步是导入签名密钥: | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
## primary RabbitMQ signing key | |||
rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | |||
## modern Erlang repository | |||
rpm --import https://packagecloud.io/rabbitmq/erlang/gpgkey | |||
## RabbitMQ server repository | |||
rpm --import https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey | |||
</syntaxhighlight> | |||
# 为 RabbitMQ 和 Modern Erlang 添加 Yum 存储库: | |||
#: 为了使用Yum存储库,必须在 '''/etc/Yum.repos.d/''' 目录下添加一个 '''.repo''' 文件(例如“rabbitmq.repo”): | |||
#: 【.repo 文件根据发行版不同而略有差异,以 CentOS 7 为例】 | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
# In /etc/yum.repos.d/rabbitmq.repo | |||
## | |||
## Zero dependency Erlang | |||
## | |||
[rabbitmq_erlang] | |||
name=rabbitmq_erlang | |||
baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/$basearch | |||
repo_gpgcheck=1 | |||
gpgcheck=1 | |||
enabled=1 | |||
# PackageCloud's repository key and RabbitMQ package signing key | |||
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey | |||
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | |||
sslverify=1 | |||
sslcacert=/etc/pki/tls/certs/ca-bundle.crt | |||
metadata_expire=300 | |||
[rabbitmq_erlang-source] | |||
name=rabbitmq_erlang-source | |||
baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/SRPMS | |||
repo_gpgcheck=1 | |||
gpgcheck=0 | |||
enabled=1 | |||
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey | |||
sslverify=1 | |||
sslcacert=/etc/pki/tls/certs/ca-bundle.crt | |||
metadata_expire=300 | |||
## | |||
## RabbitMQ server | |||
## | |||
[rabbitmq_server] | |||
name=rabbitmq_server | |||
baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/$basearch | |||
repo_gpgcheck=1 | |||
gpgcheck=1 | |||
enabled=1 | |||
# PackageCloud's repository key and RabbitMQ package signing key | |||
gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey | |||
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | |||
sslverify=1 | |||
sslcacert=/etc/pki/tls/certs/ca-bundle.crt | |||
metadata_expire=300 | |||
[rabbitmq_server-source] | |||
name=rabbitmq_server-source | |||
baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/SRPMS | |||
repo_gpgcheck=1 | |||
gpgcheck=0 | |||
enabled=1 | |||
gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey | |||
sslverify=1 | |||
sslcacert=/etc/pki/tls/certs/ca-bundle.crt | |||
metadata_expire=300 | |||
</syntaxhighlight> | |||
==== 用Yum安装包 ==== | |||
【操作根据发行版不同而略有差异,以 CentOS 7 为例】 | |||
# 更新 Yum 软件包元数据: | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
yum update -y | |||
</syntaxhighlight> | |||
# 然后安装软件包: | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
## install these dependencies from standard OS repositories | |||
yum install socat logrotate -y | |||
yum install --repo rabbitmq_erlang --repo rabbitmq_server erlang rabbitmq-server -y | |||
</syntaxhighlight> | |||
#* logrotate 程序是一个日志文件管理工具。用于分割日志文件,删除旧的日志文件,并创建新的日志文件,起到“转储”作用,可以节省磁盘空间。 | |||
=== 离线安装 === | |||
---- | |||
注意: | |||
* RabbitMQ 依赖于 Erlang,而 Erlang 内存管理依赖 Socat,因此要首先安装 '''Erlang''' 与 '''socat'''; | |||
* Erlang 与 RabbitMQ 版本需要兼容,可以在“'''[https://www.rabbitmq.com/which-erlang.html https://www.rabbitmq.com/which-erlang.html]'''”查看。 | |||
* 所以最好是安装时使用指定版本的 rpm 源: | |||
*# rabbitmq-server包下载地址: https://github.com/rabbitmq/rabbitmq-server/releases | |||
*# erlang包下载地址: https://github.com/rabbitmq/erlang-rpm/releases | |||
*# socat包下载地址: https://pkgs.org/download/socat | |||
步骤如下: | |||
# 安装 Erlang: | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
rpm -Uvh http://www.rabbitmq.com/releases/erlang/erlang-18.1-1.el7.centos.x86_64.rpm | |||
</syntaxhighlight> | |||
#: 查看 Erlang 版本: | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
erl -version | |||
</syntaxhighlight> | |||
# 安装 RabbitMQ: | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
rpm -Uvh http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.6/rabbitmq-server-3.5.6-1.noarch.rpm | |||
</syntaxhighlight> | |||
=== 启动 === | |||
<syntaxhighlight lang="bash" highlight=""> | |||
#启动服务 | |||
systemctl start rabbitmq-server | |||
#查看状态 | |||
systemctl status rabbitmq-server | |||
#设置为开机启动 | |||
systemctl enable rabbitmq-server | |||
</syntaxhighlight> | |||
=== 启用管理平台插件 === | |||
<syntaxhighlight lang="bash" highlight=""> | |||
rabbitmq-plugins enable rabbitmq_management | |||
</syntaxhighlight> | |||
# : | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
</syntaxhighlight> | |||
# : | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
</syntaxhighlight> | |||
# : | |||
#: <syntaxhighlight lang="bash" highlight=""> | |||
</syntaxhighlight> | |||
== Docker方式部署 == | == Docker方式部署 == |
2021年5月24日 (一) 00:44的版本
关于
RabbitMQ 快速搭建开发环境,因为 RabbitMQ 使用 Erlang 开发,常规方式安装需要先安装 Erlang,再安装 RabbitMQ 比较麻烦,所以这里推荐使用 Docker 方式部署,一条命令搞定。
CentOS 安装
两种方法可以在 RPM 发行版上安装 RabbitMQ 的最新版本:【转自官网: https://www.rabbitmq.com/install-rpm.html】
- 使用Cloudsmith.io或PackageCloud上的 Yum 存储库安装包。(强烈建议使用此选项)
- 下载软件包并用 rpm 安装。(需要手动安装所有包依赖项)
- 在CentOS上,Erlang包有三种常用的源:
- RabbitMQ提供:只提供运行 RabbitMQ 所需的组件,官方称零依赖项,容易安装。(如果Erlang只是用来提供运行RabbitMQ的,推荐使用)
- Erlang官方提供:安装时需要安装依赖多,如果还需要Erlang做相关开发或运行环境,使用该包。
- EPEL源提供:但该包版本过低,不推荐使用该方法下载安装。
- 如果通过 yum 安装:elang在默认的yum存储库中不可用,所以先安装 epel存储库:
# 先安装epel存储库 yum -y install epel-release # 再安装 Erlang、socat yum -y install erlang socat
在线安装:使用 Cloudsmith 上的 YUM 库
Cloudsmith 提供了带有 RabbitMQ 包的Yum存储库,还可以通过 yum 安装最新的 Erlang 版本。
安装Yum存储库文件
设置存储库的一种快速方法是使用 Cloudsmith 提供的脚本:
- 【这不是必须的,但是可以考虑使用,因为它将生成的脚本从公共互联网传输到特定的shell】
## Uses a Cloudsmith-provided Yum repository setup script. ## Always verify what is downloaded before piping it to a privileged shell! curl -1sLf 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/setup.rpm.sh' | sudo -E bash
传统的库文件安装方式:【使用上述的命令,可以替代以下步骤】
- Yum 将验证其安装的任何包的签名,因此该过程的第一步是导入签名密钥:
## primary RabbitMQ signing key rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc ## modern Erlang repository rpm --import 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key' ## RabbitMQ server repository rpm --import 'https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key'
- 为 RabbitMQ 和 Modern Erlang 添加 Yum 存储库:
- 为了使用Yum存储库,必须在 /etc/Yum.repos.d/ 目录下添加一个 .repo 文件(例如“rabbitmq.repo”):
- 【.repo 文件根据发行版不同而略有差异,以 CentOS 7 为例】
# In /etc/yum.repos.d/rabbitmq.repo [rabbitmq_erlang] name=rabbitmq_erlang baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/7/$basearch repo_gpgcheck=1 enabled=1 # Cloudsmith's repository key and RabbitMQ package signing key gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc gpgcheck=1 sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 pkg_gpgcheck=1 autorefresh=1 type=rpm-md [rabbitmq_erlang-noarch] name=rabbitmq_erlang-noarch baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/7/noarch repo_gpgcheck=1 enabled=1 # Cloudsmith's repository key and RabbitMQ package signing key gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc gpgcheck=1 sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 pkg_gpgcheck=1 autorefresh=1 type=rpm-md [rabbitmq_erlang-source] name=rabbitmq_erlang-source baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/rpm/el/7/SRPMS repo_gpgcheck=1 enabled=1 gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key gpgcheck=0 sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 pkg_gpgcheck=1 autorefresh=1 type=rpm-md ## ## RabbitMQ server ## [rabbitmq-server] name=rabbitmq_server baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/7/$basearch repo_gpgcheck=1 enabled=1 # Cloudsmith's repository key and RabbitMQ package signing key gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc gpgcheck=1 sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 pkg_gpgcheck=1 autorefresh=1 type=rpm-md [rabbitmq_server-noarch] name=rabbitmq_server-noarch baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/7/noarch repo_gpgcheck=1 enabled=1 # Cloudsmith's repository key and RabbitMQ package signing key gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc gpgcheck=1 sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 pkg_gpgcheck=1 autorefresh=1 type=rpm-md [rabbitmq_server-source] name=rabbitmq_server-source baseurl=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/rpm/el/7/SRPMS repo_gpgcheck=1 enabled=1 gpgkey=https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key gpgcheck=0 sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 pkg_gpgcheck=1 autorefresh=1 type=rpm-md
用Yum安装包
【操作根据发行版不同而略有差异,以 CentOS 7 为例】
- 更新 Yum 软件包元数据:
yum update -y
- 然后安装软件包:
yum install socat logrotate -y yum install erlang rabbitmq-server -y
- logrotate 程序是一个日志文件管理工具。用于分割日志文件,删除旧的日志文件,并创建新的日志文件,起到“转储”作用,可以节省磁盘空间。
在线安装:使用 PackageCloud 上的 YUM 库
PackageCloud 提供了包含 RabbitMQ 包的Yum存储库,也可以用于通过 yum 安装最新的 Erlang 版本。
使用示例:CSDN:Centos7安装RabbitMQ最新版3.8.5,史上最简单实用安装步骤
安装Yum存储库文件
设置存储库的一种快速方法是使用 PackageCloud 提供的脚本:
- 【这不是必须的,但是可以考虑使用,因为它将生成的脚本从公共互联网传输到特定的shell】
## Uses a PackageCloud-provided Yum repository setup script. ## Always verify what is downloaded before piping it to a privileged shell! curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash
传统的库文件安装方式:【使用上述的命令,可以替代以下步骤】
- Yum 将验证其安装的任何包的签名,因此该过程的第一步是导入签名密钥:
## primary RabbitMQ signing key rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc ## modern Erlang repository rpm --import https://packagecloud.io/rabbitmq/erlang/gpgkey ## RabbitMQ server repository rpm --import https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
- 为 RabbitMQ 和 Modern Erlang 添加 Yum 存储库:
- 为了使用Yum存储库,必须在 /etc/Yum.repos.d/ 目录下添加一个 .repo 文件(例如“rabbitmq.repo”):
- 【.repo 文件根据发行版不同而略有差异,以 CentOS 7 为例】
# In /etc/yum.repos.d/rabbitmq.repo ## ## Zero dependency Erlang ## [rabbitmq_erlang] name=rabbitmq_erlang baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/$basearch repo_gpgcheck=1 gpgcheck=1 enabled=1 # PackageCloud's repository key and RabbitMQ package signing key gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 [rabbitmq_erlang-source] name=rabbitmq_erlang-source baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/SRPMS repo_gpgcheck=1 gpgcheck=0 enabled=1 gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 ## ## RabbitMQ server ## [rabbitmq_server] name=rabbitmq_server baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/$basearch repo_gpgcheck=1 gpgcheck=1 enabled=1 # PackageCloud's repository key and RabbitMQ package signing key gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300 [rabbitmq_server-source] name=rabbitmq_server-source baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/SRPMS repo_gpgcheck=1 gpgcheck=0 enabled=1 gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt metadata_expire=300
用Yum安装包
【操作根据发行版不同而略有差异,以 CentOS 7 为例】
- 更新 Yum 软件包元数据:
yum update -y
- 然后安装软件包:
## install these dependencies from standard OS repositories yum install socat logrotate -y yum install --repo rabbitmq_erlang --repo rabbitmq_server erlang rabbitmq-server -y
- logrotate 程序是一个日志文件管理工具。用于分割日志文件,删除旧的日志文件,并创建新的日志文件,起到“转储”作用,可以节省磁盘空间。
离线安装
注意:
- RabbitMQ 依赖于 Erlang,而 Erlang 内存管理依赖 Socat,因此要首先安装 Erlang 与 socat;
- Erlang 与 RabbitMQ 版本需要兼容,可以在“https://www.rabbitmq.com/which-erlang.html”查看。
- 所以最好是安装时使用指定版本的 rpm 源:
- rabbitmq-server包下载地址: https://github.com/rabbitmq/rabbitmq-server/releases
- erlang包下载地址: https://github.com/rabbitmq/erlang-rpm/releases
- socat包下载地址: https://pkgs.org/download/socat
步骤如下:
- 安装 Erlang:
rpm -Uvh http://www.rabbitmq.com/releases/erlang/erlang-18.1-1.el7.centos.x86_64.rpm
- 查看 Erlang 版本:
erl -version
- 安装 RabbitMQ:
rpm -Uvh http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.6/rabbitmq-server-3.5.6-1.noarch.rpm
启动
#启动服务
systemctl start rabbitmq-server
#查看状态
systemctl status rabbitmq-server
#设置为开机启动
systemctl enable rabbitmq-server
启用管理平台插件
rabbitmq-plugins enable rabbitmq_management
- :
- :
- :
Docker方式部署
可以到docker官方镜像仓库找最新版本:https://hub.docker.com/_/rabbitmq
安装
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
其中:
- 下载并且启动了一个 rabbitmq 容器实例;
- 开放了两个端口:5672(代码访问使用)和 15672(管理后台使用);
- 使用的是 3-management 版本;
容器维护
- 关闭 RabbitMQ 容器:
docker stop rabbitmq
- 启动 RabbitMQ 容器:
docker start rabbitmq
管理后台
RabbitMQ提供了一个可视化的Web后台,方便了解队列的运行情况,也可以对RabbitMQ做一些管理操作。
访问 RabbitMQ 管理后台地址:http://localhost:15672/
- 默认账号和密码:guest / guest