我创建vhost:
rabbitmqctl add_vhost test
然后用户:
rabbitmqctl add_user user 123456
然后我获得该用户的权限:
rabbitmqctl set_permissions -p test user "test" "test" "test"
我在任务中使用芹菜.py:
app = Celery('tasks', broker='amqp://user:123456@localhost/test', backend='amqp://user:123456@localhost/test')
然后我运行:
celery -A tasks worker --loglevel=info
我有错误:
amqp.exceptions.AccessRefused: Exchange.declare: (403) ACCESS_REFUSED - access to exchange 'celeryev' in vhost 'test' refused for user 'user'
如何解决?
在此处查看set_permissions:https://www.rabbitmq.com/rabbitmqctl.8.html#Access_control
当您调用set_permissions时,您正在传递";测试";对于配置、读取和写入,因此您的用户将只能使用名为"的队列/交换;测试";
此外,还可以查看此链接:https://www.rabbitmq.com/access-control.html
如果您仍然有错误,请检查您是否有正确的双引号(发生在我身上)
".*"
而不是
“.*”
可以肯定的是,在你的vhostpath(默认/)中列出用户的权限
rabbitmqctl list_permissions -p /
Lexsoul提到的双引号可能是错误的类型,例如:
sudo rabbitmqctl list_permissions -p EDO_DEVELOPING
*Listing permissions in vhost "EDO_DEVELOPING" ...
billing “.*” “.*” “.*”
不起作用,所以我尝试了:
sudo rabbitmqctl clear_permissions -p EDO_DEVELOPING billing
Clearing permissions for user "billing" in vhost "EDO_DEVELOPING" ...
sudo rabbitmqctl set_permissions -p EDO_DEVELOPING billing ".*" ".*" ".*"
Setting permissions for user "billing" in vhost "EDO_DEVELOPING" ...
然后
sudo rabbitmqctl list_permissions -p EDO_DEVELOPING
Listing permissions in vhost "EDO_DEVELOPING" ...
billing .* .* .*
并且为我工作。
我再次确认了之前关于拨款的详细信息。
问题:导致通道异常access_refused:访问exchange"reply.celebox.pidbox"
解决方案:rabbitmqctl clear_permissions-p环境用户名rabbitmqctl set_permissions-p environment skberge".".".*"