13

ELK-学习笔记–filebeat报错too many open files处理 |坐而言不如起而行! 二丫讲梵

 3 years ago
source link: http://www.eryajf.net/5016.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
ELK-学习笔记–filebeat报错too many open files处理 |坐而言不如起而行! 二丫讲梵
> 迎刃而解 > <十七>ELK-学习笔记–filebeat报错too many open files处理
本文预计阅读时间 4 分钟

有同学反馈说api的日志可能漏采了,部分日志查不到,我于是立马进行一波查验,发现的确是有部分日志没有写到es,一开始还以为是这部分日志有问题,然后开发同学是同目录下的日志用的是同一个框架,于是又想是不是es写入有问题,看了看也没问题,后来来到主机上看filebeat的日志,发现了如下报错。

  1. 2019-12-03T15:46:22+08:00 ERR Failed to create tempfile (/var/lib/filebeat/registry.new) for writing: open /var/lib/filebeat/registry.new: too many open files
  2. 2019-12-03T15:46:22+08:00 ERR Writing of registry returned error: open /var/lib/filebeat/registry.new: too many open files. Continuing...
  3. 2019-12-03T15:46:23+08:00 ERR Harvester could not be started on existing file: /var/log/secure, Err: Error setting up harvester: Harvester setup failed. Unexpected file opening error: Failed opening /var/log/secure: open /var/log/secure: too many open files

如上报错是采集的日志文件超过了filebeat进程的最大文件打开数了,而超出的部分,也将无法落入到es中。

71cfeb93ly1gf8j8vuxyzj20oe0zkgp9.jpg

解决可以参考动态修改,但只是临时生效,一旦服务或者系统重启,就又失效了,因此在启动文件中添加配置来解决:

  1. cat /usr/lib/systemd/system/filebeat.service
  2. [Unit]
  3. Description=filebeat
  4. Documentation=https://www.elastic.co/guide/en/beats/filebeat/current/index.html
  5. Wants=network-online.target
  6. After=network-online.target
  7. [Service]
  8. ExecStart=/usr/share/filebeat/bin/filebeat -c /etc/filebeat/filebeat.yml -path.home /usr/share/filebeat -path.config /etc/filebeat -path.data /var/lib/filebeat -path.logs /var/log/filebeat
  9. Restart=always
  10. LimitNOFILE=10240
  11. [Install]
  12. WantedBy=multi-user.target

然后重启服务即可。


weinxin


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK