apache-spark - 如何远程使用 Spark 将数据写入配置单元表?
问题描述
我是hadoop世界的新手。我已经在我的 windows 机器上安装了 spark 2.3.1,并在同一台机器的 vm 中安装了 cloudera。我正在使用 spark shell 以数据框的形式进行一些数据转换。现在我想把这些数据放到cloudera中使用spark的hive中。我已经用谷歌搜索并执行了以下步骤。
1) 复制 /etc/hive/conf 中的所有文件并粘贴到我的 windows 中的 spark/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.
请有人帮助我。
解决方案
推荐阅读
- flutter - 有什么办法可以在下拉菜单中的项目中添加更多项目?
- c++ - 错误:未在此范围内声明“板”(C++)
- regex - 从 XML 中删除特定项目
- database - 在 Windows 10 上下载 MariaDB 列存储
- ios - 推送通知是否在 IOS 上受到限制和定价?
- python - 格式化 dask.diagnostics 进度条
- phpmailer - PHPMailer 有时无法连接到 SMTP 主机
- c# - DecryptByPassPhrase 的等效 C# 代码,反之亦然
- linux - 如何使用 sed 将 virsh xml 数据转换为 PCI BDF 格式
- unity3d - 导入到 unity 的 Blender 文件在每个轴上具有不同的缩放比例