RabbitMQ系列:rabbitmqctl在application、cluster、user、accesscontrol、monitoring、observability 等方面的management
目录
网址:https://www.rabbitmq.com/rabbitmqctl.8.html
命令介绍
rabbitmqctl [-q] [-s] [-l] [-n node] [-t timeout] command [command_options]
rabbitmq help
[root@vmcode local]# rabbitmqctl help
Usage
rabbitmqctl [--node <node>] [--timeout <timeout>] [--longnames] [--quiet] <command> [<command options>]
Available commands:
Help:
autocomplete Provides command name autocomplete variants
help Displays usage information for a command
version Displays CLI tools version
Nodes:
await_startup Waits for the RabbitMQ application to start on the target node
reset Instructs a RabbitMQ node to leave the cluster and return to its virgin state
rotate_logs Instructs the RabbitMQ node to perform internal log rotation
shutdown Stops RabbitMQ and its runtime (Erlang VM). Monitors progress for local nodes. Does not require a PID file path.
start_app Starts the RabbitMQ application but leaves the runtime (Erlang VM) running
stop Stops RabbitMQ and its runtime (Erlang VM). Requires a local node pid file path to monitor progress.
stop_app Stops the RabbitMQ application, leaving the runtime (Erlang VM) running
wait Waits for RabbitMQ node startup by monitoring a local PID file. See also 'rabbitmqctl await_online_nodes'
Cluster:
await_online_nodes Waits for <count> nodes to join the cluster
change_cluster_node_type Changes the type of the cluster node
cluster_status Displays all the nodes in the cluster grouped by node type, together with the currently running nodes
force_boot Forces node to start even if it cannot contact or rejoin any of its previously known peers
force_reset Forcefully returns a RabbitMQ node to its virgin state
forget_cluster_node Removes a node from the cluster
join_cluster Instructs the node to become a member of the cluster that the specified node is in
rename_cluster_node Renames cluster nodes in the local database
update_cluster_nodes Instructs a cluster member node to sync the list of known cluster members from <seed_node>
Replication:
cancel_sync_queue Instructs a synchronising mirrored queue to stop synchronising itself
sync_queue Instructs a mirrored queue with unsynchronised mirrors (follower replicas) to synchronise them
Users:
add_user Creates a new user in the internal database. This user will have no permissions for any virtual hosts by default.
authenticate_user Attempts to authenticate a user. Exits with a non-zero code if authentication fails.
change_password Changes the user password
clear_password Clears (resets) password and disables password login for a user
clear_user_limits Clears user connection/channel limits
delete_user Removes a user from the internal database. Has no effect on users provided by external backends such as LDAP
list_user_limits Displays configured user limits
list_users List user names and tags
set_user_limits Sets user limits
set_user_tags Sets user tags
Access Control:
clear_permissions Revokes user permissions for a vhost
clear_topic_permissions Clears user topic permissions for a vhost or exchange
list_permissions Lists user permissions in a virtual host
list_topic_permissions Lists topic permissions in a virtual host
list_user_permissions Lists permissions of a user across all virtual hosts
list_user_topic_permissions Lists user topic permissions
list_vhosts Lists virtual hosts
set_permissions Sets user permissions for a vhost
set_topic_permissions Sets user topic permissions for an exchange
Monitoring, observability and health checks:
list_bindings Lists all bindings on a vhost
list_channels Lists all channels in the node
list_ciphers Lists cipher suites supported by encoding commands
list_connections Lists AMQP 0.9.1 connections for the node
list_consumers Lists all consumers for a vhost
list_exchanges Lists exchanges
list_hashes Lists hash functions supported by encoding commands
list_node_auth_attempt_stats Lists authentication attempts on the target node
list_queues Lists queues and their properties
list_unresponsive_queues Tests queues to respond within timeout. Lists those which did not respond
ping Checks that the node OS process is up, registered with EPMD and CLI tools can authenticate with it
report Generate a server status report containing a concatenation of all server status information for support purposes
schema_info Lists schema database tables and their properties
status Displays status of a node
Parameters:
clear_global_parameter Clears a global runtime parameter
clear_parameter Clears a runtime parameter.
list_global_parameters Lists global runtime parameters
list_parameters Lists runtime parameters for a virtual host
set_global_parameter Sets a runtime parameter.
set_parameter Sets a runtime parameter.
Policies:
clear_operator_policy Clears an operator policy
clear_policy Clears (removes) a policy
list_operator_policies Lists operator policy overrides for a virtual host
list_policies Lists all policies in a virtual host
set_operator_policy Sets an operator policy that overrides a subset of arguments in user policies
set_policy Sets or updates a policy
Virtual hosts:
add_vhost Creates a virtual host
clear_vhost_limits Clears virtual host limits
delete_vhost Deletes a virtual host
list_vhost_limits Displays configured virtual host limits
restart_vhost Restarts a failed vhost data stores and queues
set_vhost_limits Sets virtual host limits
trace_off
trace_on
Configuration and Environment:
decode Decrypts an encrypted configuration value
encode Encrypts a sensitive configuration value
environment Displays the name and value of each variable in the application environment for each running application
set_cluster_name Sets the cluster name
set_disk_free_limit Sets the disk_free_limit setting
set_log_level Sets log level in the running node
set_vm_memory_high_watermark Sets the vm_memory_high_watermark setting
Definitions:
export_definitions Exports definitions in JSON or compressed Erlang Term Format.
import_definitions Imports definitions in JSON or compressed Erlang Term Format.
Feature flags:
enable_feature_flag Enables a feature flag or all supported feature flags on the target node
list_feature_flags Lists feature flags
Operations:
close_all_connections Instructs the broker to close all connections for the specified vhost or entire RabbitMQ node
close_connection Instructs the broker to close the connection associated with the Erlang process id
eval Evaluates a snippet of Erlang code on the target node
eval_file Evaluates a file that contains a snippet of Erlang code on the target node
exec Evaluates a snippet of Elixir code on the CLI node
force_gc Makes all Erlang processes on the target node perform/schedule a full sweep garbage collection
resume_listeners Resumes client connection listeners making them accept client connections again
suspend_listeners Suspends client connection listeners so that no new client connections are accepted
Queues:
delete_queue Deletes a queue
purge_queue Purges a queue (removes all messages in it)
Deprecated:
hipe_compile DEPRECATED. This command is a no-op. HiPE is no longer supported by modern Erlang versions
node_health_check DEPRECATED. Performs intrusive, opinionated health checks on a fully booted node. See https://www.rabbitmq.com/monitoring.html#health-checks instead
Use 'rabbitmqctl help <command>' to learn more about a specific command
Nodes:节点管理
Nodes:
await_startup Waits for the RabbitMQ application to start on the target node
reset Instructs a RabbitMQ node to leave the cluster and return to its virgin state
rotate_logs Instructs the RabbitMQ node to perform internal log rotation
shutdown Stops RabbitMQ and its runtime (Erlang VM). Monitors progress for local nodes. Does not require a PID file path.
start_app Starts the RabbitMQ application but leaves the runtime (Erlang VM) running
stop Stops RabbitMQ and its runtime (Erlang VM). Requires a local node pid file path to monitor progress.
stop_app Stops the RabbitMQ application, leaving the runtime (Erlang VM) running
wait Waits for RabbitMQ node startup by monitoring a local PID file. See also 'rabbitmqctl await_online_nodes'
start_app:启动rabbitmq application
rabbitmqctl start_app #启动rabbitmq application
stop_app:关闭rabbitmq application
rabbitmqctl stop_app #关闭rabbitmq application
stop:关闭rabbitmq node 相当于退出rabbitmq-server
rabbitmqctl stop #关闭rabbitmq node 相当于退出rabbitmq-server
await_startup:等待启动
rabbitmqctl await_startup #等待启动
reset :格式化
rabbitmqctl reset #格式化
#Error: this command requires the 'rabbit' app to be stopped on the target node. Stop it with 'rabbitmqctl #stop_app'.
#Arguments given:
# reset
#
#Usage
#
#rabbitmqctl [--node <node>] [--longnames] [--quiet] reset
#[root@localhost lib]# rabbitmqctl stop_app
#Stopping rabbit application on node rabbit@localhost ...
#[root@localhost lib]# rabbitmqctl reset
#Resetting node rabbit@localhost ...
force_reset:强制格式化
rabbitmqctl force_reset #强制格式化,它不管当前管理数据库状态和集群配置
Cluster:集群管理
await_online_nodes Waits for <count> nodes to join the cluster
change_cluster_node_type Changes the type of the cluster node
cluster_status Displays all the nodes in the cluster grouped by node type, together with the currently running nodes
force_boot Forces node to start even if it cannot contact or rejoin any of its previously known peers
force_reset Forcefully returns a RabbitMQ node to its virgin state
forget_cluster_node Removes a node from the cluster
join_cluster Instructs the node to become a member of the cluster that the specified node is in
rename_cluster_node Renames cluster nodes in the local database
update_cluster_nodes Instructs a cluster member node to sync the list of known cluster members from <seed_node>
Replication:
cancel_sync_queue Instructs a synchronising mirrored queue to stop synchronising itself
sync_queue Instructs a mirrored queue with unsynchronised mirrors (follower replicas) to synchronise them
Users:用户管理
Users:
add_user Creates a new user in the internal database. This user will have no permissions for any virtual hosts by default.
authenticate_user Attempts to authenticate a user. Exits with a non-zero code if authentication fails.
change_password Changes the user password
clear_password Clears (resets) password and disables password login for a user
clear_user_limits Clears user connection/channel limits
delete_user Removes a user from the internal database. Has no effect on users provided by external backends such as LDAP
list_user_limits Displays configured user limits
list_users List user names and tags
set_user_limits Sets user limits
set_user_tags Sets user tags
add_user:添加用户
rabbitmqctl add_user admin admin123
authenticate_user:验证用户
rabbitmqctl authenticate_user admin admin123
delete_user:删除用户
rabbitmqctl delete_user admin
change_password:更改密码
rabbitmqctl change_password admin admin1234
clear_password:清除密码
rabbitmqctl clear_password admin
set_user_tags:设置标签
权限名称 | 权限说明 | |
---|---|---|
mangement | 用户可以访问管理插件 | |
policaymaker | 用户可以访问管理插件并管理他们有权访问的vhost的策略和参数。 | |
monitoring | 用户可以访问管理插件并查看所有连接和通道以及节点相关信息。 | |
administrator | 用户可以完成监视所能做的一切,管理用户、虚拟主机和权限,关闭其他用户的连接,以及管理所有虚拟主机的策略和参数。 |
rabbitmqctl set_user_tags admin administrator #设置为管理员权限
rabbitmqctl set_user_tags admin monitoring management #设置为访问并查看所有连接和通道以及节点相关信息
rabbitmqctl set_user_tags admin #什么标签也不设置,删除所有标签
list_users:列出所有用户
rabbitmqctl list_users #列出所有用户
Access Control:访问控制
clear_permissions Revokes user permissions for a vhost
clear_topic_permissions Clears user topic permissions for a vhost or exchange
list_permissions Lists user permissions in a virtual host
list_topic_permissions Lists topic permissions in a virtual host
list_user_permissions Lists permissions of a user across all virtual hosts
list_user_topic_permissions Lists user topic permissions
list_vhosts Lists virtual hosts
set_permissions Sets user permissions for a vhost
set_topic_permissions Sets user topic permissions for an exchange
set_permissions [-p vhost] username conf write read:设置权限
rabbitmqctl set_permissions -p my_vhost admin "^admin-.*" ".*" ".*"
rabbitmqctl set_permissions -p my_vhost admin ".*" ".*" ".*"
clear_permissions :清除权限
rabbitmqctl clear_permissions admin
rabbitmqctl clear_permissions -p my_vhost admin
list_user_permissions:查看用户所有权限
rabbitmqctl list_user_permissions admin
list_permissions :查看vhost所有权限
rabbitmqctl list_permissions -p my_vhost
rabbitmqctl list_permissions #不指定默认/
Monitoring、Observability、Health Checks:监控、可观察性、健康检查
list_bindings Lists all bindings on a vhost
list_channels Lists all channels in the node
list_ciphers Lists cipher suites supported by encoding commands
list_connections Lists AMQP 0.9.1 connections for the node
list_consumers Lists all consumers for a vhost
list_exchanges Lists exchanges
list_hashes Lists hash functions supported by encoding commands
list_node_auth_attempt_stats Lists authentication attempts on the target node
list_queues Lists queues and their properties
list_unresponsive_queues Tests queues to respond within timeout. Lists those which did not respond
ping Checks that the node OS process is up, registered with EPMD and CLI tools can authenticate with it
report Generate a server status report containing a concatenation of all server status information for support purposes
schema_info Lists schema database tables and their properties
status Displays status of a node
Runtime Parameters、Policies:运行时参数、策略
Parameters:
clear_global_parameter Clears a global runtime parameter
clear_parameter Clears a runtime parameter.
list_global_parameters Lists global runtime parameters
list_parameters Lists runtime parameters for a virtual host
set_global_parameter Sets a runtime parameter.
set_parameter Sets a runtime parameter.
Policies:
clear_operator_policy Clears an operator policy
clear_policy Clears (removes) a policy
list_operator_policies Lists operator policy overrides for a virtual host
list_policies Lists all policies in a virtual host
set_operator_policy Sets an operator policy that overrides a subset of arguments in user policies
set_policy Sets or updates a policy
Virtual Host:虚拟Host
Virtual hosts:
add_vhost Creates a virtual host
clear_vhost_limits Clears virtual host limits
delete_vhost Deletes a virtual host
list_vhost_limits Displays configured virtual host limits
restart_vhost Restarts a failed vhost data stores and queues
set_vhost_limits Sets virtual host limits
trace_off
trace_on
add_vhost:添加虚拟host
rabbitmqctl add_vhost my_vhost
delete_vhost :删除vhost
rabbitmqctl delete_vhost my_vhost
list_vhost:查看所有的vhost
rabbitmqctl list_vhosts
Configuration:配置
decode Decrypts an encrypted configuration value
encode Encrypts a sensitive configuration value
environment Displays the name and value of each variable in the application environment for each running application
set_cluster_name Sets the cluster name
set_disk_free_limit Sets the disk_free_limit setting
set_log_level Sets log level in the running node
set_vm_memory_high_watermark Sets the vm_memory_high_watermark setting
Connection Operations:连接操作
Operations:
close_all_connections Instructs the broker to close all connections for the specified vhost or entire RabbitMQ node
close_connection Instructs the broker to close the connection associated with the Erlang process id
eval Evaluates a snippet of Erlang code on the target node
eval_file Evaluates a file that contains a snippet of Erlang code on the target node
exec Evaluates a snippet of Elixir code on the CLI node
force_gc Makes all Erlang processes on the target node perform/schedule a full sweep garbage collection
resume_listeners Resumes client connection listeners making them accept client connections again
suspend_listeners Suspends client connection listeners so that no new client connections are accepted
Queue:队列
Queues:
delete_queue Deletes a queue
purge_queue Purges a queue (removes all messages in it)
Feature flags:功能标记
Feature flags:
enable_feature_flag Enables a feature flag or all supported feature flags on the target node
list_feature_flags Lists feature flags
Plugin Commands:插件命令
Shovel Plugin
AMQP Plugin
MQTT Plugin
STOMP Plugin
微信:17873041739
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?