当前位置:   article > 正文

RabbitMQ 常见错误汇总_user can only log in via localhost

user can only log in via localhost

报错现象1

rabbitMQ登录报错user can only log in via localhost

在这里插入图片描述
RabbitMQ默认只有一个guest帐号,guest帐号只能在RabbitMQ安装服务器上登录,在其它服务器用guest登录提示User can only log in via localhost。

解决办法1:

进入容器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用户默认不允许远程主机访问。
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

输出结果

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:/$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/569212
推荐阅读
相关标签
  

闽ICP备14008679号