所需要配置的参数:
Configuration conf =
new
Configuration();
conf.set(
"fs.defaultFS"
,
"hdfs://hadoop2cluster"
);
conf.set(
"dfs.nameservices"
,
"hadoop2cluster"
);
conf.set(
"dfs.ha.namenodes.hadoop2cluster"
,
"nn1,nn2"
);
conf.set(
"dfs.namenode.rpc-address.hadoop2cluster.nn1"
,
"10.0.1.165:8020"
);
conf.set(
"dfs.namenode.rpc-address.hadoop2cluster.nn2"
,
"10.0.1.166:8020"
);
conf.set(
"dfs.client.failover.proxy.provider.hadoop2cluster"
,
"org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider"
);
将其中的hadoop2cluster改为自己的HA的url
就可以了
时间: 2024-12-26 08:54:12