使用 PackageCloud Apt 仓库安装

RabbitMQ 团队在包托管服务 PackageCloud 上维护一个 apt 存储库。它为最新的 RabbitMQ 版本提供包。

PackageCloud 提供存储库设置说明,其中包括方便的单行说明。请始终检查从 Internet 下载并通过特权 shell 执行的脚本!

请注意,PackageCloud 脚本目前不遵循 GPG 密钥处理方面的 Debian 最佳实践,而本节的其余部分则遵循。

本指南将重点介绍一种更传统和明确的方式来设置额外的 apt 存储库和安装包。

除非另有说明,否则下面涵盖的所有步骤都是强制性的。

PackageCloud 快速启动脚本

下面是执行这些步骤的 shell 片段。在Shell脚本后是对脚本执行步骤的说明。

#!/usr/bin/sh

## Update package indices
sudo apt-get update -y

sudo apt-get install curl gnupg apt-transport-https -y

## Team RabbitMQ's main signing key
curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null
## Launchpad PPA that provides modern Erlang releases
curl -1sLf "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xf77f1eda57ebb1cc" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg > /dev/null
## PackageCloud RabbitMQ repository
curl -1sLf "https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/io.packagecloud.rabbitmq.gpg > /dev/null

## Add apt repositories maintained by Team RabbitMQ
sudo tee /etc/apt/sources.list.d/rabbitmq.list <<EOF
## Provides modern Erlang/OTP releases
##
## "bionic" as distribution name should work for any reasonably recent Ubuntu or Debian release.
## See the release to distribution mapping table in RabbitMQ doc guides to learn more.
deb [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic main
deb-src [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic main

## Provides RabbitMQ
##
## "bionic" as distribution name should work for any reasonably recent Ubuntu or Debian release.
## See the release to distribution mapping table in RabbitMQ doc guides to learn more.
deb [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ bionic main
deb-src [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ bionic main
EOF

## Update package indices
sudo apt-get update -y

## Install Erlang packages
sudo apt-get install -y erlang-base \
                        erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \
                        erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key \
                        erlang-runtime-tools erlang-snmp erlang-ssl \
                        erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl

## Install rabbitmq-server and its dependencies
sudo apt-get install rabbitmq-server -y --fix-missing

以下是对上面shell脚本的详细说明。

Step 1:启用 apt HTTPS 传输

为了 apt 能够从 PackageCloudCloudsmith.ioLaunchpad 等服务下载 RabbitMQErlang 包,必须安装 apt-transport-https 包:

sudo apt-get install apt-transport-https
Step 2:添加存储库签名密钥

为了易于使用存储库,RabbitMQ 签名密钥必须可用于系统进行验证。

## Team RabbitMQ's main signing key
curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null
## Launchpad PPA that provides modern Erlang releases
curl -1sLf "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xf77f1eda57ebb1cc" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg > /dev/null
## PackageCloud RabbitMQ repository
curl -1sLf "https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/io.packagecloud.rabbitmq.gpg > /dev/null
Step 3:添加源列表文件

与所有第 3 方 apt 存储库一样,描述 RabbitMQ 和 Erlang 包存储库的文件必须放在/etc/apt/sources.list.d/目录下。 /etc/apt/sources.list.d/rabbitmq.list 是推荐的位置。

该文件应该有一个使用以下模式的源(存储库)定义行:

# Source repository definition example.

## Provides modern Erlang/OTP releases
##
## "bionic" as distribution name should work for any reasonably recent Ubuntu or Debian release.
## See the release to distribution mapping table in RabbitMQ doc guides to learn more.
deb [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic main
deb-src [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic main

## Provides RabbitMQ
##
## "bionic" as distribution name should work for any reasonably recent Ubuntu or Debian release.
## See the release to distribution mapping table in RabbitMQ doc guides to learn more.
deb [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ bionic main
deb-src [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ bionic main

接下来的几节讨论支持哪些分布和组件值。

分发

为了设置一个提供正确包的 apt 存储库,必须做出一些决定。一是确定发行版名称。它通常与使用的 Debian 或 Ubuntu 版本相匹配:

  • jammy for Ubuntu 22.04
  • focal for Ubuntu 20.04
  • bionic for Ubuntu 18.04
  • buster for Debian Buster
  • bullseye for Debian Bullseye

并非所有发行版都被涵盖(索引)。例如,新发布的通常不会被包托管服务识别。但也有好消息:由于为这些发行版编制索引的包是相同的,因此在实践中,任何合理的最新发行版名称都足够了。例如,Debian Sid 或 Debian Bullseye 的用户都可以使用bullseye作为发行版名称。

下面是应该与 PackageCloud 上的 RabbitMQ apt 存储库一起使用的操作系统版本和分发名称的表格。

发行版本 分发
Ubuntu 22.04 jammy
Ubuntu 20.04 focal
Ubuntu 18.04 bionic
Debian Buster buster
Debian Bullseye bullseye
Debian Sid bullseye

要将 apt 存储库添加到源列表目录 ( /etc/apt/sources.list.d ),请使用:

sudo tee /etc/apt/sources.list.d/rabbitmq.list <<EOF
## Provides modern Erlang/OTP releases
##
## "bionic" as distribution name should work for any reasonably recent Ubuntu or Debian release.
## See the release to distribution mapping table in RabbitMQ doc guides to learn more.
deb [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic main
deb-src [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic main

## Provides RabbitMQ
##
## Replace $distribution with the name of the Ubuntu release used.
## On Debian, "deb/ubuntu" should be replaced with "deb/debian"
deb [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ $distribution main
deb-src [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ $distribution main
EOF

其中$distribution是使用的 Debian 或 Ubuntu 发行版的名称(参见上表)。

因此,例如,在 Debian Buster 上它将是

sudo tee /etc/apt/sources.list.d/rabbitmq.list <<EOF
## Provides modern Erlang/OTP releases
##
## The Ubuntu PPA is not aware of Debian distribution names.
## "bionic" as distribution name should work for any reasonably recent Ubuntu or Debian release.
deb [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic main
deb-src [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic main

## Provides RabbitMQ
##
deb [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ buster main
deb-src [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ buster main
EOF
Step 4:安装包

更新apt源列表后,有必要运行apt-get update

sudo apt-get update -y

然后安装包

## Install Erlang packages
sudo apt-get install -y erlang-base \
                        erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \
                        erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key \
                        erlang-runtime-tools erlang-snmp erlang-ssl \
                        erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl

## Install rabbitmq-server and its dependencies
sudo apt-get install rabbitmq-server -y --fix-missing
安装遇到错误

下列软件包有未满足的依赖关系:
erlang-crypto : 依赖: libssl1.1 (>= 1.1.1) 但无法安装它
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。

解决方案

单独下载安装一个libssl1.1_1.1.1f-1ubuntu2_amd64.deb文件然后再升级就可以了

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb

使用aptitude进行安装,aptitude 会对依赖关系进行智能处理

sudo apt-get install aptitude
sudo aptitude install <package name>
作者:Jeebiz  创建时间:2023-04-11 00:36
最后编辑:Jeebiz  更新时间:2024-09-23 10:03