历史日志服务器与Master HA

1.配置historyServer
临时配置,对本次提交的应用程序起作用
./spark-shell --master spark://node1:7077
–name myapp1
–conf spark.eventLog.enabled=true
–conf spark.eventLog.dir=hdfs://node1:9000/spark/test
停止程序,在Web Ui中Completed Applications对应的ApplicationID中能查看history。
spark-default.conf配置文件中配置HistoryServer,对所有提交的Application都起作用
在客户端节点,进入…/spark-1.6.0/conf/ spark-defaults.conf最后加入:
//开启记录事件日志的功能
spark.eventLog.enabled true
//设置事件日志存储的目录
spark.eventLog.dir hdfs://node1:9000/spark/test
//设置HistoryServer加载事件日志的位置
spark.history.fs.logDirectory hdfs://node1:9000/spark/test
//日志优化选项,压缩日志
spark.eventLog.compress true
启动HistoryServer:
./start-history-server.sh
访问HistoryServer:node4:18080,之后所有提交的应用程序运行状况都会被记录。
2.Master HA
1.Master的高可用原理
Standalone集群只有一个Master,如果Master挂了就无法提交应用程序,需要给Master进行高可用配置,Master的高可用可以使用fileSystem(文件系统)和zookeeper(分布式协调服务)。
fileSystem只有存储功能,可以存储Master的元数据信息,用fileSystem搭建的Master高可用,在Master失败时,需要我们手动启动另外的备用Master,这种方式不推荐使用。
zookeeper有选举和存储功能,可以存储Master的元素据信息,使用zookeeper搭建的Master高可用,当Master挂掉时,备用的Master会自动切换,推荐使用这种方式搭建Master的HA。
在这里插入图片描述
2.Master高可用搭建
1)在Spark Master节点上配置主Master,配置spark-env.sh
export SPARK_DAEMON_JAVA_OPTS="
-Dspark.deploy.recoveryMode=ZOOKEEPER
-Dspark.deploy.zookeeper.url=node3:2181,node4:2181,node5:2181
-Dspark.deploy.zookeeper.dir=/sparkmaster0821"
在这里插入图片描述
2)发送到其他worker节点上
在这里插入图片描述
在这里插入图片描述
3)找一台节点(非主Master节点)配置备用 Master,修改spark-env.sh配置节点上的MasterIP
在这里插入图片描述
4)启动集群之前启动zookeeper集群:
…/zkServer.sh start
5)启动spark Standalone集群,启动备用Master
6)打开主Master和备用Master WebUI页面,观察状态。
3.注意点
主备切换过程中不能提交Application。
主备切换过程中不影响已经在集群中运行的Application。因为Spark是粗粒度资源调度。
4.测试验证
提交SparkPi程序,kill主Master观察现象。
./spark-submit
–master spark://node1:7077,node2:7077
–class org.apache.spark.examples.SparkPi
…/lib/spark-examples-1.6.0-hadoop2.6.0.jar
10000

猜你喜欢

转载自blog.csdn.net/qq_20174285/article/details/86023319
HA