当前位置: 首页 > 知识库问答 >
问题:

如何在yarn客户端模式下提交远程主节点上的spark作业?

敖淮晨
2023-03-14
./spark-submit --class SparkTest --deploy-mode client /home/vm/app.jar 

我有我的主人的地址硬编码到我的应用程序在表单

val spark_master = spark://IP:7077

但我得到的只是错误

16/06/06 03:04:34 INFO AppClient$ClientEndpoint: Connecting to master spark://IP:7077...
16/06/06 03:04:34 WARN AppClient$ClientEndpoint: Failed to connect to master IP:7077
java.io.IOException: Failed to connect to /IP:7077
at org.apache.spark.network.client.TransportClientFactory.createClient(TransportClientFactory.java:216)
at org.apache.spark.network.client.TransportClientFactory.createClient(TransportClientFactory.java:167)
at org.apache.spark.rpc.netty.NettyRpcEnv.createClient(NettyRpcEnv.scala:200)
at org.apache.spark.rpc.netty.Outbox$$anon$1.call(Outbox.scala:187)
at org.apache.spark.rpc.netty.Outbox$$anon$1.call(Outbox.scala:183)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.ConnectException: Connection refused: /IP:7077

或者如果我使用

./spark-submit --class SparkTest --master yarn --deploy-mode client /home/vm/test.jar
Exception in thread "main" java.lang.Exception: When running with master 'yarn' either HADOOP_CONF_DIR or YARN_CONF_DIR must be set in the environment.
at org.apache.spark.deploy.SparkSubmitArguments.validateSubmitArguments(SparkSubmitArguments.scala:251)
at org.apache.spark.deploy.SparkSubmitArguments.validateArguments(SparkSubmitArguments.scala:228)
at org.apache.spark.deploy.SparkSubmitArguments.<init>(SparkSubmitArguments.scala:109)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:114)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

共有1个答案

姬安志
2023-03-14

首先,如果要从应用程序代码中设置conf.setmaster(...),则它具有最高优先级(高于--master参数)。如果要在yarn客户端模式下运行,请不要在应用程序代码中使用master_ip:7077。您应该按照以下方式向驱动程序提供hadoop客户端配置文件。

您应该将环境变量HADOOP_CONF_DIR或YARN_CONF_DIR设置为指向包含客户端配置的目录。

http://spark.apache.org/docs/latest/running-on-yarn.html

 类似资料: