hadoop格式化(或者启动hadoop)的时候出现名称和服务不识别错误

在第一次格式化hadoop的时候,可能会出现以下错误信息:

  1. 14/08/10 07:07:57 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable  
  2. 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.  
  3. It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.  
  4. cluster1]  
  5. sed: -e expression #1, char 6: unknown option to `s'  
  6. -c: Unknown cipher type 'cd'  
  7. ^Ccluster1: stopping namenode  
  8. cluster1: stopping datanode  
  9. VM: ssh: Could not resolve hostname VM: Name or service not known  
  10. stack: ssh: Could not resolve hostname stack: Name or service not known  
  11. warning:: ssh: Could not resolve hostname warning:: Name or service not known  
  12. will: ssh: Could not resolve hostname will: Name or service not known  
  13. which: ssh: Could not resolve hostname which: Name or service not known  
  14. fix: ssh: Could not resolve hostname fix: Name or service not known  
  15. disabled: ssh: Could not resolve hostname disabled: Name or service not known  
  16. have: ssh: Could not resolve hostname have: Name or service not known  
  17. 64-Bit: ssh: Could not resolve hostname 64-Bit: Name or service not known  
  18. guard: ssh: Could not resolve hostname guard: Name or service not known  
  19. HotSpot(TM): ssh: Could not resolve hostname HotSpot(TM): Name or service not known  
  20. Java: ssh: Could not resolve hostname Java: Name or service not known  
  21. VM: ssh: Could not resolve hostname VM: Name or service not known  
  22. stack: ssh: Could not resolve hostname stack: Name or service not known  
  23. The: ssh: Could not resolve hostname The: Name or service not known  
  24. recommended: ssh: Could not resolve hostname recommended: Name or service not known  
  25. have: ssh: Could not resolve hostname have: Name or service not known  
  26. guard.: ssh: Could not resolve hostname guard.: Name or service not known  
  27. Server: ssh: Could not resolve hostname Server: Name or service not known  
  28. loaded: ssh: Could not resolve hostname loaded: Name or service not known  
  29. It's: ssh: Could not resolve hostname It's: Name or service not known  
  30. try: ssh: Could not resolve hostname try: Name or service not known  
  31. the: ssh: Could not resolve hostname the: Name or service not known  
  32. You: ssh: Could not resolve hostname You: Name or service not known  
  33. that: ssh: Could not resolve hostname that: Name or service not known  
  34. might: ssh: Could not resolve hostname might: Name or service not known  
  35. you: ssh: Could not resolve hostname you: Name or service not known  
  36. library: ssh: Could not resolve hostname library: Name or service not known  
  37. fix: ssh: Could not resolve hostname fix: Name or service not known  
  38. to: ssh: Could not resolve hostname to: Name or service not known  
  39. highly: ssh: Could not resolve hostname highly: Name or service not known  
  40. library: ssh: Could not resolve hostname library: Name or service not known  
  41. the: ssh: Could not resolve hostname the: Name or service not known  
  42. 'execstack: ssh: Could not resolve hostname 'execstack: Name or service not known  
  43. '-z: ssh: Could not resolve hostname '-z: Name or service not known  
  44. 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命令




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值