【问题标题】:Flower fails to monitor Celery queues that are using Redis Sentinel as a broker instead of just RedisFlower 无法监控使用 Redis Sentinel 而不仅仅是 Redis 作为代理的 Celery 队列
【发布时间】:2020-08-11 12:32:33
【问题描述】:

为了提高弹性,我将独立的 Redis 部署转换为由三个 Redis 哨兵组成的集群。通过修改我的 Celery 配置以包含

,我能够将 Celery 连接到 Redis Sentinel 设置
BROKER_URL = 'sentinel://10.1.1.1:26379/0;sentinel://10.1.1.2:26379/0;sentinel://10.1.1.3:26379/0'

BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 32400, 'master_name': 'mymaster'}

让 Celery 连接的关键是添加 BROKER_TRANSPORT_OPTIONS 并定义我的 redis 配置中设置的 master_name。

我还使用 Flower 来监控我的 Celery 队列,方法如下:

celery flower --basic_auth=user1:pass123 --port=5555 --broker=redis://localhost:6379/0

但是现在我有一个 Redis Sentinel 部署,我想我需要一种方法来传递传输选项,以便它成功连接,否则如果我这样做:

celery flower --basic_auth=user1:pass123 --port=5555 -b 'sentinel://10.1.1.1:26379/0;sentinel://10.1.1.2:26379/0;sentinel://10.1.1.3:26379/0' --debug

它只是挂起:

    [I 200427 13:01:36 command:139] Visit me at http://localhost:5555
[I 200427 13:01:36 command:144] Broker: sentinel://10.1.1.1:26379/0
[I 200427 13:01:36 command:147] Registered tasks:
    [u'celery.accumulate',
     u'celery.backend_cleanup',
     u'celery.chain',
     u'celery.chord',
     u'celery.chord_unlock',
     u'celery.chunks',
     u'celery.group',
     u'celery.map',
     u'celery.starmap']
[D 200427 13:01:36 command:149] Settings: {'cookie_secret': 'W0UNu/+hQLCUYD2smFhIBMo9nrJqn0ZimgrxxroGeSI=',
     'debug': True,
     'login_url': '/login',
     'static_path': '/usr/local/lib/python2.7/dist-packages/flower/static',
     'static_url_prefix': '/static/',
     'template_path': '/usr/local/lib/python2.7/dist-packages/flower/templates'}
[D 200427 13:01:36 control:29] Updating all worker's cache...

我知道 BROKER_TRANSPORT_OPTIONS 是芹菜概念而不是花,我尝试使用 --conf 选项通过 TRANSPORT config 传递配置,但它似乎没有接受它。

对此的任何帮助将不胜感激。我搜索了 celery 和 Flower 文档,看看我如何在没有运气的情况下解决这个问题。

【问题讨论】:

    标签: python redis celery redis-sentinel flower


    【解决方案1】:

    我通过从启动 celery 和花的 Django 目录运行花解决了这个问题,然后我可以在花命令行中使用 -A :

    芹菜花 --basic_auth=user1:pass123 --port=5555 -b 'sentinel://10.1.1.1:26379/0;sentinel://10.1.1.2:26379/0;sentinel://10.1。 1.3:26379/0' --debug -A myappname

    一旦我这样做了,Flower 就可以连接到我的哨兵,我可以看到我的任务和队列。

    【讨论】:

    • 但是,你传递了主人的名字吗?
    • 它在 BROKER_TRANSPORT_OPTIONS 中定义的配置中
    猜你喜欢
    • 2020-06-08
    • 1970-01-01
    • 1970-01-01
    • 2022-01-11
    • 2022-12-14
    • 1970-01-01
    • 2018-11-04
    • 2016-04-05
    • 2020-01-12
    相关资源
    最近更新 更多