
# Spark对接OBS
#### 概述
Apache Spark是专为大规模数据处理而设计的快速通用的计算引擎。
#### 前提条件
已安装Hadoop，具体请参见[Hadoop对接OBS](https://support.huaweicloud.com/bestpractice-obs/obs_05_1507.html)。
#### 注意事项
为了减少日志输出，在/opt/spark-2.3.3/conf/log4j.properties文件中增加配置：
```
log4j.logger.com.obs= ERROR
```
#### 对接步骤
以Spark2.3.3为例。
1. 下载spark-2.3.3-bin-without-hadoop.tgz，并解压到/opt/spark-2.3.3。
2. 在/etc/profile文件中增加配置内容： 
   ```
   export SPARK_HOME=/opt/spark-2.3.3
   export PATH=$SPARK_HOME/bin:$SPARK_HOME/sbin:$PATH
   ```
   
   
3. 配置spark。 
   1. 重命名/opt/spark-2.3.3/conf/spark-env.sh.template为spark-env.sh并增加配置：
      ```
      export SPARK_DIST_CLASSPATH=$(hadoop classpath)
      ```
      更多配置内容请参见[++Apache Hadoop++](https://spark.apache.org/docs/latest/hadoop-provided.html#apache-hadoop)。
      
   
   2. 重命名/opt/spark-2.3.3/conf/log4j.properties.template为log4j.properties。
   
   
   
   
4. 执行以下命令，验证是否对接成功。 
   **$SPARK_HOME/bin/run-example org.apache.spark.examples.JavaWordCount obs://obs-bucket/input/test.txt**
   
   
 
