今天就跟大家聊聊有關Mac開發(fā)中Unable to load native-hadoop library問題該怎么解決,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據(jù)這篇文章可以有所收獲。
專注于為中小企業(yè)提供成都網站設計、做網站、成都外貿網站建設公司服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)牟定免費做網站提供優(yōu)質的服務。我們立足成都,凝聚了一批互聯(lián)網行業(yè)人才,有力地推動了近1000家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網站建設實現(xiàn)規(guī)模擴充和轉變。
在使用hhbase讀取使用了snappy壓縮的hfile時,報錯如下:
java.lang.UnsatisfiedLinkError: org.apache.hadoop.util.NativeCodeLoader.buildSupportsSnappy()Z
再往上找log中還會有這樣的一行提示:
Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
分析
這個問題呢,需要我們自己編譯mac平臺的hadoop native,但是編譯了好些版本hadoop都會遇到cmake的問題:
hadoop-yarn-server-nodemanager: make failed,這個通過YARN-8622 patch可以解決
hadoop-mapreduce-client-nativetask: make failed,這個沒找到解決辦法
所以最終編譯了hadoop 2.8.5 ,hadoop 3.1.1,hadoop 3.2.1,hadoop 3.2.1都有類似的問題,有的版本第一個問題已經解決,第二個問題都會碰到,只好放棄編譯了
還好有開源,在github上熱搜索hadoop native mac,真的有人共享出來,然后替換到本機${hadoop_home}/lib/native 還有一些配置如下:
$ vim .zshrc export HADOOP_HOME=/Users/jiazz/devEnvs/hadoop-3.1.1 export HADOOP_PREFIX=/Users/jiazz/devEnvs/hadoop-3.1.1 export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin export HADOOP_OPTS="-Djava.library.path=${HADOOP_HOME}/lib/native" export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${HADOOP_HOME}/lib/native export JAVA_LIBRARY_PATH=$JAVA_LIBRARY_PATH:${HADOOP_HOME}/lib/native $ source .zshrc
是否成功其實可以通過命令檢測一下:
這里需要注意一下,mac會檢查你替換的文件來源,需要在mac電腦:設置->安全性與隱私->通用->允許打開
# 修復之前 $ hadoop checknative -a WARNING: HADOOP_PREFIX has been replaced by HADOOP_HOME. Using value of HADOOP_PREFIX. 2020-11-03 13:28:45,307 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Native library checking: hadoop: false zlib: false zstd : false snappy: false lz4: false bzip2: false openssl: false ISA-L: false # 修復之后 $ hadoop checknative -a WARNING: HADOOP_PREFIX has been replaced by HADOOP_HOME. Using value of HADOOP_PREFIX. 2020-11-03 13:28:59,672 WARN bzip2.Bzip2Factory: Failed to load/initialize native-bzip2 library system-native, will use pure-Java version 2020-11-03 13:28:59,677 INFO zlib.ZlibFactory: Successfully loaded & initialized native-zlib library 2020-11-03 13:28:59,967 WARN erasurecode.ErasureCodeNative: Loading ISA-L failed: Failed to load libisal.2.dylib (dlopen(libisal.2.dylib, 9): image not found) 2020-11-03 13:28:59,967 WARN erasurecode.ErasureCodeNative: ISA-L support is not available in your platform... using builtin-java codec where applicable Native library checking: hadoop: true /Users/jiazz/devEnvs/hadoop-3.1.1/lib/native/libhadoop.dylib zlib: true /usr/lib/libz.1.dylib zstd : true /usr/local/Cellar/zstd/1.4.5/lib/libzstd.1.4.5.dylib snappy: true /usr/local/Cellar/snappy/1.1.8/lib/libsnappy.1.1.8.dylib lz4: true revision:10301 bzip2: false openssl: false EVP_CIPHER_CTX_reset ISA-L: false Loading ISA-L failed: Failed to load libisal.2.dylib (dlopen(libisal.2.dylib, 9): image not found) 2020-11-03 13:28:59,995 INFO util.ExitUtil: Exiting with status 1: ExitException
再次在idea中運行程序,問題解決
經驗證如果是java -jar在服務器上跑還需要加參數(shù)-Djava.library.path=$HADOOP_HOME/lib/native
看完上述內容,你們對Mac開發(fā)中Unable to load native-hadoop library問題該怎么解決有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。