【发布时间】:2017-05-03 12:36:12
【问题描述】:
HDFS 上的根暂存目录:/tmp/hive 应该是可写的。当前权限为:rwx--------
您好,我在 CDH 5.8 的 Eclipse 中执行以下 Spark 代码并获得 RuntimeExeption 之上
public static void main(String[] args) {
final SparkConf sparkConf = new SparkConf().setMaster("local").setAppName("HiveConnector");
final JavaSparkContext sparkContext = new JavaSparkContext(sparkConf);
SQLContext sqlContext = new HiveContext(sparkContext);
DataFrame df = sqlContext.sql("SELECT * FROM test_hive_table1");
//df.show();
df.count();
}
根据异常 /tmp/hive on HDFS 应该是可写的,但是我们正在本地模式下执行 spark 作业。这意味着本地 (linux) 文件系统中的目录 /tmp/hive 没有可写权限,而不是 HDFS。
所以我执行了下面的命令来授予权限。
$ sudo chmod -R 777 /tmp/hive
现在它对我有用。
如果您在集群模式下执行 spark 作业时遇到同样的问题,您应该在 hive conf 文件夹的 hive-site.xml 文件中配置以下属性并重新启动蜂巢服务器。
<property>
<name>hive.exec.scratchdir</name>
<value>/tmp/hive</value>
<description>Scratch space for Hive jobs</description>
</property>
<property>
<name>hive.scratch.dir.permission</name>
<value>777</value>
<description>The permission for the user-specific scratch directories that get created in the root scratch directory </description>
</property>
【问题讨论】:
-
你遇到了异常,你修复了它。那么这里的问题是什么?我的意思是你想在这里问什么问题?
标签: apache-spark hive apache-spark-sql spark-dataframe hiveql