RabbitMQ management
User Management
list users rabbitmqctl list_users
[root@g66 opt]# rabbitmqctl list_users Listing users ... guest [administrator] [root@g66 opt]#
add user rabbitmqctl add_user username user password
[root@g66 opt]# rabbitmqctl add_user ycj ycj123 Creating user "ycj" ... [root@g66 opt]# rabbitmqctl list_users Listing users ... guest [administrator] life [] [root@g66 opt]#
Modify user password rabbitmqctl change_password username new password
[root@g66 opt]# rabbitmqctl change_password ycj 123456 Changing password for user "ycj" ... [root@g66 opt]#
clear password rabbitmqctl clear_password username (note: the user whose password is cleared will not be able to log in with the password)
[root@g66 opt]# rabbitmqctl clear_password ycj Clearing password for user "ycj" ... [root@g66 opt]#
Tag a user rabbitmqctl set_user_tags username tag name (role name)
[root@g66 opt]# rabbitmqctl set_user_tags ycj administrator Setting tags for user "ycj" to [administrator] ... [root@g66 opt]# rabbitmqctl list_users Listing users ... guest [administrator] ycj [administrator] [root@g66 opt]#
Recycling tag rabbitmqctl set_user_tags username (default is empty if no tag is written)
[root@g66 opt]# rabbitmqctl set_user_tags ycj Setting tags for user "ycj" to [] ... [root@g66 opt]# rabbitmqctl list_users Listing users ... guest [administrator] life [] [root@g66 opt]#
Note: Multiple flags can be set at one time. The latest command will be used as the standard, and the previous setting will be overwritten, so make a record to restore it.
[root@g66 opt]# rabbitmqctl set_user_tags ycj hui layui Setting tags for user "ycj" to [hui,layui] ... [root@g66 opt]# rabbitmqctl list_users Listing users ... guest [administrator] ycj [hui, layui] [root@g66 opt]#
Tip: You can write any tags
There are 5 default labels in user
● management: access the management plugin
● policymaker: access the management plugin and manage the policies and parameters of your own vhosts
● monitoring: access the management plugin and view all configuration and channel and node information
● administrator: all permissions
● Node: no configuration
delete user rabbitmqctl delete_user username
[root@g66 opt]# rabbitmqctl list_users Listing users ... guest [administrator] ycj [hui, layui] [root@g66 opt]# rabbitmqctl delete_user ycj Deleting user "ycj" ... [root@g66 opt]# rabbitmqctl list_users Listing users ... guest [administrator] [root@g66 opt]#
Access control
There is a concept of vhost in RabbitMQ, which is not the same as vhost in other software. In Apache, it represents a virtual site, and here it represents a namespace and permission set
A vhost contains a bunch of exchange, binding, queue, permission, parameter and policy elements. Having permission to a vhost and having permission to a vhost means that it has corresponding operation permissions for these elements under it. Its setting It is for the convenience of permission assignment and isolation system with a default vhost named "/"
Different applications, it is best to use different vhosts for isolation
列出vhost rabbitmqctl list_vhosts
[root@g66 ~]# rabbitmqctl list_vhosts Listing vhosts ... / test [root@g66 ~]#
Add vhost rabbitmqctl add_vhost virtual hostname
[root@g66 ~]# rabbitmqctl add_vhost ycj Creating vhost "ycj" ... [root@g66 ~]# rabbitmqctl list_vhosts Listing vhosts ... / test life [root@g66 ~]#
View permission assignments in vhost rabbitmqctl list_permissions -p virtual host name
Note: When the vhost is not specified with -p, "/" will be used by default
[root@g66 ~]# rabbitmqctl list_permissions Listing permissions in vhost "/" ... guest .* .* .* [root@g66 ~]# rabbitmqctl list_permissions -p ycj Listing permissions in vhost "ycj" ... [root@g66 ~]# rabbitmqctl list_permissions -p test Listing permissions in vhost "test" ... [root@g66 ~]#
View user's permissions rabbitmqctl list_user_permissions username
[root@g66 ~]# rabbitmqctl list_users Listing users ... guest [administrator] life [] [root@g66 ~]# rabbitmqctl list_user_permissions guest Listing permissions for user "guest" ... / .* .* .* [root@g66 ~]# rabbitmqctl list_user_permissions ycj Listing permissions for user "ycj" ... [root@g66 ~]#
Assign permissions rabbitmqctl set_permissions -p virtual hostname username permissions
[root@g66 ~]# rabbitmqctl set_permissions -p / ycj ".*" ".*" ".*" Setting permissions for user "ycj" in vhost "/" ... [root@g66 ~]# rabbitmqctl list_user_permissions ycj Listing permissions for user "ycj" ... / .* .* .* [root@g66 ~]# rabbitmqctl list_permissions Listing permissions in vhost "/" ... guest .* .* .* life. *. *. * [root@g66 ~]#
Take back permissions rabbitmqctl clear_permissions -p virtual hostname username
Note: When you do not use -p to specify vhost, "/" will be used by default and will not clear all
[root@g66 ~]# rabbitmqctl clear_permissions -p / ycj Clearing permissions for user "ycj" in vhost "/" ... [root@g66 ~]# rabbitmqctl list_permissions Listing permissions in vhost "/" ... guest .* .* .* [root@g66 ~]#
delete vhost rabbitmqctl delete_vhost vhostname
[root@g66 ~]# rabbitmqctl list_vhosts Listing vhosts ... / test life [root@g66 ~]# rabbitmqctl delete_vhost test Deleting vhost "test" ... [root@g66 ~]# rabbitmqctl list_vhosts Listing vhosts ... / life [root@g66 ~]#
[root@g66 ~]# rabbitmqctl delete_vhost / Deleting vhost "/" ... [root@g66 ~]# rabbitmqctl list_vhosts Listing vhosts ... life [root@g66 ~]#Status view
returns the information of the queue. If the -p parameter is omitted, the information of "/" vhosts is displayed by default.
list_exchanges [-p <vhostpath>] [<exchangeinfoitem> ...]
Returns exchange information.
list_bindings [-p <vhostpath>] [<bindinginfoitem> ...]
Returns binding information.
list_connections [<connectioninfoitem> ...]
returns link information.
list_channels [<channelinfoitem> ...]
returns all current channels.
list_consumers [-p <vhostpath>]
returns consumers,
status
shows the status of the broker
environment
shows the information of environment parameters
report #Returns
a service status report,
eval <expr>