Skip to main content

Monitoring & Management

Tutorials

TermsWeb toUI

explanation

Overview

  • prefetch:Ready: consumer已經發佈到 的參數。當 consumer 接收訊息是採 PUSH 模式,且發送端會有大量訊息寫入,由於 consumer 的 PUSH 模式,會一次接收大量(一次幾百或幾千)的訊息,假使 consumer 未能及時處理所有訊息,那些待處理的訊息會處於 Unacked 狀態,一旦 UnackedQueue 的訊息量過多,主機就會終止連線。
    要解決這個問題,consumer
  • 必須使用
  • Unacked: prefetch消費端已接收但尚未 限制主機每次推送至 consumerAck 的訊息量。 
  • LazyTotal: Queue:Ready Queue+ 的參數。對於較長(大)的訊息,可以使用這類 queue,記憶體的耗用可以改善,但會增加磁碟空間的使用率。Unacked

CLI

rabbitmq-diagnostics

Online Resource Utilization

rabbitmq-diagnostics observer

RabbitMQ Version

[root@tpeeaprmq98 ~]# rabbitmq-diagnostics server_version
Asking node rabbit@tpeeaprmq98 for its RabbitMQ version...
3.10.7
rabbitmqctl

List the queues

rabbitmqctl -p <vhost-name> list_queues name durable arguments policy

rabbitmqctl -qs -p <vhost-name> list_queues name > queue_names.lst

Recreate the virtual host

rabbitmqctl delete_vhost <my-vhost-name>
rabbltmqctl add_vhost <my-vhost-name>

Reset the RabbitMQ Node

The broker drops all virtual hosts, queues, exchanges, and non-administrative users.

rabbitmqctl stop_app
rabbitmqctl reset
rabbitmqctl start_app

Force Reset the RabbitMQ Node

如果 Cluster 損壞且無法恢復運作時,可以嘗試強制重設 Node。

rabbitmqctl stop_app
rabbitmqctl force_reset
rabbitmqctl start_app

Suspend all listeners and prevent new client connections

rabbitmqctl suspend_listeners

# suspends listeners on node rabbit@node2.cluster.rabbitmq.svc: it won't accept any new client connections
rabbitmqctl suspend_listeners -n rabbit@node2.cluster.rabbitmq.svc

# To resume all listeners on a node and make it accept new client connections again
rabbitmqctl resume_listeners
# resumes listeners on node rabbit@node2.cluster.rabbitmq.svc: it will accept new client connections again
rabbitmqctl resume_listeners -n rabbit@node2.cluster.rabbitmq.svc
rabbitmqadmin

Basic Operation

# List queus
rabbitmqadmin list queues
rabbitmqadmin -H <RabbitMQ-Server-IP> -u <username> -p <password> -V <vhost-name> list queues

# Add a queue with optional parameters
rabbitmqadmin declare queue name=<my-new-queu> durable=true auto_delete=true

Remove multiple queues

rabbitmqadmin -f tsv -q list queues name > q.txt
while read -r name; do rabbitmqadmin -q delete queue name="${name}"; done < q.txt