赞
踩
rabbitMQ登录报错user can only log in via localhost
RabbitMQ默认只有一个guest帐号,guest帐号只能在RabbitMQ安装服务器上登录,在其它服务器用guest登录提示User can only log in via localhost。
进入容器admin
这个情况的最佳解决办法是添加一个新的帐号
容器模式: sudo docker exec -it rabbitmq-server bash
#第一步:添加 admin 用户并设置密码
rabbitmqctl add_user admin 123456
#第二步:添加 admin 用户为administrator角色
rabbitmqctl set_user_tags admin administrator
#第三步:设置 admin 用户的权限,指定允许访问的vhost以及write/read
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
#第四步:查看vhost(/)允许哪些用户访问
rabbitmqctl list_permissions -p /
#第五步:查看用户列表
rabbitmqctl list_users
#第六步:配置允许远程访问的用户,rabbitmq的guest用户默认不允许远程主机访问。
输出结果
chaoyue@chaoyue-dt3000f4:/data/wms-data/app$ sudo docker exec -it rabbitmq-server bash
I have no name!@4da15e88ac02:/$ rabbitmqctl add_user admin luckserver
Adding user "admin" ...
Done. Don't forget to grant the user permissions to some virtual hosts! See 'rabbitmqctl help set_permissions' to learn more.
I have no name!@4da15e88ac02:/$ rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...
I have no name!@4da15e88ac02:/$ rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
Setting permissions for user "admin" in vhost "/" ...
I have no name!@4da15e88ac02:/$ rabbitmqctl list_permissions -p /
Listing permissions for vhost "/" ...
user configure write read
guest .* .* .*
admin .* .* .*
I have no name!@4da15e88ac02:/$
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。