RabbitMQ Broker管理
1. RabbitMQ Plugins使用
RabbitMQ自带插件管理系统,可以使用工具[rabbitmq-plugins]进行管理和使用。查看当前插件状态[tRabbitMQ@iZ250x18mnzZ ~]$ rabbitmq-plugins list Configured: E = explicitly enabled; e = implicitly enabled | Status: [failed to contact rabbit@iZ250x18mnzZ - status not shown] |/ [e ] amqp_client 3.6.0 [ ] cowboy 1.0.3 [ ] cowlib 1.0.1 [e ] mochiweb 2.13.0 [ ] rabbitmq_amqp1_0 3.6.0 [ ] rabbitmq_auth_backend_ldap 3.6.0 [ ] rabbitmq_auth_mechanism_ssl 3.6.0 [ ] rabbitmq_consistent_hash_exchange 3.6.0 [ ] rabbitmq_event_exchange 3.6.0 [ ] rabbitmq_federation 3.6.0 [ ] rabbitmq_federation_management 3.6.0 [E ] rabbitmq_management 3.6.0 [e ] rabbitmq_management_agent 3.6.0 [ ] rabbitmq_management_visualiser 3.6.0 [ ] rabbitmq_mqtt 3.6.0 [ ] rabbitmq_recent_history_exchange 1.2.1 [ ] rabbitmq_sharding 0.1.0 [ ] rabbitmq_shovel 3.6.0 [ ] rabbitmq_shovel_management 3.6.0 [ ] rabbitmq_stomp 3.6.0 [ ] rabbitmq_tracing 3.6.0 [e ] rabbitmq_web_dispatch 3.6.0 [ ] rabbitmq_web_stomp 3.6.0 [ ] rabbitmq_web_stomp_examples 3.6.0 [ ] sockjs 0.3.4 [e ] webmachine git启用插件
[tRabbitMQ@iZ250x18mnzZ ~]$ sudo rabbitmq-plugins enable rabbitmq_management The following plugins have been enabled: mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_management_agent rabbitmq_management Applying plugin configuration to rabbit@iZ250x18mnzZ... started 6 plugins.
停用插件
[tRabbitMQ@iZ250x18mnzZ ~]$ sudo rabbitmq-plugins disable rabbitmq_management The following plugins have been disabled: mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_management_agent rabbitmq_management Applying plugin configuration to rabbit@iZ250x18mnzZ... stopped 6 plugins.
具体的命令使用参考官网资料: https://www.rabbitmq.com/man/rabbitmq-plugins.1.man.html除系统安装自带的插件,RabbtiMQ还提供了一些其他插件可下载使用:https://www.rabbitmq.com/community-plugins.html不再对其他的插件相关内容做分析,大家有兴趣的可以点击以下链接到官网学习2. Management Plugin
管理插件在安装RabbtiMQ时就已经同步安装,只需使用上面的启动命令启动插件即可。管理插件提供了一套对RabbitMQ服务的管理及监控的HTTP API,以及基于浏览器服的用户界面、命令行工具以及rabbitmqadmin(工具)。主要有以下功能:1、 声明、查询、删除交换机、队列、bindings、用户、虚拟机以及权限
2、 监控队列、通道、数据连接等信息
3、 发送和接收消息
4、 监控Erlang进程、内存使用、文件描述符
5、 导入或导出json对象
6、 强制关闭连接,清理队列按照上述方式启动之后。1、web访问地址:http://server-name:15672/ 端口可自定义配置2、http api访问地址:http://server-name:15672/api/ 也可以参考官网:https://raw.githack.com/rabbitmq/rabbitmq-management/rabbitmq_v3_6_1/priv/www/api/index.html3、下载工具rabbitmqadmin:http://server-name:15672/cli/ 关于客户端使用方法:https://www.rabbitmq.com/management-cli.html其他相关使用方法,参考官网:https://www.rabbitmq.com/management.html安装RabbitMQ自带的用户guest,只能在本地使用,所以公网中用户guest无法登录management提供的插件,下面是新建用户并增加。3. 用户及权限管理
3.1.用户管理
创建用户
[tRabbitMQ@iZ250x18mnzZ ~]$ sudo rabbitmqctl add_user rabbitmq rabbitmq Creating user "rabbitmq" ...
删除用户
[tRabbitMQ@iZ250x18mnzZ ~]$ sudo rabbitmqctl delete_user rabbitmq Deleting user "rabbitmq" ...
查看用户
[tRabbitMQ@iZ250x18mnzZ ~]$ sudo rabbitmqctl list_users Listing users ... rabbitmq [] guest [administrator]
修改用户密码
[tRabbitMQ@iZ250x18mnzZ ~]$ sudo rabbitmqctl change_password rabbitmq rabbitmq Changing password for user "rabbitmq" ... [tRabbitMQ@iZ250x18mnzZ ~]$
命令参考资料:http://www.rabbitmq.com/man/rabbitmqctl.1.man.html
3.2. 用户角色管理
创建用户之后,还需要给用户添加权限,在插件management中基于RabbitMQ权限模型进行了封装与扩展,对用户指定类似标签的方式决定用户的权限,提供以下几类标签:
标签 功能 (None) No access to the management plugin management Anything the user could do via AMQP plus:
- List virtual hosts to which they can log in via AMQP
- View all queues, exchanges and bindings in "their" virtual hosts
- View and close their own channels and connections
- View "global" statistics covering all their virtual hosts, including activity by other users within them
policymaker Everything "management" can plus:
- View, create and delete policies and parameters for virtual hosts to which they can log in via AMQP
monitoring Everything "management" can plus:
- List all virtual hosts, including ones they could not log in to via AMQP
- View other users's connections and channels
- View node-level data such as memory use and clustering
- View truly global statistics for all virtual hosts
administrator Everything "policymaker" and "monitoring" can plus:
- Create and delete virtual hosts
- View, create and delete users
- View, create and delete permissions
- Close other users's connections
给用户设置标签也可以给用户设置多个角色,除上述系统内置角色外,还可以自定义角色,具体可参考官网给出的命令
[tRabbitMQ@iZ250x18mnzZ ~]$ sudo rabbitmqctl set_user_tags rabbitmq administrator Setting tags for user "rabbitmq" to [administrator] ... [tRabbitMQ@iZ250x18mnzZ ~]$
管理工具角色参考官网:http://www.rabbitmq.com/management.html3.3. 权限管理
权限大致分为两个级别:1. 访问权限决定是否可以连接上相应的服务按照前两步的方法,创建用户,给用户设置用户角色,我就可以登录到web2. 操作权限操作权限又分为两类,配置权限和读写权限,只要针对资源(queue、exchange)配置权限影响资源的创建和删除。读写权限影响消息的读取和写入,例如发送消息要有可写权限,接收消息要有可读权限。具体说明可见官网资料,而给用户设置相应的权限,使用rabbitmqctl执行即可,下面也有提供具体的手机用方法。RabbitMQ权限模型说明参考资料:http://www.rabbitmq.com/access-control.html
所有内容皆为个人总结或转载别人的文章,只为学习技术。 若您觉得文章有用,欢迎点赞分享! 若无意对您的文章造成侵权,请您留言,博主看到后会及时处理,谢谢。