hdfs上的root scratch dir:/tmp/hive应该是可写的当前权限为:rwx

ymdaylpp  于 2021-06-28  发布在  Hive
关注(0)|答案(2)|浏览(454)

(在linux上)

vfhzx4xs

vfhzx4xs1#

使用适当的64位winutils并设置权限
winutils.exe chmod-r 777\tmp\hive

  1. System.setProperty("hadoop.home.dir", "C:\\Users\\Hadoop_home")
  2. lazy val spark: SparkSession = {
  3. FileUtils.deleteDirectory(new File("c:\\tmp\\metastore_db"))
  4. FileUtils.deleteDirectory(new File("c:\\tmp\\spark-warehouse"))
  5. SparkSession.builder().config("spark.sql.warehouse.dir", "C:\\temp\\").master("local").appName("spark session for testing").enableHiveSupport().getOrCreate()
  6. }
yc0p9oo0

yc0p9oo02#

hdfs上的root scratch dir:/tmp/hive应该是可写的。当前权限为:rwx--------
嗨,下面是我在cdh5.8的eclipse中执行的spark代码&runtimeexeption之上的代码

  1. public static void main(String[] args) {
  2. final SparkConf sparkConf = new SparkConf().setMaster("local").setAppName("HiveConnector");
  3. final JavaSparkContext sparkContext = new JavaSparkContext(sparkConf);
  4. SQLContext sqlContext = new HiveContext(sparkContext);
  5. DataFrame df = sqlContext.sql("SELECT * FROM test_hive_table1");
  6. //df.show();
  7. df.count();
  8. }

根据异常,hdfs上的/tmp/hive应该是可写的,但是我们在本地模式下执行spark作业。这意味着在本地(linux)文件系统中没有对目录/tmp/hive的可写权限,而不是hdfs。
所以我执行了下面的命令给予了许可。

  1. $ sudo chmod -R 777 /tmp/hive

现在它对我有用。
如果在集群模式下执行spark作业时遇到相同的问题,则应在hive conf文件夹的hive-site.xml文件中配置以下属性,然后重新启动hive服务器。

  1. <property>
  2. <name>hive.exec.scratchdir</name>
  3. <value>/tmp/hive</value>
  4. <description>Scratch space for Hive jobs</description>
  5. </property>
  6. <property>
  7. <name>hive.scratch.dir.permission</name>
  8. <value>777</value>
  9. <description>The permission for the user-specific scratch directories that get created in the root scratch directory </description>
  10. </property>
展开查看全部

相关问题