Flink on yarn 启动报错:缺jar包(Error: A JNI error has occurred, please check your installation and try ag)

很久以前遇到的问题,突然回顾了,今天做下总结,供大家参考===============》

启动yarn模式具体报错如下:

 bin]$ ./yarn-session.sh -n 2 -s 2 -jm 1024 -tm 1024 -nm test -d
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/yarn/exceptions/YarnException
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
	at java.lang.Class.getMethod0(Class.java:3018)
	at java.lang.Class.getMethod(Class.java:1784)
	at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.yarn.exceptions.YarnException
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 7 more

这个很可能是版本的问题,我这里家里测试版本为:

**注意:**我的flink版本是1.7.2,hadoop是2.7.2,scala是2.11,要注意你的版本是否和我一致!!
缺少的包如下图:
Flink on yarn 启动报错:缺jar包(Error: A JNI error has occurred, please check your installation and try ag)_第1张图片
未补充包和补充包前后对比图(图上)

若果不一致,可以去 /hadoop-XXX/lib/native (你的hadoop目录下)把里面的jar包(软连接)拷贝到flink的lib下。

缺失包下载地址:

链接:https://pan.baidu.com/s/15DzPqgJWIa8OmFNiyfNcqg
提取码:ocne

然后yarn模式启动就没问题了:
上图:
Flink on yarn 启动报错:缺jar包(Error: A JNI error has occurred, please check your installation and try ag)_第2张图片

你可能感兴趣的:(心得体会)