我让网络服务器正常工作,我的airflow-scheduler.service文件启动了调度程序,它找到了我的dags等。但是,任务没有运行:
我看到有关/ bin / sh
的错误消息ERROR - failed to execute task Command 'exec bash -c run'
我有我的sysconfig文件:
#!/bin/bash
PATH=/opt/anaconda/anaconda3/envs/airflow_env/bin/airflow
AIRFLOW_CONFIG=/mnt/var/airflow/airflow.cfg
AIRFLOW_HOME=/mnt/var/airflow
我的airflow-scheduler.service文件:
#!/bin/bash
[Unit]
Description=Airflow scheduler daemon
After=network.target postgresql.service
Wants=postgresql.service
[Service]
EnvironmentFile=/etc/sysconfig/airflow
User=airflow
Group=airflow
Type=simple
ExecStart=/opt/anaconda/anaconda3/envs/airflow_env/bin/airflow scheduler
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
这是记录我得到的bash错误的journalctl记录:
[2017-10-30 18:36:13,764] {base_executor.py:50} INFO - Adding to queue: airflow run user_presence_raw_etl transform_raw_user_presence 2017-10-30T14:00:00 --local -sd /mnt/var/airflow/dags/bin/user_p
Oct 30 18:36:13 airflow[4742]: [2017-10-30 18:36:13,765] {jobs.py:1443} INFO - Heartbeating the executor
Oct 30 18:36:13 airflow[4742]: [2017-10-30 18:36:13,783] {local_executor.py:45} INFO - LocalWorker running airflow run user_presence_raw_etl transform_raw_user_presence 2017-10-30T14:00:00 --local -sd /mnt/var/airflow/dags/bin/us
Oct 30 18:36:13 airflow[4742]: /bin/sh: 1: exec: bash: not found
Oct 30 18:36:13 airflow[4742]: [2017-10-30 18:36:13,865] {local_executor.py:52} **ERROR - failed to execute task Command 'exec bash -c 'airflow run** user_presence_raw_etl transform_raw_user_presence 2017-10-30T14:00:00 --local -sd /mnt/var/airf
Oct 30 18:36:14 airflow[4742]: [2017-10-30 18:36:14,786] {jobs.py:1407} INFO - Heartbeating the process manager
Oct 30 18:36:14 airflow[4742]: [2017-10-30 18:36:14,786] {dag_processing.py:559} INFO - Processor for /mnt/var/airflow/dags/bin/prod/hourly_agent_dag.py finished
Oct 30 18:36:14 airflow[4742]: [2017-10-30 18:36:14,789] {dag_processing.py:627} INFO - Started a process (PID: 5425) to generate tasks for /mnt/var/airflow/dags/bin/prod/daily_agent_email_dag.py - logging into /mnt/var/airflow/l
Oct 30 18:36:14 airflow[4742]: [2017-10-30 18:36:14,831] {jobs.py:1000} INFO - No tasks to send to the executor
Oct 30 18:36:14 airflow[4742]: [2017-10-30 18:36:14,832] {jobs.py:1443} INFO - Heartbeating the executor
Oct 30 18:36:14 airflow[4742]: [2017-10-30 18:36:14,833] {jobs.py:1195} INFO - Executor reports user_presence_raw_etl.transform_raw_user_presence execution_date=2017-10-30 14:00:00 as failed
答案 0 :(得分:2)
看起来您的sysconfig文件正在破坏Oct 30 18:36:13 airflow[4742]: /bin/sh: 1: exec: bash: not found
环境变量,因此出现错误:
PATH=/opt/anaconda/anaconda3/envs/airflow_env/bin/airflow:$PATH
尝试将该行设置为以下内容:
threads[i]: Thread[Thread-2,5,main] threads[i].clientName: Bill maxClientsCount: 15 i: 0
threads[i]: Thread[Thread-2,5,main] threads[i].clientName: Bill maxClientsCount: 15 i: 0
答案 1 :(得分:0)
由LocalExecutor生成的工作进程无法运行气流,因为它在PATH
中不可用。您只需为sysconfig
配置它。在气流存储库中提供的示例中,airflow-scheduler.service他们希望气流可以为用户执行。
我的建议是为气流创建virtualenv,在那里安装气流然后为每个外壳激活它,在那里你要运行与气流有关的东西,例如:工人,调度员或网络服务器。
答案 2 :(得分:0)
看起来您将气流安装为气流以外的用户。我有一个airflow-scheduler.service
文件,指定我用来安装气流的用户,在我的例子中是mghen
。
[Unit]
Description=Airflow scheduler daemon
After=network.target postgresql.service mysql.service redis.service rabbitmq-server.service
Wants=postgresql.service mysql.service redis.service rabbitmq-server.service
[Service]
EnvironmentFile=/etc/sysconfig/airflow
User=mghen
Group=mghen
Type=simple
ExecStart=/usr/local/bin/airflow scheduler
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
我遇到了类似的问题,但没有看到同样的错误消息。无论如何,改变User
和Group
可能会有所帮助。由于您在启动气流(ExecStart=/opt/anaconda/anaconda3/envs/airflow_env/bin/airflow scheduler
)时指定了绝对路径,因此它看起来像airflow
用户一样正常,但实际上airflow
用户实际上无法运行{{1该程序因为另一个用户安装了它。 Idk如何解决airflow
我刚刚更改PATH
文件中的User
和Group
。
或者,也许您可以airflow-*.service
用户安装airflow
,因此airflow
用户的airflow
可以使用PATH
。