【发布时间】: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