# RabbitMQ设置

{% hint style="info" %}
及时获悉最准确和最新硬件建议，请参考[RabbitMQ官方文档](https://www.rabbitmq.com/docs/production-checklist)。
{% endhint %}

对于生产系统，建议使用具有[仲裁队列](https://bbs.huaweicloud.com/blogs/364672) (quorum queues) 的多节点RabbitMQ集群，以确保消息的耐用性和高可用性。这种设置可提高容错能力和性能，从而构建可靠的消息传递基础设施。

### 硬件要求

* CPU：多核处理器
* 内存：单个节点至少 4GB
* 硬盘：建议使用SSD硬盘，以获得更好的性能
* 网络：高速、低延迟的网络连接

### 安装RabbitMQ

遵循[RabbitMQ官方安装文档](https://www.rabbitmq.com/docs/download#installation-guides)要求，选择合适你操作系统的安装流程。

### 添加RabbitMQ凭证

1. **启用RabbitMQ管理面板**

```
sudo rabbitmq-plugins enable rabbitmq_management
```

2. **为RabbitMQ创建管理员用户**

{% hint style="info" %}
服务器稍后将使用这些确切的凭证连接到队列。
{% endhint %}

```
sudo rabbitmqctl add_user <admin> <password>
sudo rabbitmqctl set_user_tags <admin> <administrator>
sudo rabbitmqctl set_permissions -p / <admin> ".*" ".*" ".*"
```

你可以自定义`<admin>` (管理员用户名)、 `<password>`(密码)。

3. **访问RabbitMQ管理面板**

在浏览器打开：<http://localhost:15672>，导航到`default`，RabbitMQ的默认管理面板。

使用用户名`<admin>`和上一步中设置的密码`<password>`登录管理面板。

### 服务器监控

可通过[Prometheus Blackbox Exporter](https://github.com/prometheus/blackbox_exporter)轮询RabbitMQ服务器的可用性。

RabbitMQ特定的Prometheus指标也可以通过任何开源[Prometheus RabbitMQ导出器](https://github.com/kbudde/rabbitmq_exporter)来公开。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.docszh.com/babylon-docs/user-guides/bitcoin-staking-phase1/backend-deployment/infra/rabbitmq.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
