我正在尝试通过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
存储库中,并允许.sh
和.jar
文件可以用chmod +x file.sh
执行
我也尝试了一些答案here,但相同的情况下气流无法识别.jar路径目录。
答案 0 :(得分:0)
我也遇到过同样的问题。
需要安装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)