【问题标题】:What is the similar function to Distributed cache of Hadoop Distribution File system in Google File SystemGoogle File System中Hadoop分布式文件系统的分布式缓存有什么类似的功能
【发布时间】:2014-11-25 21:03:48
【问题描述】:
我在 Google Compute Engine 中部署了一个 6 节点 Hadoop 集群。
我使用的是 Google 文件系统(GFS),而不是 Hadoop 文件分发系统(HFS)。
.
所以,我想访问 GFS 中的文件,就像 HDFS 中的分布式缓存方法一样
请告诉我一种以这种方式访问文件的方法。
【问题讨论】:
标签:
hadoop
hdfs
google-compute-engine
distributed-cache
gfs
【解决方案1】:
当在 Google Compute Engine 上运行 Hadoop 并将 Hadoop 的 Google Cloud Storage 连接器作为“默认文件系统”时,GCS 连接器的处理方式与处理 HDFS 的方式完全相同,包括在 DistributedCache 中的使用。因此,要访问 Google Cloud Storage 中的文件,您可以像使用 HDFS 一样使用它,无需进行任何更改。例如,如果您在部署集群时将 GCS 连接器的 CONFIGBUCKET 设置为 foo-bucket,并且您希望将 本地 文件放在 DistributedCache 中,那么您可以:
# Copies mylib.jar into gs://foo-bucket/myapp/mylib.jar
$ bin/hadoop fs -copyFromLocal mylib.jar /myapp/mylib.jar
在你的 Hadoop 工作中:
JobConf job = new JobConf();
// Retrieves gs://foo-bucket/myapp/mylib.jar as a cached file.
DistributedCache.addFileToClassPath(new Path("/myapp/mylib.jar"), job);
如果您想访问与CONFIGBUCKET 不同的存储桶中的文件,您只需指定完整路径,使用gs:// 而不是hdfs://:
# Copies mylib.jar into gs://other-bucket/myapp/mylib.jar
$ bin/hadoop fs -copyFromLocal mylib.jar gs://other-bucket/myapp/mylib.jar
然后在 Java 中
JobConf job = new JobConf();
// Retrieves gs://other-bucket/myapp/mylib.jar as a cached file.
DistributedCache.addFileToClassPath(new Path("gs://other-bucket/myapp/mylib.jar"), job);