如何在 Ubuntu 22.04 LTS 上安装 RabbitMQ

Linux命令 Edge插件网 2年前 (2023-03-04) 557次浏览 已收录 0个评论

RabbitMQ 是一种流行的开源消息代理,它根据预定义的规则在两个或多个服务之间存储和传递异步消息。它是一种中间软件,可确保您的系统更可靠、可扩展且始终可用。它实现了高级消息队列协议 (AMQP)、面向文本的流消息传递协议 (STOMP)、MQ 遥测传输 (MQTT) 和其他协议。如何在 Ubuntu 22.04 LTS 上安装 RabbitMQ

在 Ubuntu 22.04 LTS Jammy Jellyfish 上安装 RabbitMQ

第 1 步。首先,通过在终端中运行以下命令,确保所有系统软件包都是最新的。apt

<span class="pln">sudo apt update
sudo apt upgrade
sudo apt install curl gnupg apt</span><span class="pun">-</span><span class="pln">transport</span><span class="pun">-</span><span class="pln">https</span>

第 2 步。正在安装 Erlang。

现在我们使用以下命令安装所需的 ErLang 软件包:

<span class="pln">sudo apt install </span><span class="pun">-</span><span class="pln">y erlang</span><span class="pun">-</span><span class="kwd">base</span><span class="pln"> \
    erlang</span><span class="pun">-</span><span class="pln">asn1 erlang</span><span class="pun">-</span><span class="pln">crypto erlang</span><span class="pun">-</span><span class="pln">eldap erlang</span><span class="pun">-</span><span class="pln">ftp erlang</span><span class="pun">-</span><span class="pln">inets \
    erlang</span><span class="pun">-</span><span class="pln">mnesia erlang</span><span class="pun">-</span><span class="pln">os</span><span class="pun">-</span><span class="pln">mon erlang</span><span class="pun">-</span><span class="pln">parsetools erlang</span><span class="pun">-</span><span class="kwd">public</span><span class="pun">-</span><span class="pln">key \
    erlang</span><span class="pun">-</span><span class="pln">runtime</span><span class="pun">-</span><span class="pln">tools erlang</span><span class="pun">-</span><span class="pln">snmp erlang</span><span class="pun">-</span><span class="pln">ssl \
    erlang</span><span class="pun">-</span><span class="pln">syntax</span><span class="pun">-</span><span class="pln">tools erlang</span><span class="pun">-</span><span class="pln">tftp erlang</span><span class="pun">-</span><span class="pln">tools erlang</span><span class="pun">-</span><span class="pln">xmerl</span>

有关安装 Erlang 的其他资源,请阅读下面的帖子:

  • 如何在 Ubuntu Linux √ 上安装 Erlang

第 3 步。在 Ubuntu 22.04 上安装 RabbitMQ

默认情况下,RabbitMQ 在 Ubuntu 22.04 基本存储库中不可用。现在运行以下命令,将 RabbitMQ 存储库添加到您的 Ubuntu 系统中:

<span class="pln">deb </span><span class="pun">[</span><span class="kwd">signed</span><span class="pun">-</span><span class="kwd">by</span><span class="pun">=</span><span class="str">/usr/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">keyrings</span><span class="pun">/</span><span class="pln">net</span><span class="pun">.</span><span class="pln">launchpad</span><span class="pun">.</span><span class="pln">ppa</span><span class="pun">.</span><span class="pln">rabbitmq</span><span class="pun">.</span><span class="pln">erlang</span><span class="pun">.</span><span class="pln">gpg</span><span class="pun">]</span><span class="pln"> http</span><span class="pun">:</span><span class="com">//ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu jammy main</span><span class="pln">
deb</span><span class="pun">-</span><span class="pln">src </span><span class="pun">[</span><span class="kwd">signed</span><span class="pun">-</span><span class="kwd">by</span><span class="pun">=</span><span class="str">/usr/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">keyrings</span><span class="pun">/</span><span class="pln">net</span><span class="pun">.</span><span class="pln">launchpad</span><span class="pun">.</span><span class="pln">ppa</span><span class="pun">.</span><span class="pln">rabbitmq</span><span class="pun">.</span><span class="pln">erlang</span><span class="pun">.</span><span class="pln">gpg</span><span class="pun">]</span><span class="pln"> http</span><span class="pun">:</span><span class="com">//ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu jammy main</span><span class="pln">
deb </span><span class="pun">[</span><span class="kwd">signed</span><span class="pun">-</span><span class="kwd">by</span><span class="pun">=</span><span class="str">/usr/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">keyrings</span><span class="pun">/</span><span class="pln">io</span><span class="pun">.</span><span class="pln">packagecloud</span><span class="pun">.</span><span class="pln">rabbitmq</span><span class="pun">.</span><span class="pln">gpg</span><span class="pun">]</span><span class="pln"> https</span><span class="pun">:</span><span class="com">//packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ jammy main</span><span class="pln">
deb</span><span class="pun">-</span><span class="pln">src </span><span class="pun">[</span><span class="kwd">signed</span><span class="pun">-</span><span class="kwd">by</span><span class="pun">=</span><span class="str">/usr/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">keyrings</span><span class="pun">/</span><span class="pln">io</span><span class="pun">.</span><span class="pln">packagecloud</span><span class="pun">.</span><span class="pln">rabbitmq</span><span class="pun">.</span><span class="pln">gpg</span><span class="pun">]</span><span class="pln"> https</span><span class="pun">:</span><span class="com">//packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ jammy main</span>

接下来,使用以下命令添加 GPG 密钥:

<span class="pln">curl </span><span class="pun">-</span><span class="lit">1sLf</span> <span class="str">"https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA"</span> <span class="pun">|</span><span class="pln"> sudo gpg </span><span class="pun">--</span><span class="pln">dearmor </span><span class="pun">|</span><span class="pln"> sudo tee </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">keyrings</span><span class="pun">/</span><span class="pln">com</span><span class="pun">.</span><span class="pln">rabbitmq</span><span class="pun">.</span><span class="pln">team</span><span class="pun">.</span><span class="pln">gpg </span><span class="pun">></span> <span class="str">/dev/</span><span class="kwd">null</span><span class="pln">
curl </span><span class="pun">-</span><span class="lit">1sLf</span> <span class="str">"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xf77f1eda57ebb1cc"</span> <span class="pun">|</span><span class="pln"> sudo gpg </span><span class="pun">--</span><span class="pln">dearmor </span><span class="pun">|</span><span class="pln"> sudo tee </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">keyrings</span><span class="pun">/</span><span class="pln">net</span><span class="pun">.</span><span class="pln">launchpad</span><span class="pun">.</span><span class="pln">ppa</span><span class="pun">.</span><span class="pln">rabbitmq</span><span class="pun">.</span><span class="pln">erlang</span><span class="pun">.</span><span class="pln">gpg </span><span class="pun">></span> <span class="str">/dev/</span><span class="kwd">null</span><span class="pln">
curl </span><span class="pun">-</span><span class="lit">1sLf</span> <span class="str">"https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey"</span> <span class="pun">|</span><span class="pln"> sudo gpg </span><span class="pun">--</span><span class="pln">dearmor </span><span class="pun">|</span><span class="pln"> sudo tee </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">share</span><span class="pun">/</span><span class="pln">keyrings</span><span class="pun">/</span><span class="pln">io</span><span class="pun">.</span><span class="pln">packagecloud</span><span class="pun">.</span><span class="pln">rabbitmq</span><span class="pun">.</span><span class="pln">gpg </span><span class="pun">></span> <span class="str">/dev/</span><span class="kwd">null</span>

添加存储库后,现在使用以下命令安装 RabbitMQ 服务器和依赖项:

<span class="pln">sudo apt update
sudo apt install rabbitmq</span><span class="pun">-</span><span class="pln">server </span><span class="pun">-</span><span class="pln">y </span><span class="pun">--</span><span class="pln">fix</span><span class="pun">-</span><span class="pln">missing</span>

成功安装后,RabbitMQ 将启动并在启动时启用。您可以使用以下命令进行检查:

<span class="pln">sudo systemctl enable rabbitmq</span><span class="pun">-</span><span class="pln">server
sudo systemctl start rabbitmq</span><span class="pun">-</span><span class="pln">server</span>

第 4 步。启用 RabbitMQ 管理控制台。

要启用 RabbitMQ 管理 UI,请先启用管理插件:

<span class="pln">rabbitmq</span><span class="pun">-</span><span class="pln">plugins enable rabbitmq_management</span>

第5步。配置防火墙。

现在,我们使用 Apache 设置了一个简单防火墙 (UFW),以允许在 5672 和 15672 的默认 Web 端口上进行公共访问:

<span class="pln">sudo ufw allow </span><span class="typ">OpenSSH</span><span class="pln">
sudo ufw allow proto tcp </span><span class="kwd">from</span><span class="pln"> any to any port </span><span class="lit">5672</span><span class="pun">,</span><span class="lit">15672</span><span class="pln">
sudo ufw enable</span>

第 6 步。访问 RabbitMQ Web 界面。

成功安装后,打开您的 Web 浏览器并使用 URL 访问 RabbitMQ 安装向导。您将被重定向到以下页面:http://your-domain.com:15672 or http://server-ip-address:15672

如何在 Ubuntu 22.04 LTS 上安装 RabbitMQ

缺省情况下,来宾用户存在并且只能从 进行连接。您可以使用密码“guest”在当地使用此用户登录localhost

建议在设置 RabbitMQ 服务器时创建一个新用户并为其分配管理权限。您可以使用该命令添加新用户。选择一个唯一的用户名并设置一个安全密码以继续:rabbitmqctl add_user

<span class="pln">rabbitmqctl add_user ngadimin y0ur</span><span class="pun">-</span><span class="typ">Strong</span><span class="pun">-</span><span class="typ">Passwd</span><span class="pln">
rabbitmqctl set_user_tags ngadimin administrator</span>

出于安全原因,还建议删除默认用户来宾:

<span class="pln">rabbitmqctl delete_user guest</span>

请随时检查用户列表以确保您的配置正确:

<span class="pln">rabbitmqctl list_users</span>

感谢您使用本教程在 Ubuntu 22.04 LTS Jammy Jellyfish 系统上安装 RabbitMQ。如需其他帮助或有用信息,我们建议您查看 RabbitMQ 网站


Edge插件网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在 Ubuntu 22.04 LTS 上安装 RabbitMQ
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址