Apache AirFlow:如何在远程计算机上安排它

问题描述 投票:0回答:1

我是不熟悉apache气流的人,请您帮助我了解我应该在哪里/在远程计算机上配置DAG。我正在使用celery_executor在工作程序节点上执行代码,我尚未在工作程序节点上进行任何配置,我正在使用RabitMQ作为队列服务,并且好像我已经正确配置了Airflow集群。

我的DAG文件:

"""
Code that goes along with the Airflow tutorial located at:
https://github.com/apache/airflow/blob/master/airflow/example_dags/tutorial.py
"""
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta


default_args = {
    'owner': 'Airflow',
    'depends_on_past': False,
    'start_date': datetime(2015, 6, 1),
    'email': ['[email protected]'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
    # 'queue': 'bash_queue',
    # 'pool': 'backfill',
    # 'priority_weight': 10,
    # 'end_date': datetime(2016, 1, 1),
}

dag = DAG('sample_date_print', schedule_interval='*/1 * * * *', default_args=default_args)

# t1, t2 and t3 are examples of tasks created by instantiating operators
t1 = BashOperator(
    task_id='print_date',
    bash_command='date',
    dag=dag)

t2 = BashOperator(
    task_id='sleep',
    bash_command='sleep 5',
    retries=3,
    dag=dag)

templated_command = """
    {% for i in range(5) %}
        echo "{{ ds }}"
        echo "{{ macros.ds_add(ds, 7)}}"
        echo "{{ params.my_param }}"
    {% endfor %}
"""

t3 = BashOperator(
    task_id='templated',
    bash_command=templated_command,
    params={'my_param': 'Parameter I passed in'},
    dag=dag)

t2.set_upstream(t1)
t3.set_upstream(t1)

日志:

{
  "host_name": "1f176162bc5e",
  "full_command": "['/usr/local/bin/airflow', 'tasks', 'run', 'sample_date_print', 'print_date', '2015-06-04T00:00:00+00:00', '--local', '--pool', 'default_pool', '-sd', '/root/airflow/dags/sample_date_print.py']"
}

我不确定如何以DAG文件的方式更改--local的默认行为去在远程机器上执行,请帮助我

airflow airflow-scheduler
1个回答
0
投票

您是否已将executor = SequentialExecutor中的executor = CeleryExecutor更改为airflow.cfg?我认为您还没有,或者如果您忘了提及它。如果要更改执行模式,这是第一件事。您可能会忘记的其他配置信息可能是herehere

© www.soinside.com 2019 - 2024. All rights reserved.