
# 提交Spark任务时连接ResourceManager异常
#### 问题现象
连接ResourceManager异常，导致Spark任务提交失败。
#### 原因分析
1. 在Driver端打印异常如下，打印连接两个ResourceManager主备节点的26004端口均被拒绝：
   ```
   15/08/19 18:36:16 INFO RetryInvocationHandler: Exception while invoking getClusterMetrics of class ApplicationClientProtocolPBClientImpl over 33 after 1 fail over attempts. Trying to fail over after sleeping for 17448ms. 
   java.net.ConnectException: Call From ip0 to ip1:26004 failed on connection exception: java.net.ConnectException: Connection refused.
   INFO RetryInvocationHandler: Exception while invoking getClusterMetrics of class ApplicationClientProtocolPBClientImpl over 32 after 2 fail over attempts. Trying to fail over after sleeping for 16233ms. 
    java.net.ConnectException: Call From ip0 to ip2:26004 failed on connection exception: java.net.ConnectException: Connection refused;
   ```
   
2. 在MRS Manager页面查看ResourceManager此时是否功能正常，如果Yarn服务状态故障或某个Yarn服务的实例出现未知之类的异常说明此时集群的ResourceManager可能异常。
3. 排查使用的客户端是否是集群最新的客户端。 排查集群是否做过实例ResourceManager迁移相关操作（先卸载某个ResourceManager实例，然后在其他节点添加）。
   
4. 在MRS Manager页面查看审计日志，是否有相关操作的记录。 使用**ping**命令，查看IP是否可连通。
   
 
#### 解决办法
- 如果ResourceManager出现异常，可参考相关告警章节查看解决方法。
- 如果客户端不是最新，请重新下载安装客户端。
- 若使用**ping**命令查看IP不通，需要协调网络管理相关人员协助排查网络。
- 若集群开启高可用，尝试将Yarn参数"yarn.client.failover-sleep-base-ms"调小。
 
