界面如图所示,默认端口为15672.
默认用户名和密码均为 guest
默认网页是不允许访问的,需要增加一个用户修改一下权限,代码如下:
添加用户:rabbitmqctl add_user tanx tanx
添加权限:rabbitmqctl set_permissions -p "/" tanx ".*" ".*" ".*"
修改用户角色rabbitmqctl set_user_tags tanx administrator
然后就可以远程访问了,然后可直接配置用户权限等信息。
set_permissions [-p vhost] {user} {conf} {write} {read}
vhost
The name of the virtual host to which to grant the user access, defaulting to /.
user
The name of the user to grant access to the specified virtual host.
conf
A regular expression matching resource names for which the user is granted configure permissions.
write
A regular expression matching resource names for which the user is granted write permissions.
read
A regular expression matching resource names for which the user is granted read permissions.
rabbitmq常用命令
add_user <UserName> <Password>
delete_user <UserName>
change_password <UserName> <NewPassword>
list_users
add_vhost <VHostPath>
delete_vhost <VHostPath>
list_vhostsset_permissions [-p <VHostPath>] <UserName> <Regexp> <Regexp> <Regexp>
clear_permissions [-p <VHostPath>] <UserName>
list_permissions [-p <VHostPath>]
list_user_permissions <UserName>
list_queues [-p <VHostPath>] [<QueueInfoItem> ...]
list_exchanges [-p <VHostPath>] [<ExchangeInfoItem> ...]
list_bindings [-p <VHostPath>]
list_connections [<ConnectionInfoItem> ...]
2.python代码
先来一段简单的代码实现
producter端
#!/usr/bin/env python
import pika