Celery:无法使用新用户名连接远程工作人员

时间:2014-01-12 06:19:47

标签: rabbitmq celery django-celery

我是第一次将远程工作人员连接到我的Celery服务器(Django)。在我的服务器上,我为用户创建了一个新的用户名和密码,并设置了权限:

# rabbitmqctl add_user adcelery pwd
# rabbitmqctl set_permissions adcelery "^adcelery-.*" ".*" ".*"
# rabbitmqctl list_users
Listing users ...
guest   [administrator]
adcelery    []
...done.
# /etc/init.d/rabbitmq-server restart
# /etc/init.d/celeryd restart

我的远程工作人员的网址:

BROKER_URL = "amqp://adcelery:pwd@mydomain.com/"

我在远程工作者的启动时收到以下错误。当我在上面的BROKER_URL中设置“guest:guest”作为我的登录时,它连接完全正常。我确定我错过了一两步,有什么建议吗?

[2014-01-12 11:31:26,188: INFO/MainProcess] Connected to amqp://adcelery@awaaz.de:5672//
[2014-01-12 11:31:26,391: ERROR/MainProcess] Unrecoverable error: AccessRefused(403, u"ACCESS_REFUSED - access to exchange 'celeryev' in vhost '/' refused f
or user 'adcelery'", (40, 10), 'Exchange.declare')
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/celery/worker/__init__.py", line 206, in start
    self.blueprint.start(self)
  File "/usr/local/lib/python2.7/dist-packages/celery/bootsteps.py", line 123, in start
    step.start(parent)
  File "/usr/local/lib/python2.7/dist-packages/celery/bootsteps.py", line 373, in start
    return self.obj.start()
  File "/usr/local/lib/python2.7/dist-packages/celery/worker/consumer.py", line 270, in start
    blueprint.start(self)
  File "/usr/local/lib/python2.7/dist-packages/celery/bootsteps.py", line 123, in start
    step.start(parent)
  File "/usr/local/lib/python2.7/dist-packages/celery/worker/consumer.py", line 498, in start
    enabled=self.send_events, groups=self.groups,
  File "/usr/local/lib/python2.7/dist-packages/celery/events/__init__.py", line 150, in __init__
    self.enable()
  File "/usr/local/lib/python2.7/dist-packages/celery/events/__init__.py", line 169, in enable
    serializer=self.serializer)
  File "/usr/local/lib/python2.7/dist-packages/kombu/messaging.py", line 82, in __init__
    self.revive(self._channel)
  File "/usr/local/lib/python2.7/dist-packages/kombu/messaging.py", line 216, in revive
    self.declare()
  File "/usr/local/lib/python2.7/dist-packages/kombu/messaging.py", line 102, in declare
    self.exchange.declare()
  File "/usr/local/lib/python2.7/dist-packages/kombu/entity.py", line 166, in declare
    nowait=nowait, passive=passive,
  File "/usr/local/lib/python2.7/dist-packages/amqp/channel.py", line 612, in exchange_declare
    (40, 11),  # Channel.exchange_declare_ok
  File "/usr/local/lib/python2.7/dist-packages/amqp/abstract_channel.py", line 75, in wait
    return self.dispatch_method(method_sig, args, content)
  File "/usr/local/lib/python2.7/dist-packages/amqp/abstract_channel.py", line 93, in dispatch_method
   return amqp_method(self, args)
  File "/usr/local/lib/python2.7/dist-packages/amqp/channel.py", line 232, in _close
    reply_code, reply_text, (class_id, method_id), ChannelError,
AccessRefused: Exchange.declare: (403) ACCESS_REFUSED - access to exchange 'celeryev' in vhost '/' refused for user 'adcelery'

1 个答案:

答案 0 :(得分:5)

刚刚找到答案in the docs。需要将用户添加到vhost:

rabbitmqctl set_permissions -p / adcelery ".*" ".*" ".*"