【问题标题】:Airflow : Bash command failed气流:Bash 命令失败
【发布时间】:2019-05-03 15:44:08
【问题描述】:

我正在尝试通过 Airlfow 运行 .jar DAG 我有一个.sh 文件,它调用了执行相关jar 所需的所有库,但我仍然面临BashOperator 的相同错误,这是.py 文件的内容:

from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime


import os
import sys

create_command  = "/home/user/Images/Job senority new colecttion /Skill/Skill_run.sh "

default_args = {
    'owner': 'me',
    'depends_on_past': False,
    'start_date': datetime(2019, 5, 03),
    'email_on_failure': False,
    'email_on_success': False,
    'provide_context': True
}
dag = DAG(dag_id='Skill_batch', default_args=default_args)


t1 = BashOperator(
        task_id= 'Batch_file_sh',
        bash_command='create_command',
        dag=dag
   )

t2 = BashOperator(
        task_id='task_1',
        bash_command='echo Hello, This is my first DAG in Airflow!',
        dag=dag
    )

t3 = BashOperator(
       task_id = 'runjar',
       dag = dag,
       bash_command = 'java -cp /home/user/Images/Job senority new colecttion /Skill/skill.jar '

t2 >> t1 >> t3
 `

这是来自气流 ui 的日志:

[2019-05-08 15:33:24,523] {bash_operator.py:104} INFO - Temporary script location: /tmp/airflowtmpIghU_M/Batch_file_shPuscAS
[2019-05-08 15:33:24,523] {bash_operator.py:114} INFO - Running command: create_command
[2019-05-08 15:33:24,527] {bash_operator.py:123} INFO - Output:
[2019-05-08 15:33:24,528] {bash_operator.py:127} INFO - /tmp/airflowtmpIghU_M/Batch_file_shPuscAS: ligne 1: create_command : commande introuvable
[2019-05-08 15:33:24,528] {bash_operator.py:131} INFO - Command exited with return code 127
[2019-05-08 15:33:24,532] {__init__.py:1580} ERROR - Bash command failed
Traceback (most recent call last):
  File "/home/user/.local/lib/python2.7/site-packages/airflow/models/__init__.py", line 1441, in _run_raw_task
    result = task_copy.execute(context=context)
  File "/home/user/.local/lib/python2.7/site-packages/airflow/operators/bash_operator.py", line 135, in execute
    raise AirflowException("Bash command failed")
AirflowException: Bash command failed

我检查了 DAG 是否在 AIRFLOW_HOME/dags 存储库下,并允许使用 chmod +x file.sh 执行 .sh.jar 文件 我也尝试了一些答案here,但同样的情况气流无法识别.jar 路径目录。

【问题讨论】:

  • cmd 是特定于 Windows 的。你好像是在linux上吧?
  • 对,对不起,只是在复制代码时出错了,是的,我在 Ubuntu 16.04 和Airflow version v1.10.3 上
  • 如果仍然存在问题,请更正您的代码,因为不清楚是否已解决?
  • @bosnjak 它还没有旋转,我确实检查了代码中的错误
  • 但现在错误部分与代码无关。该错误仍然与您删除的缺少的cmd 命令有关。

标签: python bash jar sh airflow


【解决方案1】:

我也遇到了同样的问题。

需要安装java包。

首先,更新 apt 包索引:

sudo apt update

更新包索引后,安装默认的 Java OpenJDK 包:

sudo apt install default-jdk

通过运行以下将打印 Java 版本的命令来验证安装:

java -version

输出将如下所示:

openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.04.3)
OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.04.3, mixed mode, sharing)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-21
    • 2022-12-29
    • 2020-04-10
    • 2016-09-20
    • 1970-01-01
    • 1970-01-01
    • 2018-12-23
    • 2018-08-09
    相关资源
    最近更新 更多