跳至主内容
版本:4.2

每用户资源限制

概述

每个虚拟主机资源限制类似,可以限制特定用户可以打开的连接和通道数量。

在无法信任并详细监控应用程序的环境中,例如 RabbitMQ 集群作为服务提供时,可以使用这些限制作为保护措施。

可以使用 CLI 工具或HTTP API 来配置这些限制。

最大连接数

要限制用户可以打开的连接数,请将 max-connections 限制设置为正整数

rabbitmqctl set_user_limits user1 '{"max-connections": 10}'

最大通道数

要限制用户总共可以打开的通道数,请将 max-channels 限制设置为正整数

rabbitmqctl set_user_limits guest '{"max-connections": 10, "max-channels": 20}'

此限制应用于用户打开的所有连接的总通道数。因此,它必须等于或大于上述最大连接数限制。

列出用户限制

列出特定用户的限制

rabbitmqctl list_user_limits user1

清除用户限制

要清除用户的限制,请使用 CLI 工具或HTTP API

# clears the maximum number of connections limit
rabbitmqctl clear_user_limits user1 'max-connections'

# clears the maximum number of channels limit
rabbitmqctl clear_user_limits user1 'max-channels'

# clears all limits in a single operation
rabbitmqctl clear_user_limits user1 all
© . This site is unofficial and not affiliated with VMware.