Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7171113
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类: LINUX

2016-03-10 08:05:36

CentOS 6.4+Hadoop2.2.0 Spark伪分布式安装

[日期:2016-03-09] 来源:Linux社区  作者:sunflower_cao [字体:  ]

版本是2.2.0的稳定版本 下载地址
spark版本:spark-0.9.1-bin-hadoop2  下载地址
这里的spark有三个版本:

    For Hadoop 1 (HDP1, CDH3): find an Apache mirror or direct file download
    For CDH4: find an Apache mirror or direct file download
    For Hadoop 2 (HDP2, CDH5): find an Apache mirror or direct file download
我的hadoop版本是hadoop2.2.0的,所以下载的是for hadoop2

关于spark的介绍可以参看
Apache Spark is a fast and general engine for large-scale data processing.

spark运行时需要scala环境,这里下载最新版本的scala 

scala是一种可伸缩的语言是一种多范式的编程语言,一种类似java的编程,设计初衷是要集成面向对象编程和函数式编程的各种特性。Scala是在JVM上运行,Scala是一种纯粹的面向对象编程语言,而又无缝地结合了命令式和函数式的编程风格

ok 开始配置spark:

我是在hadoop的安装用户下面安装的,所以这里直接编辑/home/hadoop/.bashrc

[hadoop@localhost ~]$ cat .bashrc 
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions
export HADOOP_HOME=/home/hadoop/hadoop
export HBASE_HOME=/home/hadoop/hbase
export HIVE_HOME=/home/hadoop/hive
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export YARN_HOME=/etc/home/hadoop
export YARN_CONF_DIR=$HADOOP_HOME/etc/hadoop
export SCALA_HOME=/home/hadoop/scala
export SPARK_HOME=/home/hadoop/spark

export PATH=${PATH}:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HBASE_HOME/bin:$HIVE_HOME/bin:$SCALA_HOME/bin:$SPARK_HOME/bin
export CLASSPATH=$CLASSPATH:$HADOOP/lib:$HBASE_HOME/lib

1.scala安装:
将scala解压到hadoop根目录下 
ln -ls scala-2.11.0 scala#建立软链接 
lrwxrwxrwx.  1 hadoop hadoop        12 May 21 09:15 scala -> scala-2.11.0
drwxrwxr-x.  6 hadoop hadoop      4096 Apr 17 16:10 scala-2.11.0

编辑.bashrc  加入  export SCALA_HOME=/home/hadoop/scala
export PATH=${PATH}:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HBASE_HOME/bin:$HIVE_HOME/bin:$SCALA_HOME/bin:$SPARK_HOME/bin
保存 并使环境变量生效  source  .bashrc  
验证安装:
[hadoop@localhost ~]$ scala -version
Scala code runner version 2.11.0 -- Copyright 2002-2013, LAMP/EPFL
能够正常显示版本说明安装成功

2:spark配置:
tar -xzvf  spark-0.9.1-bin-hadoop2.tgz
ln -s spark-0.9.1-bin-hadoop2 spark
然后配置.bashrc  
export SPARK_HOME=/home/hadoop/spark
export PATH=${PATH}:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HBASE_HOME/bin:$HIVE_HOME/bin:$SCALA_HOME/bin:$SPARK_HOME/bin

编辑完成source .bashrc 使环境变量生效

spark-env.sh配置:
spark-env.sh是不存在的 需要从 cat spark-env.sh.template >> spark-env.sh 生成

然后编辑spark-env.sh

加入一下内容
export SCALA_HOME=/home/hadoop/scala
export JAVA_HOME=/usr/java/jdk
export SPARK_MASTER=localhost
export SPARK_LOCAL_IP=localhost
export HADOOP_HOME=/home/hadoop/hadoop
export SPARK_HOME=/home/hadoop/spark
export SPARK_LIBARY_PATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$HADOOP_HOME/lib/native
export YARN_CONF_DIR=$HADOOP_HOME/etc/hadoop

保存退出

3.启动spark
跟hadoop的目录结构相似 在spark下面的sbin里边放了启动和关闭的shell文件
-rwxrwxr-x. 1 hadoop hadoop 2504 Mar 27 13:44 slaves.sh
-rwxrwxr-x. 1 hadoop hadoop 1403 Mar 27 13:44 spark-config.sh
-rwxrwxr-x. 1 hadoop hadoop 4503 Mar 27 13:44 spark-daemon.sh
-rwxrwxr-x. 1 hadoop hadoop 1176 Mar 27 13:44 spark-daemons.sh
-rwxrwxr-x. 1 hadoop hadoop  965 Mar 27 13:44 spark-executor
-rwxrwxr-x. 1 hadoop hadoop 1263 Mar 27 13:44 start-all.sh
-rwxrwxr-x. 1 hadoop hadoop 2384 Mar 27 13:44 start-master.sh
-rwxrwxr-x. 1 hadoop hadoop 1520 Mar 27 13:44 start-slave.sh
-rwxrwxr-x. 1 hadoop hadoop 2258 Mar 27 13:44 start-slaves.sh
-rwxrwxr-x. 1 hadoop hadoop 1047 Mar 27 13:44 stop-all.sh
-rwxrwxr-x. 1 hadoop hadoop 1124 Mar 27 13:44 stop-master.sh
-rwxrwxr-x. 1 hadoop hadoop 1427 Mar 27 13:44 stop-slaves.sh
[hadoop@localhost sbin]$ pwd
/home/hadoop/spark/sbin

这里只需要运行start-all就可以了~~~
[hadoop@localhost sbin]$ ./start-all.sh 
rsync from localhost
rsync: change_dir "/home/hadoop/spark-0.9.1-bin-hadoop2/sbin/localhost" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]
starting org.apache.spark.deploy.master.Master, logging to /home/hadoop/spark/logs/spark-hadoop-org.apache.spark.deploy.master.Master-1-localhost.out
localhost: rsync from localhost
localhost: rsync: change_dir "/home/hadoop/spark-0.9.1-bin-hadoop2/localhost" failed: No such file or directory (2)
localhost: rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]
localhost: starting org.apache.spark.deploy.worker.Worker, logging to /home/hadoop/spark/logs/spark-hadoop-org.apache.spark.deploy.worker.Worker-1-localhost.out

通过jps查看启动是否成功:
[hadoop@localhost sbin]$ jps
4706 Jps
3692 DataNode
3876 SecondaryNameNode
4637 Worker
4137 NodeManager
4517 Master
4026 ResourceManager
3587 NameNode

可以看到有一个Master跟Worker进程 说明启动成功
可以通过查看spark集群状况

4 运行spark自带的程序  
首先需要进入spark下面的bin目录 :
[hadoop@localhost sbin]$ ll ../bin/
total 56
-rw-rw-r--. 1 hadoop hadoop 2601 Mar 27 13:44 compute-classpath.cmd
-rwxrwxr-x. 1 hadoop hadoop 3330 Mar 27 13:44 compute-classpath.sh
-rwxrwxr-x. 1 hadoop hadoop 2070 Mar 27 13:44 pyspark
-rw-rw-r--. 1 hadoop hadoop 1827 Mar 27 13:44 pyspark2.cmd
-rw-rw-r--. 1 hadoop hadoop 1000 Mar 27 13:44 pyspark.cmd
-rwxrwxr-x. 1 hadoop hadoop 3055 Mar 27 13:44 run-example
-rw-rw-r--. 1 hadoop hadoop 2046 Mar 27 13:44 run-example2.cmd
-rw-rw-r--. 1 hadoop hadoop 1012 Mar 27 13:44 run-example.cmd
-rwxrwxr-x. 1 hadoop hadoop 5151 Mar 27 13:44 spark-class
-rwxrwxr-x. 1 hadoop hadoop 3212 Mar 27 13:44 spark-class2.cmd
-rw-rw-r--. 1 hadoop hadoop 1010 Mar 27 13:44 spark-class.cmd
-rwxrwxr-x. 1 hadoop hadoop 3184 Mar 27 13:44 spark-shell
-rwxrwxr-x. 1 hadoop hadoop  941 Mar 27 13:44 spark-shell.cmd

run-example org.apache.spark.examples.SparkLR spark://localhost:7077

run-example org.apache.spark.examples.SparkPi spark://localhost:7077

Hadoop2.5.2 HA高可靠性集群搭建(Hadoop+Zookeeper) 

Hadoop2.7完全分布式集群搭建以及任务测试   

一步步教你Hadoop多节点集群安装配置 

更多Hadoop相关信息见 专题页面 

本文永久更新链接地址

阅读(1929) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~