Created
March 3, 2015 22:20
-
-
Save vinothchandar/3ad542c2028c2a20e356 to your computer and use it in GitHub Desktop.
HDFS HA Name Node Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) throws Exception { | |
if (args.length != 2){ | |
System.out.println("Usage: pgm <hdfs:///path/to/copy> </local/path/to/copy/from>"); | |
System.exit(1); | |
} | |
Configuration conf = new Configuration(false); | |
conf.set("fs.defaultFS", "hdfs://nameservice1"); | |
conf.set("fs.default.name", conf.get("fs.defaultFS")); | |
conf.set("dfs.nameservices","nameservice1"); | |
conf.set("dfs.ha.namenodes.nameservice1", "namenode1,namenode2"); | |
conf.set("dfs.namenode.rpc-address.nameservice1.namenode1","hadoopnamenode01:8020"); | |
conf.set("dfs.namenode.rpc-address.nameservice1.namenode2", "hadoopnamenode02:8020"); | |
conf.set("dfs.client.failover.proxy.provider.nameservice1","org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider"); | |
FileSystem fs = FileSystem.get(URI.create(args[0]), conf); | |
Path srcPath = new Path(args[1]); | |
Path dstPath = new Path(args[0]); | |
//in case the same file exists on remote location, it will be overwritten | |
fs.copyFromLocalFile(false, true, srcPath, dstPath); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment