安装Spark集群(在CentOS上)

环境:CentOS 6.4, Hadoop 1.1.2, JDK 1.7, Spark 0.7.2, Scala 2.9.3

折腾了几天,终于把Spark 集群安装成功了,其实比hadoop要简单很多,由于网上搜索到的博客大部分都还停留在需要依赖mesos的版本,走了不少弯路。

1. 安装 JDK 1.7 yum search openjdk-devel sudo yum install Java-1.7.0-openjdk-devel.x86_64 /usr/sbin/alternatives --config java /usr/sbin/alternatives --config javac sudo vim /etc/profile # add the following lines at the end export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.19.x86_64 export JRE_HOME=$JAVA_HOME/jre export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar # save and exit vim # make the bash profile take effect immediately $ source /etc/profile # test $ java -version

参考我的另一篇博客,安装和配置CentOS服务器的详细步骤

2. 安装 Scala 2.9.3

Spark 0.7.2 依赖 Scala 2.9.3, 我们必须要安装Scala 2.9.3.

下载 scala-2.9.3.tgz 并 保存到home目录.

$ tar -zxf scala-2.9.3.tgz $ sudo mv scala-2.9.3 /usr/lib $ sudo vim /etc/profile # add the following lines at the end export SCALA_HOME=/usr/lib/scala-2.9.3 export PATH=$PATH:$SCALA_HOME/bin # save and exit vim #make the bash profile take effect immediately source /etc/profile # test $ scala -version 3. 下载预编译好的Spark

下载预编译好的Spark, spark-0.7.2-prebuilt-hadoop1.tgz.

如果你想从零开始编译,则下载源码包,但是我不建议你这么做,因为有一个Maven仓库,twitter4j.org, 被墙了,导致编译时需要翻墙,非常麻烦。如果你有DIY精神,并能顺利翻墙,则可以试试这种方式。

4. 本地模式 4.1 解压 $ tar -zxf spark-0.7.2-prebuilt-hadoop1.tgz 4.2 设置SPARK_EXAMPLES_JAR 环境变量 $ vim ~/.bash_profile # add the following lines at the end export SPARK_EXAMPLES_JAR=$HOME/spark-0.7.2/examples/target/scala-2.9.3/spark-examples_2.9.3-0.7.2.jar # save and exit vim #make the bash profile take effect immediately $ source /etc/profile

这一步其实最关键,很不幸的是,官方文档和网上的博客,都没有提及这一点。我是偶然看到了这两篇帖子,, ,才补上了这一步,之前死活都无法运行SparkPi。

4.3 (可选)设置 SPARK_HOME环境变量,并将SPARK_HOME/bin加入PATH $ vim ~/.bash_profile # add the following lines at the end export SPARK_HOME=$HOME/spark-0.7.2 export PATH=$PATH:$SPARK_HOME/bin # save and exit vim #make the bash profile take effect immediately $ source /etc/profile 4.4 现在可以运行SparkPi了 $ cd ~/spark-0.7.2 $ ./run spark.examples.SparkPi local

接下来请看第2页精彩内容

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/b059b28d58b78961aa465dcf5f0ba7b5.html