一、启动Spark
1、standalone模式
方法一:
(1)启动主节点
./sbin/start-master.sh
访问http://127.0.0.1:8080,得到如下页面
注意标记到的链接就是spark master节点的链接master-spark-URL
(2)启动从节点
./sbin/start-slave.sh <master-spark-URL>
再次访问http://127.0.0.1:8080,得到如下页面
可以看到,从节点启动
方法二:
(1)设置SSH,本地免密码登录
cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys
(2)配置Spark slave
cp ./conf/slaves.template ./conf/slaves
(3)启动Spark伪分布式
<SPARK_HOME>/sbin/start-all.sh
(4)执行jps验证Spark启动成功
6407 Worker
6423 Jps
6361 Master
二、在IDEA中写一个简单的Spark程序
报错
Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps;
at org.apache.spark.util.Utils$.getCallSite(Utils.scala:1406)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:76)
at base.SimpleApp$.main(SimpleApp.scala:13)
at base.SimpleApp.main(SimpleApp.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Process finished with exit code 1
没有按照文档里面的Scala版本号下载对应的Scala,Spark 2.1.0对应下载的版本是Scala 2.11.7
参考
1.spark官方文档:Spark Standalone Mode
2.Spark本地开发环境搭建:链接