public class DFSOperater {
public static void main(String args) {
// TODO Auto-generated method stub
Configuration conf = new Configuration();
try {
FileSystem fs = FileSystem.get(conf);
System.out.println(conf);
Path f = new Path("/root/README.txt");
boolean isExists = fs.exists(f);
System.out.println("The file exists? [" + isExists + "]");
fs.create(f);
fs.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
HADOOP集群是HA模式
core-site.xml内容如下
fs.defaultFS
hdfs://ns1
hadoop.tmp.dir
/data/hadoop-2.6.4/tmp
ha.zookeeper.quorum
WJClinux01:2181,WJClinux02:2181,WJClinux03:2181