filebeat:Failed to publish events caused by: write tcp 5044: write: connection reset by peer

简介: filebeat:Failed to publish events caused by: write tcp 5044: write: connection reset by peer

一、问题描述



filebeat的日志文件上一直在报这个错误:Failed to publish events caused by: write tcp 5044: write: connection reset by peer,从明面上看这个问题就是联通logstash时失败了,具体是什么原因却看不出来。刚开始网络上搜了下,发现网上的解决方法都是给logstash配置个连接超时的配置,就是在logstash的input里面配置如下即可:


input {
        beats {
                port => 5044
                codec => json
                client_inactivity_timeout => 36000
        }
}


笔者试了,不好使,根本原因还是我这里的报错不是这个导致的。


二、问题原因



上面的方法不好使,然后笔者就去检查了logstash的日志,有下面这块日志信息:

io.netty.util.internal.OutOfDirectMemoryError: failed to allocate 16777216 byte(s) of direct memory (used: 1029357059, max: 1037959168)
        at io.netty.util.internal.PlatformDependent.incrementMemoryCounter(PlatformDependent.java:640) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.util.internal.PlatformDependent.allocateDirectNoCleaner(PlatformDependent.java:594) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.buffer.PoolArena$DirectArena.allocateDirect(PoolArena.java:764) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.buffer.PoolArena$DirectArena.newChunk(PoolArena.java:740) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.buffer.PoolArena.allocateNormal(PoolArena.java:244) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.buffer.PoolArena.allocate(PoolArena.java:214) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.buffer.PoolArena.allocate(PoolArena.java:146) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:324) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:185) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:176) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:137) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator$MaxMessageHandle.allocate(DefaultMaxMessagesRecvByteBufAllocator.java:114) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:125) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497) ~[netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459) [netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [netty-all-4.1.18.Final.jar:4.1.18.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-all-4.1.18.Final.jar:4.1.18.Final]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_281]


看到这里就很简单明了了,logstash是用java写的,这里报的是直接内存这块使用已经满了,那就给直接内存增加点容量吧(注意:直接内存不属于堆栈范围,他是jvm虚拟机之外的内存,jvm是通过DirectByteBuffer来操作这块堆外内存的,这块内存常常会因为我们的忽视,导致内存溢出,直接内存详情请看这里:JVM内存结构详细总结)

然后笔者就去修改了logstash的jvm参数,就ok了。


三、问题解决



从报错上看 1037959168 该值将近1G,笔者直接提到了2G,参数如下

-XX:MaxDirectMemorySize=2048M


logstash配置截图如下:

7699cf05a0e4446caa5fc9c832ad5c23.png

logstash的运行截图如下:

image.png

(备注:这里当时配置的是2024不是2048,属于失误)


相关文章
|
9月前
|
人工智能
Timeout on reading data from socket
Timeout on reading data from socket
78 3
|
12天前
【已解决】kex_exchange_identification: Connection closed by remote host fatal: Could not read from
【已解决】kex_exchange_identification: Connection closed by remote host fatal: Could not read from
21 1
|
11月前
|
Python
ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
203 0
|
安全 Java 数据库连接
Java报错javax.net.ssl.SSLException MESSAGE: closing inbound before receiving peer‘s close_notify解决方法
Java报错javax.net.ssl.SSLException MESSAGE: closing inbound before receiving peer‘s close_notify解决方法
Java报错javax.net.ssl.SSLException MESSAGE: closing inbound before receiving peer‘s close_notify解决方法
|
8月前
|
Java 网络安全 Docker
curl: (56) Recv failure: Connection reset by peer
curl: (56) Recv failure: Connection reset by peer
448 0
|
网络安全
错误集--NFS报错clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
错误集--NFS报错clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
1316 0
错误集--NFS报错clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
|
网络协议 安全 Linux
如何修复 SSH Client_loop: send disconnect: Broken pipe Error
如何修复 SSH Client_loop: send disconnect: Broken pipe Error
2021 1
|
Python
ConnectionResetError: [Errno 104] Connection reset by peer
ConnectionResetError: [Errno 104] Connection reset by peer
506 0
|
开发工具 git
git 报错 RPC failed; curl 18 transfer closed with outstanding read data remaining
这个错误是因为项目太久,tag资源文件太大 找了很久网上都说这样: 配置如下: $ git  config --global http.
8863 0
|
网络协议
OGG-01232 Receive TCP params error: TCP/IP error 104 (Connection reset by peer), endpoint:
源端: 2015-02-05 17:45:49 INFO OGG-01815 Virtual Memory Facilities for: COM anon alloc: mmap(MAP_ANON) anon free: munmap file alloc: mmap(MAP_SH...
3070 0