spark-snappy库不可用

klr1opcd  于 2021-06-02  发布在  Hadoop
关注(0)|答案(1)|浏览(390)

我正在试图保存一个mllib模型。
我在spark中运行的代码:

model = RandomForest.trainClassifier(train_data, 
                                 numClasses=2, categoricalFeaturesInfo=categoricalFeaturesInfo,
                                 numTrees=numTrees, featureSubsetStrategy="auto",
                                 impurity=impurity, maxDepth=maxDepth, maxBins=maxBins)

model.save(sc, "file:///path/to/models/model_name")

错误消息是:

native snappy library not available: 
this version of libhadoop was built without snappy support

spark的信息

spark版本:
1.6.1
启动spark的代码:

pyspark --packages com.databricks:spark-csv_2.11:1.5.0 --master "local[8]" --driver-memory 6G --executor-memory 6G --jars /usr/local/path/to/hadoop/lib/snappy-java-1.0.4.1.jar

环境变量(spark_env.sh):

HADOOP_HOME=/usr/local/path/to/hadoop 
SPARK_HOME=/usr/local/path/to/spark
HADOOP_CONF_DIR=/usr/local/path/to/hadoop/etc/hadoop
SPARK_CONF_DIR=/usr/local/path/to/spark/conf
HADOOP_LZO_DIR=/usr/local/path/to/hadoop/lib
HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/local/path/to/spark/*:/usr/local/path/to/spark/lib/*:/usr/local/path/to/hadoop/lib/*:/usr/local/path/to/hadoop/lib/native/*
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/path/to/hadoop/lib/native
SPARK_CLASSPATH=$SPARK_CLASSPATH:/usr/local/path/to/hadoop/lib/native/*:/usr/local/path/to/hadoop/lib/snappy-java-1.0.4.1.jar:/usr.local/path/to/spark/lib/*:$CLASSPATH

我特意加了一句 /usr/local/path/to/hadoop/lib/snappy-java-1.0.4.1.jar 在spark\u类路径中没有结果。

zphenhs4

zphenhs41#

接下来的步骤帮助我解决了类似的问题:
从下载hadoop库https://hadoop.apache.org/releases.html,本地解包并设置 spark.driver.extraLibraryPath$HADOOP_PATH/lib/native .
例子: pyspark --packages com.databricks:spark-csv_2.11:1.5.0 --master "local[8]" --conf "spark.driver.extraLibraryPath=/home/hadoop/hadoop-2.8.1/lib/native" --driver-memory 6G --executor-memory 6G --jars /usr/local/path/to/hadoop/lib/snappy-java-1.0.4.1.jar 你可以试着 spark.executor.extraLibraryPath 如果它对你不起作用的话。

相关问题