1、需要连接HDFS NN主机,如果连接其他DN的话,会报Connection refused
2、需使用8020端口,如果使用9000端口,会报Protocol message end-group tag did not match expected tag
3、在定义一个FileSystem变量的时候分布式和单机版的方法是不一样的,单机版使用的是FileSystem类的静态函数
FileSystem hdfs = FileSystem.get(conf)
分布式下需要使用Path来获得
Path dstDir = new Path(hdfsPath);
FileSystem hdfs = dstDir.getFileSystem(conf);
否则会报
Wrong FS: hdfs://hdfs://10.108.66.81:8020/..., expected: file:///
4、需要定义执行HDFS的用户,否则会出现Permission denied
System.setProperty("HADOOP_USER_NAME", "hdfs");
或者
UserGroupInformation.setLoginUser(UserGroupInformation.createRemoteUser("admin"));