Spark : 多个 spark-submit 并行
Spark : multiple spark-submit in parallel
我有一个关于 Apache Spark 的一般性问题:
我们有一些使用 Kafka 消息的 spark 流脚本。
问题:它们在没有特定错误的情况下随机失败...
有些脚本在我手动 运行 工作时什么都不做,一个失败并显示此消息:
ERROR SparkUI: Failed to bind SparkUI
java.net.BindException: Address already in use: Service 'SparkUI' failed after 16 retries!
所以我想知道是否有一种特定的方法可以并行 运行 脚本?
他们都在同一个罐子里,我 运行 他们和 Supervisor 在一起。
Spark 安装在 Yarn 上的 Cloudera Manager 5.4 上。
以下是我启动脚本的方式:
sudo -u spark spark-submit --class org.soprism.kafka.connector.reader.TwitterPostsMessageWriter /home/soprism/sparkmigration/data-migration-assembly-1.0.jar --master yarn-cluster --deploy-mode client
感谢您的帮助!
更新:我更改了命令,现在 运行 这个(它停止并显示特定消息):
root@ns6512097:~# sudo -u spark spark-submit --class org.soprism.kafka.connector.reader.TwitterPostsMessageWriter --master yarn --deploy-mode client /home/soprism/sparkmigration/data-migration-assembly-1.0.jar
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.4.7-1.cdh5.4.7.p0.3/jars/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.4.7-1.cdh5.4.7.p0.3/jars/avro-tools-1.7.6-cdh5.4.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
15/09/28 16:14:21 INFO Remoting: Starting remoting
15/09/28 16:14:21 INFO Remoting: Remoting started; listening on addresses :[akka.tcp://sparkDriver@ns6512097.ip-37-187-69.eu:52748]
15/09/28 16:14:21 INFO Remoting: Remoting now listens on addresses: [akka.tcp://sparkDriver@ns6512097.ip-37-187-69.eu:52748]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.4.7-1.cdh5.4.7.p0.3/jars/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.4.7-1.cdh5.4.7.p0.3/jars/avro-tools-1.7.6-cdh5.4.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
如果多个用户尝试同时启动 spark 会话或现有 spark 会话未属性关闭
,则会出现此问题
有两种方法可以解决此问题。
如下在不同的端口上启动新的 spark 会话
spark-submit --conf spark.ui.port=5051 <other arguments>`<br>`spark-shell --conf spark.ui.port=5051
查找所有使用4041到4056端口的spark会话,使用kill命令杀死进程,netstat和kill命令可以分别找到占用端口的进程并杀死进程。这是用法:
sudo netstat -tunalp | grep LISTEN| grep 4041
以上命令将产生如下输出,最后一列是进程 ID,在本例中 PID 是 32028
tcp 0 0 :::4040 :::* LISTEN 32028/java
一旦找到进程 ID(PID),就可以使用以下命令终止 spark 进程(spark-shell 或 spark-submit)
sudo kill -9 32028
您还可以提高为 spark.port.maxRetries
设置的值。
根据 docs:
Maximum number of retries when binding to a port before giving up. When a port is given a specific value (non 0), each subsequent retry will increment the port used in the previous attempt by 1 before retrying. This essentially allows it to try a range of ports from the start port specified to port + maxRetries.
以上回答正确。
但是,我们不应该尝试更改 spark.port.maxRetries
值,因为它会增加同一台服务器上的负载,这反过来会降低集群性能并可能将节点推向死锁 situations.Load 可以在您的会话中使用 uptime
命令进行检查。
此问题的根本原因是当您尝试通过 --deploy-mode client
.
运行 所有 spark 应用程序时
如果您的集群中有分布式容量,最好的方法是 运行 它与 --deploy-mode cluster
。
这样,每次都会运行不同节点的spark应用,从而缓解同一节点的端口绑定问题。
希望这对您有所帮助。干杯!
我有一个关于 Apache Spark 的一般性问题:
我们有一些使用 Kafka 消息的 spark 流脚本。 问题:它们在没有特定错误的情况下随机失败...
有些脚本在我手动 运行 工作时什么都不做,一个失败并显示此消息:
ERROR SparkUI: Failed to bind SparkUI java.net.BindException: Address already in use: Service 'SparkUI' failed after 16 retries!
所以我想知道是否有一种特定的方法可以并行 运行 脚本?
他们都在同一个罐子里,我 运行 他们和 Supervisor 在一起。 Spark 安装在 Yarn 上的 Cloudera Manager 5.4 上。
以下是我启动脚本的方式:
sudo -u spark spark-submit --class org.soprism.kafka.connector.reader.TwitterPostsMessageWriter /home/soprism/sparkmigration/data-migration-assembly-1.0.jar --master yarn-cluster --deploy-mode client
感谢您的帮助!
更新:我更改了命令,现在 运行 这个(它停止并显示特定消息):
root@ns6512097:~# sudo -u spark spark-submit --class org.soprism.kafka.connector.reader.TwitterPostsMessageWriter --master yarn --deploy-mode client /home/soprism/sparkmigration/data-migration-assembly-1.0.jar
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.4.7-1.cdh5.4.7.p0.3/jars/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.4.7-1.cdh5.4.7.p0.3/jars/avro-tools-1.7.6-cdh5.4.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
15/09/28 16:14:21 INFO Remoting: Starting remoting
15/09/28 16:14:21 INFO Remoting: Remoting started; listening on addresses :[akka.tcp://sparkDriver@ns6512097.ip-37-187-69.eu:52748]
15/09/28 16:14:21 INFO Remoting: Remoting now listens on addresses: [akka.tcp://sparkDriver@ns6512097.ip-37-187-69.eu:52748]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.4.7-1.cdh5.4.7.p0.3/jars/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.4.7-1.cdh5.4.7.p0.3/jars/avro-tools-1.7.6-cdh5.4.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
如果多个用户尝试同时启动 spark 会话或现有 spark 会话未属性关闭
,则会出现此问题有两种方法可以解决此问题。
如下在不同的端口上启动新的 spark 会话
spark-submit --conf spark.ui.port=5051 <other arguments>`<br>`spark-shell --conf spark.ui.port=5051
查找所有使用4041到4056端口的spark会话,使用kill命令杀死进程,netstat和kill命令可以分别找到占用端口的进程并杀死进程。这是用法:
sudo netstat -tunalp | grep LISTEN| grep 4041
以上命令将产生如下输出,最后一列是进程 ID,在本例中 PID 是 32028
tcp 0 0 :::4040 :::* LISTEN 32028/java
一旦找到进程 ID(PID),就可以使用以下命令终止 spark 进程(spark-shell 或 spark-submit)
sudo kill -9 32028
您还可以提高为 spark.port.maxRetries
设置的值。
根据 docs:
Maximum number of retries when binding to a port before giving up. When a port is given a specific value (non 0), each subsequent retry will increment the port used in the previous attempt by 1 before retrying. This essentially allows it to try a range of ports from the start port specified to port + maxRetries.
以上回答正确。
但是,我们不应该尝试更改 spark.port.maxRetries
值,因为它会增加同一台服务器上的负载,这反过来会降低集群性能并可能将节点推向死锁 situations.Load 可以在您的会话中使用 uptime
命令进行检查。
此问题的根本原因是当您尝试通过 --deploy-mode client
.
如果您的集群中有分布式容量,最好的方法是 运行 它与 --deploy-mode cluster
。
这样,每次都会运行不同节点的spark应用,从而缓解同一节点的端口绑定问题。
希望这对您有所帮助。干杯!