共计 1537 个字符,预计需要花费 4 分钟才能阅读完成。
运行 Spark 服务,需要在每个节点上部署 Spark。
可以先从主节点上将配置修改好,然后把 Spark 直接 scp 到其他目录。
关键配置
修改 conf/spark-env.sh
文件:
export Java_HOME=/usr/java/latest
export Hadoop_CONF_DIR=/opt/hadoop-2.4.1/etc/hadoop/
export SPARK_MASTER_IP=master
以上是必要的几个配置,详细的配置说明,请参见官网的 Document。
修改conf/slaves
,slave 节点配置,将 worker 节点的主机名直接添加进去即可。
启动集群
sbin/start-all.sh
jps
查看本机 java 进程,主节点应该有 Master
进程,worker 节点应该有个 Worker
进程。
WebUI 地址:http://master:8080
测试 Spark,bin/run-example SparkPi
, 正常的话,可以看到以下测试结果:
...
15/11/11 22:11:25 INFO scheduler.TaskSetManager: Finished task 0.0 in stage 0.0 (TID 0) in 4052 ms on localhost (1/2)
15/11/11 22:11:25 INFO scheduler.DAGScheduler: Stage 0 (reduce at SparkPi.scala:35) finished in 4.130 s
15/11/11 22:11:25 INFO scheduler.TaskSetManager: Finished task 1.0 in stage 0.0 (TID 1) in 69 ms on localhost (2/2)
15/11/11 22:11:25 INFO scheduler.TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool
15/11/11 22:11:25 INFO spark.SparkContext: Job finished: reduce at SparkPi.scala:35, took 4.613856515 s
Pi is roughly 3.1531
15/11/11 22:11:26 INFO handler.ContextHandler: stopped o.e.j.s.ServletContextHandler{/metrics/json,null}
15/11/11 22:11:26 INFO handler.ContextHandler: stopped o.e.j.s.ServletContextHandler{/stages/stage/kill,null}
15/11/11 22:11:26 INFO handler.ContextHandler: stopped o.e.j.s.ServletContextHandler{/,null}
15/11/11 22:11:26 INFO handler.ContextHandler: stopped o.e.j.s.ServletContextHandler{/static,null}
15/11/11 22:11:26 INFO handler.ContextHandler: stopped o.e.j.s.ServletContextHandler{/executors/json,null}
...
更多 Hadoop 相关信息见Hadoop 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=13
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-07/133355.htm
正文完
星哥玩云-微信公众号