码迷,mamicode.com
首页 > 其他好文 > 详细

RabbitMQ概念及环境搭建(二)RabbitMQ Broker管理

时间:2014-12-12 19:13:57      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:rabbitmq

rabbitmqctl [-n node] [-q] {command} [command options...]
1.停Server
rabbitmqctl stop

2.查看状态
rabbitmqctl status

其他常用项
sudo rabbitmqctl list_queues
sudo rabbitmqctl list_exchanges
sudo rabbitmqctl list_bindings
...
3.UI
rabbitmq-management plugin
基于HTTP的RabbitMQ server管理和监控工具
包含基于浏览器的用户界面和命令行工具rabbitmqadmin. 

启用
sudo rabbitmq-plugins enable rabbitmq_management

访问

http://server-name:15672/
http://server-name:15672/api #HTTP API
http://server-name:15672/cli #rabbitmqadmin 

提示
默认guest账户只能从localhost登录,需先添加用户用赋予相应权限
可通过配置rabbitmq.config改变rabbitmq-management plugin默认行为

4.用户管理(增删改查)
新增用户
rabbitmqctl  add_user  Username  Password
删除用户
rabbitmqctl  delete_user  Username
修改密码
rabbitmqctl  change_password  Username  Newpassword
查看用户列表
rabbitmqctl  list_users

5.用户角色
分为五类,其他、management、policymaker、monitoring、administrator、
各自的权限如下:
(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

设置用户角色
rabbitmqctl  set_user_tags  User  Tag
Tag为角色名administrator,monitoring,policymaker,management或其他自定义名称

可给同一用户设置多个角色,如:
rabbitmqctl set_user_tags testmq monitoring policymaker administrator

参考:
http://www.rabbitmq.com/management.html

6.用户权限
指用户对exchange,queue的操作权限,包括配置权限,读写权限。
配置权限会影响到exchange,queue的声明和删除。
读写权限影响到从queue里取消息,向exchange发送消息以及queue和exchange的绑定(bind)操作。

例如:
将queue绑定到某exchange上,需要具有queue的可写权限,以及exchange的可读权限;
向exchange发送消息需要具有exchange的可写权限;
从queue里取数据需要具有queue的可读权限.

设置用户权限
rabbitmqctl  set_permissions  -p  VHostPath  User  ConfP  WriteP  ReadP
查看(指定hostpath)所有用户的权限信息
rabbitmqctl  list_permissions  [-p  VHostPath]
查看指定用户的权限信息
rabbitmqctl  list_user_permissions  User
清除用户的权限信息
rabbitmqctl  clear_permissions  [-p VHostPath]  User

参考:
http://www.rabbitmq.com/access-control.html

RabbitMQ概念及环境搭建(二)RabbitMQ Broker管理

标签:rabbitmq

原文地址:http://blog.csdn.net/zyz511919766/article/details/41896685

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!