1 拷贝HA中core.xml和hdfs.xml文件到工程src下
2 java代码,其中ns1是nameservice名称
public class HDFSHATest { public static void main(String[] args) throws Exception { Configuration conf = new Configuration() ; FileSystem fs = FileSystem.get( new URI("hdfs://ns1"),conf,"hadoop") ; fs.copyFromLocalFile( new Path("e://1.txt"), new Path("hdfs://ns1/")); } }