当前位置:网站首页>IDEA远程调试spark-submit提交的jar
IDEA远程调试spark-submit提交的jar
2022-06-13 10:17:00 【Interest1_wyt】
1、编辑代码
object WordCount {
def main(args: Array[String]): Unit = {
val sc = new SparkContext(new SparkConf().setAppName("WordCount "))
val rdd: RDD[String] = sc.makeRDD(List(
"spark hello", "hive", "hadoop hbase", "spark hadoop", "hbase"
))
val value: RDD[String] = rdd.flatMap(_.split(" "))
val mapRDD: RDD[(String, Int)] = value.map((_, 1))
val result: RDD[(String, Int)] = mapRDD.reduceByKey(_ + _)
result.collect().foreach(println)
}
}
2、打开IDEA配置,配置远程连接
其中主要配置的有两项,一个是host,一个是port。不过图中我圈出来了三处,最后一处仔细阅读其英文描述可以知道,那一串命令是需要我们拷贝添加到spark-submit提交命令的参数中的。
3、修改spark-submit,添加远程连接的参数
spark-submit \
--master spark://bigdata.node2:7077 \
--class test.wordcount.WordCount \
--num-executors 1 \
--driver-memory 499m \
--driver-cores 1 \
--executor-memory 499m \
--executor-cores 1 \
--driver-java-options -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8888 \
/opt/spark-jar/wyt01bigdata-1.0-SNAPSHOT.jar
可以看到,我们将IDEA中生成的远程命令-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8888 添加在了spark提交命令中。这里有个参数要特别留意下,对于debug很有用,那就是suspend=y,y表示启动的JVM会暂停等待,直到IDEA调试器连接上才继续执行。如果设置suspend=n,那么远程服务不会等待IDEA连接。
另外这里还有一个需要留意的点是,因为上一步我们远程debug指定了host和port,所以这里我们千万不要配置deploy-mode为cluster集群模式。因为集群模式是随便找个机器启动应用,很有可能不在我们监听的那台服务器启动,所以远程debug的部署模式通常选用client(我们不配置部署模式时默认则是client)
边栏推荐
- Leetcode (question 15) - sum of three numbers
- 虚拟机内存结构简述
- Summary of string, vector and array learning
- 递归想法和实现介绍,消除递归
- 【轴承故障分解】基于matlab ITD轴承故障信号分解【含Matlab源码 1871期】
- MySQL中redo日志和undo日志简述
- Memory management -- Viewing memory space from the perspective of executing programs and processes
- MySQL利用E-R模型的数据库概念设计
- 【工具链系列】 Notepad++
- Docker deployment MySQL
猜你喜欢
Docker部署Mysql
苹果放大招!这件事干的太漂亮了……
Double carbon in every direction: green demand and competition focus in the calculation from the east to the West
Trees and binary trees: traversal of binary trees
Cynthia项目缺陷管理系统
Design of simple electronic clock based on single chip microcomputer
Thingsboard tutorial (21): save data after processing using message types and data processing nodes
Test redundancy code for error problem type solution - excerpt
ThingsBoard教程(二十):使用规则链过滤遥测数据
架构师必备:系统容量现状checklist
随机推荐
Protocol UART of schematic diagram
Consolas-with-Yahei
计算循环冗余码--摘录
Consolas-with-Yahei
[51nod p3047] displacement operation [bit operation]
Node-RED系列(二四):在Node-RED中使用mysql节点实现数据库的增删改查
Cynthia項目缺陷管理系統
Apple zoom! It's done so well
ADG备库MRP0状态WAIT_FOR_GAP
Smart210 uses SD card to burn uboot
简述请求过程
Weekend book: power BI data visualization practice
Node-RED系列(二七):扩展节点之s7节点的使用说明
SQL Server创建windows登录账户找不到用户或组
Oracle custom data type question
Test redundancy code for error problem type solution - excerpt
Classical convolutional neural network model
Pxxx local socket communication
IDEA 续命插件
五分钟内编写Pytorch模型