java.io.IOException: Connection reset by peer

本文涉及的产品
注册配置 MSE Nacos/ZooKeeper,118元/月
服务治理 MSE Sentinel/OpenSergo,Agent数量 不受限
云原生网关 MSE Higress,422元/月
简介: 一.场景:     spark通过phoenix 读取hbase表,其实说白了先要去Zookeeper建立connection。二.代码: 点击(此处)折叠或打开 val zkUrl = "192.
一.场景:
    spark通过phoenix 读取hbase表,其实说白了先要去Zookeeper建立connection。

二.代码:

点击(此处)折叠或打开

val zkUrl = "192.168.100.39,192.168.100.40,192.168.100.41:2181"
val formatStr = "org.apache.phoenix.spark"
val oms_orderinfoDF = spark.read.format(formatStr)
  .options(Map("table" -> "oms_orderinfo", "zkUrl" -> zkUrl))
  .load

三.查看SparkJob日志:

点击(此处)折叠或打开

17/10/24 03:25:25 INFO zookeeper.ClientCnxn: Opening socket connection to server hadoop40/192.168.100.40:2181. Will not attempt to authenticate using SASL (unknown error)
17/10/24 03:25:25 INFO zookeeper.ClientCnxn: Socket connection established, initiating session, client: /192.168.100.48:35952, server: hadoop40/192.168.100.40:2181
17/10/24 03:25:25 WARN zookeeper.ClientCnxn: Session 0x0 for server hadoop40/192.168.100.40:2181, unexpected error, closing socket connection and attempting reconnect
java.io.IOException: Connection reset by peer     at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
    at sun.nio.ch.IOUtil.read(IOUtil.java:192)
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
    at org.apache.phoenix.shaded.org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:68)
    at org.apache.phoenix.shaded.org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:355)
    at org.apache.phoenix.shaded.org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
17/10/24 03:25:25 INFO yarn.ApplicationMaster: Deleting staging directory hdfs://nameservice1/user/hdfs/.sparkStaging/application_1507703377455_4854
17/10/24 03:25:25 INFO util.ShutdownHookManager: Shutdown hook called
主要错误是“java.io.IOException: Connection reset by peer”,其实意思很明白了 Zookeeper将connection closing.
至于为什么会被关闭connection?那么去检查一下hadoop40机器的zookeeper的日志就会发现一些有用的信息。

四.查看Zookeeper日志:

点击(此处)折叠或打开

2017-10-24 03:25:22,498 WARN org.apache.zookeeper.server.NIOServerCnxnFactory: Too many connections from /192.168.100.40 - max is 500
2017-10-24 03:25:25,588 WARN org.apache.zookeeper.server.NIOServerCnxnFactory: Too many connections from /192.168.100.40 - max is 500
2017-10-24 03:25:25,819 WARN org.apache.zookeeper.server.NIOServerCnxnFactory: Too many connections from /192.168.100.40 - max is 500
2017-10-24 03:25:26,092 WARN org.apache.zookeeper.server.NIOServerCnxn: caught end of stream exception
EndOfStreamException: Unable to read additional data from client sessionid 0x15ed091ee09897d, likely client has closed socket
    at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:231)
    at org.apache.zookeeper.server.NIOServerCnxnFactory.run(NIOServerCnxnFactory.java:208)
    at java.lang.Thread.run(Thread.java:745)
2017-10-24 03:25:26,092 INFO org.apache.zookeeper.server.NIOServerCnxn: Closed socket connection for client /192.168.100.40:47084 which had sessionid 0x15ed091ee09897d
2017-10-24 03:25:26,092 WARN org.apache.zookeeper.server.NIOServerCnxn: caught end of stream exception
EndOfStreamException: Unable to read additional data from client sessionid 0x15ed091ee098981, likely client has closed socket
    at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:231)
    at org.apache.zookeeper.server.NIOServerCnxnFactory.run(NIOServerCnxnFactory.java:208)
    at java.lang.Thread.run(Thread.java:745)
2017-10-24 03:25:26,093 INFO org.apache.zookeeper.server.NIOServerCnxn: Closed socket connection for client /192.168.100.40:47304 which had sessionid 0x15ed091ee098981
2017-10-24 03:25:26,093 WARN org.apache.zookeeper.server.NIOServerCnxn: caught end of stream exception
这个时候我们发现" Too many connections from /192.168.100.48 - max is 500 ",
那就说明这台hadoop40机器的zookeeper的当前connection数已经超过配置的500了,所以新的connection必然被closed,


五.解决方法:
那么我们只需去zookeeper的配置修改一下参数
maxClientCnxns调大到1000,重启zookeeper服务生效配置即可。

目录
相关文章
|
4月前
|
网络协议 Java 应用服务中间件
解决java.net.ConnectException: Connection refused:connect报错
解决java.net.ConnectException: Connection refused:connect报错
885 1
|
6月前
|
Linux Windows
FinalShell连接Linux虚拟机报错java.net.ConnectException: Connection timed out: connect(亲测有效)
FinalShell连接Linux虚拟机报错java.net.ConnectException: Connection timed out: connect(亲测有效)
1153 0
|
6月前
|
SQL 分布式计算 Java
HiveOnSpark 报错:java.lang.IllegalStateException(Connection to remote Spark driver was lost)‘ Last kno
Hive On Spark 测试时遇到`java.lang.IllegalStateException`和`FileNotFoundException`,问题根源是 Spark 缺少 `hive-exec-3.1.3.jar`。解决方法:从 `$HIVE_HOME/lib/`复制该 jar 到 `$SPARK_HOME/jars/`,并使用 `hdfs dfs -put`命令将其上传至 HDFS 的 `/spark-jars/`(根据实际情况调整路径)。重启 Hive 元数据服务后问题解决。
252 0
HiveOnSpark 报错:java.lang.IllegalStateException(Connection to remote Spark driver was lost)‘ Last kno
|
6月前
|
关系型数据库 网络安全 对象存储
Flink报错问题之Flink报错java.io.EOFException: SSL peer shut down incorrectly如何解决
Flink报错通常是指在使用Apache Flink进行实时数据处理时遇到的错误和异常情况;本合集致力于收集Flink运行中的报错信息和解决策略,以便开发者及时排查和修复问题,优化Flink作业的稳定性。
|
6月前
java.lang.Exception: Apparent connection leak detected
java.lang.Exception: Apparent connection leak detected
105 0
|
6月前
java.net.ConnectException: 拒绝连接 (Connection refused) doris
java.net.ConnectException: 拒绝连接 (Connection refused) doris
385 1
|
6月前
|
分布式计算 Linux Spark
【已解决】Caused by: java.net.SocketException: Connection reset by peer: socket write error
【已解决】Caused by: java.net.SocketException: Connection reset by peer: socket write error
211 0
|
5天前
|
Java 开发者
Java多线程编程中的常见误区与最佳实践####
本文深入剖析了Java多线程编程中开发者常遇到的几个典型误区,如对`start()`与`run()`方法的混淆使用、忽视线程安全问题、错误处理未同步的共享变量等,并针对这些问题提出了具体的解决方案和最佳实践。通过实例代码对比,直观展示了正确与错误的实现方式,旨在帮助读者构建更加健壮、高效的多线程应用程序。 ####
|
4天前
|
安全 Java 开发者
Java 多线程并发控制:深入理解与实战应用
《Java多线程并发控制:深入理解与实战应用》一书详细解析了Java多线程编程的核心概念、并发控制技术及其实战技巧,适合Java开发者深入学习和实践参考。
|
4天前
|
Java 开发者
Java多线程编程的艺术与实践####
本文深入探讨了Java多线程编程的核心概念、应用场景及实践技巧。不同于传统的技术文档,本文以实战为导向,通过生动的实例和详尽的代码解析,引领读者领略多线程编程的魅力,掌握其在提升应用性能、优化资源利用方面的关键作用。无论你是Java初学者还是有一定经验的开发者,本文都将为你打开多线程编程的新视角。 ####
下一篇
无影云桌面