RabbitMQ管理3

2022-04-23 18:58:08 浏览数 (4)

查看vhost中的权限分配

不使用 -p 指定vhost时,默认会使用 /

代码语言:javascript复制
[root@h102 ~]# rabbitmqctl list_permissions
Listing permissions in vhost "/" ...
guest	.*	.*	.*
[root@h102 ~]# rabbitmqctl list_permissions -p /abc
Listing permissions in vhost "/abc" ...
[root@h102 ~]# rabbitmqctl list_permissions -p mq_test
Listing permissions in vhost "mq_test" ...
[root@h102 ~]# 

查看用户权限

list_user_permissions 可以查看指定用户在不同vhost中的权限

代码语言:javascript复制
[root@h102 ~]# rabbitmqctl list_users
Listing users ...
guest	[administrator]
mq	[]
[root@h102 ~]# rabbitmqctl list_user_permissions 
Error: list_user_permissions expects a username argument, but none provided.
[root@h102 ~]# rabbitmqctl list_user_permissions guest
Listing permissions for user "guest" ...
/	.*	.*	.*
[root@h102 ~]# rabbitmqctl list_user_permissions mq
Listing permissions for user "mq" ...
[root@h102 ~]# 

分配权限

代码语言:javascript复制
[root@h102 ~]# rabbitmqctl set_permissions -p mq_test mq ".*" ".*" ".*"
Setting permissions for user "mq" in vhost "mq_test" ...
[root@h102 ~]# rabbitmqctl set_permissions -p / mq "^mq.*" ".*" ".*"
Setting permissions for user "mq" in vhost "/" ...
[root@h102 ~]# rabbitmqctl list_user_permissions mq
Listing permissions for user "mq" ...
/	^mq.*	.*	.*
mq_test	.*	.*	.*
[root@h102 ~]# rabbitmqctl list_permissions -p /
Listing permissions in vhost "/" ...
guest	.*	.*	.*
mq	^mq.*	.*	.*
[root@h102 ~]# 

0 人点赞