在第一次格式化hadoop的时候,可能会出现以下错误信息:
- 14/08/10 07:07:57 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
- Stopping namenodes on [Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /home/hadoop/hadoop-2.2.0/lib/native/libhadoop.so.1.0.0 which might have disabled stack guard. The VM will try to fix the stack guard now.
- It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
- cluster1]
- sed: -e expression #1, char 6: unknown option to `s'
- -c: Unknown cipher type 'cd'
- ^Ccluster1: stopping namenode
- cluster1: stopping datanode
- VM: ssh: Could not resolve hostname VM: Name or service not known
- stack: ssh: Could not resolve hostname stack: Name or service not known
- warning:: ssh: Could not resolve hostname warning:: Name or service not known
- will: ssh: Could not resolve hostname will: Name or service not known
- which: ssh: Could not resolve hostname which: Name or service not known
- fix: ssh: Could not resolve hostname fix: Name or service not known
- disabled: ssh: Could not resolve hostname disabled: Name or service not known
- have: ssh: Could not resolve hostname have: Name or service not known
- 64-Bit: ssh: Could not resolve hostname 64-Bit: Name or service not known
- guard: ssh: Could not resolve hostname guard: Name or service not known
- HotSpot(TM): ssh: Could not resolve hostname HotSpot(TM): Name or service not known
- Java: ssh: Could not resolve hostname Java: Name or service not known
- VM: ssh: Could not resolve hostname VM: Name or service not known
- stack: ssh: Could not resolve hostname stack: Name or service not known
- The: ssh: Could not resolve hostname The: Name or service not known
- recommended: ssh: Could not resolve hostname recommended: Name or service not known
- have: ssh: Could not resolve hostname have: Name or service not known
- guard.: ssh: Could not resolve hostname guard.: Name or service not known
- Server: ssh: Could not resolve hostname Server: Name or service not known
- loaded: ssh: Could not resolve hostname loaded: Name or service not known
- It's: ssh: Could not resolve hostname It's: Name or service not known
- try: ssh: Could not resolve hostname try: Name or service not known
- the: ssh: Could not resolve hostname the: Name or service not known
- You: ssh: Could not resolve hostname You: Name or service not known
- that: ssh: Could not resolve hostname that: Name or service not known
- might: ssh: Could not resolve hostname might: Name or service not known
- you: ssh: Could not resolve hostname you: Name or service not known
- library: ssh: Could not resolve hostname library: Name or service not known
- fix: ssh: Could not resolve hostname fix: Name or service not known
- to: ssh: Could not resolve hostname to: Name or service not known
- highly: ssh: Could not resolve hostname highly: Name or service not known
- library: ssh: Could not resolve hostname library: Name or service not known
- the: ssh: Could not resolve hostname the: Name or service not known
- 'execstack: ssh: Could not resolve hostname 'execstack: Name or service not known
- '-z: ssh: Could not resolve hostname '-z: Name or service not known
- now.: ssh: Could not resolve hostname now.: Name or service not known
以上错误可以在/etc/profile加入以下配置
export HADOOP_HOME=/usr/local/hadoop
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
然后重新格式化,这时将不会提示错误信息,但是还是有警告信息。
4/08/10 07:07:57 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
为了能彻底解决这些问题,我们还需要在/etc/profile文件中添加以下环境变量
export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native
加入了该环境变量,此时如果主机的位数和hadoop库文件的位数不一致也会出现以上的错误。
可以通过uname -a 查看当前系统的信息。
Linux yitian1 2.6.32-573.8.1.el6.x86_64 #1 SMP Tue Nov 10 18:01:38 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
从以上信息可知,当前系统的linux内核是2.6.32-573.8.1.el6.x86_64,位数是64位
还有通过以下命令查看当前hadoop的库文件是多少位的
file /usr/local/hadoop/lib/native/*
/usr/local/hadoop/lib/native/libhadoop.a: current ar archive
/usr/local/hadoop/lib/native/libhadooppipes.a: current ar archive
/usr/local/hadoop/lib/native/libhadoop.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
/usr/local/hadoop/lib/native/libhadoop.so.1.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
/usr/local/hadoop/lib/native/libhadooputils.a: current ar archive
/usr/local/hadoop/lib/native/libhdfs.a: current ar archive
/usr/local/hadoop/lib/native/libhdfs.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
/usr/local/hadoop/lib/native/libhdfs.so.0.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
从以上输出信息可以看出,hadoop的版本也是64位的,如果hadoop的版本和系统的版本不一致,则必须要保证他们一致,不一致的情况下,一般是更换hadoop的核心库
注意:记得修改了/etc/profile文件之后,为了让配置立即生效,执行source /etc/profile命令