Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://sparkcluster");

conf.set("dfs.nameservices", "sparkcluster");

conf.set("dfs.ha.namenodes.sparkcluster", "nn1,nn2");

conf.set("dfs.namenode.rpc-address.sparkcluster.nn1", "tuxedo:8020");

conf.set("dfs.namenode.rpc-address.sparkcluster.nn2", "ecup-mgr:8020");

conf.set("dfs.client.failover.proxy.provider.sparkcluster", "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider");
// conf.set("fs.defaultFS", "hdfs://tuxedo");
/**
* 参数优先级: 1、客户端代码中设置的值 2、classpath下的用户自定义配置文件 3、然后是服务器的默认配置
*/
// conf.set("dfs.replication", "3");

// 获取一个hdfs的访问客户端,根据参数,这个实例应该是DistributedFileSystem的实例
fs = FileSystem.get(conf);

相关文章:

  • 2022-01-28
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2021-07-24
  • 2021-12-15
  • 2021-10-21
  • 2021-04-06
猜你喜欢
  • 2022-12-23
  • 2021-10-10
  • 2021-12-15
  • 2021-11-29
  • 2021-10-14
相关资源
相似解决方案