我是hadoop世界的新手 . 我已经在我的Windows机器上安装了spark 2.3.1并在同一台机器中的vm中安装了cloudera . 我正在使用spark shell以数据帧的形式进行一些数据转换 . 现在我想把这些数据放到使用spark的cloudera中的hive . 我有谷歌并做了以下步骤 .

1)复制/ ect / hive / conf中的所有文件并粘贴到我的windows中的saprk / conf中 .

2)在windows spark / conf中打开“hive-site.xml”并更改属性如下 .

<configuration>
  <property>
    <name>hive.metastore.uris</name>
    <value>thrift://MyclouderaIP:9083</value>
  </property>
  <property>

3)将主机条目放在窗口系统C:\ Windows \ System32 \ drivers \ etc \ hosts中

示例:MyclouderaIP quickstart.cloudera

4)在cloudera vm中打开“/etc/hive/conf/hdfs-site.xml”并更改属性,如下所示

<property>
    <name>dfs.client.use.datanode.hostname</name>
    <value>true</value>
  </property>

完成所有步骤后,我面临以下问题 .

scala> val Main = sc.textFile("D:\\Windows\\CompanyData.txt")

scala> Main.collect

错误:

java.lang.IllegalArgumentException: Pathname /D:/Windows/CompanyData.txt from hdfs://quickstart.cloudera:8020/D:/Windows/CompanyData.txt is not a valid DFS filename.
  at org.apache.hadoop.hdfs.DistributedFileSystem.getPathName(DistributedFileSystem.java:197)
  at org.apache.hadoop.hdfs.DistributedFileSystem.access$000(DistributedFileSystem.java:106)
  at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFileSystem.java:1305)
  at org.apache.hadoop.hdfs.DistributedFileSystem$22.doCall(DistributedFileSystem.java:1301)
  at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
  at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:1317)

我已经从spark / conf中删除了“core-site.xml”,它可以在windows中读取文本文件 . 但是,在插入记录时,saprk无法与cloudera通信 .

scala> import org.apache.spark.sql.hive.HiveContext
scala> val sqlContext = new org.apache.spark.sql.hive.HiveContext(sc)
scala> sqlContext.sql("insert into TestTable select 1")

错误:

org.apache.hadoop.ipc.RemoteException(java.io.IOException): 
File /user/hive/warehouse/TestTable/.hive-staging_hive_2018-10-17_00-03-48_369_2112774544260501723-1/-ext-10000/_temporary/0/_temporary/attempt_20181017000351_0000_m_000000_0/part-00000-8fcba81b-8a51-48a6-9c47-ac5f1c9dafdb-c000 
could only be replicated to 0 nodes instead of minReplication (=1).  
There are 1 datanode(s) running and 1 node(s) are excluded in this operation.

请有人帮助我 .