---
title: "[解決] Spark run on yarn (spark2-hdp-yarn-archive.tar.gz)"
author: "vincenta"
date: "2017-03-28T11:38:40Z"
tags: []
categories: ["编程语言"]
slug: "spark-run-on-yarn-spark2-hdp-yarn-archive-tar-gz"
draft: false
lastmod: "2017-03-28T11:38:40Z"
id: 2366232
url: "https://vincenta.iteye.com/blog/2366232"
---

最近在yarn 上運行spark 遇到一個奇怪的問題：

```
Diagnostics: ExitCodeException exitCode=2: 
gzip: /spare/hadoop/yarn/local/filecache/21_tmp/tmp_spark2-hdp-yarn-archive.tar.gz: unexpected end of file
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
```

 

查閲了很多資料，偶然看到以下的url 受到啓發，發現在 hdfs://xxxxx/hdp/apps/&lt;version&gt;/spark2/ 下的spark2-hdp-yarn-archive.tar.gz 有問題，並不是一個真正的gz file, 這個就是問題所在。

 

**解決方案：**

把/usr/hdp/current/spark2-client/jars 打包成spark2-hdp-yarn-archive.tar.gz, 並put 到hdp/apps/&lt;version&gt;/spark2/ 。 記得檢查權限，至少444.

 

然後使用 spark-submit  xxx --master yarn 執行，通過！

 

我使用的是hdp 2.5, spark 2.1.

 

\[參考]

https://community.hortonworks.com/articles/30096/foxing-broken-targz-and-jar-files-in-hdp-24.html