【发布时间】:2018-09-26 04:00:45
【问题描述】:
我刚刚用 celery executor 设置了气流,这是我的 DAG 的骨架
dag = DAG('dummy_for_testing', default_args=default_args)
t1 = BashOperator(
task_id='print_date',
bash_command='date >> /tmp/dag_output.log',
queue='test_queue',
dag=dag)
t3 = BashOperator(
task_id='print_host',
bash_command='hostname >> /tmp/dag_output.log',
queue='local_queue',
dag=dag)
t2 = BashOperator(
task_id='print_uptime',
bash_command='uptime >> /tmp/dag_output.log',
queue='local_queue',
dag=dag)
t2.set_upstream(t3)
t2.set_upstream(t1)
我有 2 名工人。其中一个只运行一个名为local_queue 的队列,另一个运行两个名为local_queue,test_queue 的队列
我只想在 1 台机器上运行任务 1,但在两台机器上运行任务 2 和 3。即在仅运行 local_queue 的 worker 1 上,t2 和 t3 应该运行,而在同时运行 local_queue 和 test_queue 的 worker 2 上,所有 3(t1、t2 和 t3)都应该运行。 任务运行总数应为 5。
但是,当我运行它时,只运行了 3 个任务。 1) print_date 为工人 2 运行(这是正确的) 2) print_host 只为工人 1 运行(不正确。应该为两个工人运行)和 3) print_uptime 只为工人 2 运行(也不正确。应该为两个工人运行)
您能否指导我如何设置它以便运行 5 个任务。在生产中,我想通过将机器分组到队列中来管理机器,并且对于所有具有 QUEUE_A -> 执行 X 的机器和所有具有 QUEUE_B -> 执行 Y 的机器等。
谢谢
【问题讨论】:
标签: celery airflow celery-task airflow-scheduler