我的Java代码是实现一个简单的写文件如下:
public class FSWriteSample {
public static void main(String[] args) throws IOException {
Path path = new Path("writeSample.txt");// create new path
Configuration conf = new Configuration();// setting configuration
FileSystem fs = FileSystem.get(conf);
FSDataOutputStream fsout = fs.create(path);
byte[] buff = "Hello World".getBytes();
fsout.write(buff);
IOUtils.closeStream(fsout);
}
}
我打jar包后在hadoop中,hadoop jar 启动会提示WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable如何解决?
还有我想问一下,用这种方式创建的文件和直接再linux下vim方式写一个文件的有什么区别?
加上
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/work/tools/java/hadoop-client/hadoop/lib/native/Linux-amd64-64/
环境变量的问题,如果你是在IDE下写的,因为在配置的时候IDE都配置好了对应的路径,如果你想要用vim自己写的话,需要指定很多配置,可以参考这篇文章
这个没错,WARN 而已。。
如果你写的文件比较大1G(假设大于64M),它会被切分为好几块(1024M/64)每个块默认下会复制3块出来存储在不同的机器上(存储策略网上很多资料)等等