我有一个由docker swarm构建的火花和气流集群。气流容器不能包含我期望的火花。
我正在使用github上存在的以下图像
Spark:大数据欧洲/ docker-hadoop-spark-workbench
气流:puckel / docker-airflow(CeleryExecutor)
我准备了一个.py文件,并将其添加到dags文件夹下。
from airflow import DAG
from airflow.contrib.operators.spark_submit_operator import SparkSubmitOperator
from datetime import datetime, timedelta
args = {'owner': 'airflow', 'start_date': datetime(2018, 9, 24) }
dag = DAG('spark_example_new', default_args=args, schedule_interval="@once")
operator = SparkSubmitOperator(task_id='spark_submit_job', conn_id='spark_default', java_class='Main', application='/SimpleSpark.jar', name='airflow-spark-example',conf={'master':'spark://master:7077'},
dag=dag)
我也将连接配置为以下网站:
Master 是spark主容器的主机名。
但是找不到火花提交,它会产生以下错误:
[2018-09-24 08:48:14,063] {{logging_mixin.py:95}} INFO - [2018-09-24 08:48:14,062] {{spark_submit_hook.py:283}} INFO - Spark-Submit cmd: ['spark-submit', '--master', 'spark://master:7077', '--conf', 'master=spark://master:7077', '--name', 'airflow-spark-example', '--class', 'Main', '--queue', 'root.default', '/SimpleSpark.jar']
[2018-09-24 08:48:14,067] {{models.py:1736}} ERROR - [Errno 2] No such file or directory: 'spark-submit': 'spark-submit'
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/airflow/models.py", line 1633, in _run_raw_task
result = task_copy.execute(context=context)
File "/usr/local/lib/python3.6/site-packages/airflow/contrib/operators/spark_submit_operator.py", line 168, in execute
self._hook.submit(self._application)
File "/usr/local/lib/python3.6/site-packages/airflow/contrib/hooks/spark_submit_hook.py", line 330, in submit
**kwargs)
File "/usr/local/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/local/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'spark-submit': 'spark-submit'
答案 0 :(得分:1)
据我所知puckel/docker-airflow
使用 Python slim 图片(https://hub.docker.com/_/python/)。该映像不包含通用软件包,仅包含运行python所需的最少软件包。因此,您将需要扩展映像并在容器上安装spark-submit
。
编辑:气流确实需要容器中的火花二进制文件来运行SparkSubmitOperator
,如here所述。
您可以使用的另一种方法是使用SSHOperator
通过SSH到远程计算机上来在外部VM上运行spark-submit
命令。但是在这里,SSH也应该可用,而Puckel Airflow中没有。