centos6下filebeat多开问题

0. 场景

比如之前在用filebeat做收集,但是想新开一个实例把之前的日志全部重新导一遍,如果直接指定filebeat -c 是不行的,因为filebeat把文件读取的游标记录在文件里面了。默认是/var/lib/filebeat下面。

网上搜了一下是没找到相关文档,所以记录一下自己的做法。下面做法的一个大前提是centos6,centos7的做法最后会提到。

1. 做法

做法其实很简单,启动脚本进行修改了以后尝试即可。我们看看filebeat的启动脚本。

...
args="-c /etc/filebeat/filebeat.yml -path.home /usr/share/filebeat -path.config /etc/filebeat -path.data /var/lib/filebeat -path.logs /var/log/filebeat"
...

基本上你结合filebeat -h的帮助,改下参数即可得到多开方案。

这里面有3个点,

  1. -c 配置文件
  2. -path.data 存放metadata的,
  3. -path.logs 日志目录

结合filebeat -h

Flags:
-E, --E setting=value Configuration overwrite
-M, --M setting=value Module configuration overwrite
-N, --N Disable actual publishing for testing
-c, --c string Configuration file, relative to path.config (default "filebeat.yml")
--cpuprofile string Write cpu profile to file
-d, --d string Enable certain debug selectors
-e, --e Log to stderr and disable syslog/file output
-h, --help help for filebeat
--httpprof string Start pprof http server
--memprofile string Write memory profile to this file
--modules string List of enabled modules (comma separated)
--once Run filebeat only once until all harvesters reach EOF
--path.config string Configuration path (default "")
--path.data string Data path (default "")
--path.home string Home path (default "")
--path.logs string Logs path (default "")
--plugin pluginList Load additional plugins
--setup Load sample Kibana dashboards and setup Machine Learning
--strict.perms Strict permission checking on config files (default true)
-v, --v Log at INFO level

跟原来的区别开就行,我试了,可以正常运行的。 但是有点小瑕疵,比如pid问题:

2. pid 问题

看filebeat的帮助里面是没法指定pidfile的,没pidfile就不大好杀进程了,得查了根据命令参数或者启动时间来判断,比较麻烦,后面仔细看了启动脚本,发现脚本是

start() {
echo -n $"Starting filebeat: "
test
if [ $? -ne 0 ]; then
echo
exit 1
fi
daemon $daemonopts $wrapper $wrapperopts -- $agent $args
RETVAL=$?
echo
return $RETVAL
}
$daemonopts

# Determine if we can use the -p option to daemon, killproc, and status.
# RHEL < 5 can't.
if status | grep -q -- '-p' 2>/dev/null; then
daemonopts="--pidfile $pidfile"
pidopts="-p $pidfile"
fi
$wrapper

wrapper="/usr/share/filebeat/bin/filebeat-god"

wrapperopts="-r / -n -p $pidfile"

这段脚本是调用了filebeat-god, 这个命令是可以指定pidfile的。

想要完美的进行多开必须改掉整个启动脚本,这里没有做深入尝试.

centos7 的启动方式

centos7是没有filebeat-god,用了systemd以后很简洁:

[Service]
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
Restart=always

systemd应该是会自己记pid,stop的时候发送kill信好就行了。 所以没有centos6的一些问题。

另外说一下,如果在k8s里面使用filebeat就更加方便了,使用sidecar 那种方式另起一个容器,一起跑就行了~

centos6下filebeat多开问题的更多相关文章

  1. centos6下安装dedecms

    几经波折,终于安装成功!!! 一.centos6下安装WDCP 1.连接linux 在百度直接搜索下载xshell,通过ssh连接 2.安装wdcp 下载安装wget http://dl.wdlinu ...

  2. VPS CentOS-6 下 LNMP HTTP服务器的搭建

    VPS CentOS-6 下 LNMP HTTP服务器的搭建 前言 恢复更新后的第一篇博文, 前段时间由于各种理由, 把博客更新给宕掉了, 个人独立博客的开发也搁浅了, 现在随着工作的逐步稳定, 决心 ...

  3. CentOS6下Haproxy的安装配置

    Haproxy 是一个开源的负载均衡和反向代理软件,其提供了高可用的网络服务.其一般是应用于web服务,但同时也能为SMTP和终端服务等提供可靠的支持. 1.下载安装haproxy wget ftp: ...

  4. (转载)CentOS6下 源代码方式安装openERP7.0

    CentOS6下 源代码方式安装openERP7.0 安装背景 :CPU32 bit,CentOS 6.4版本,openERP7.0,linux shell为bash,PostgreSQL9.2 1. ...

  5. CentOS6下编译安装Python2.7.6方法

    关于在CentOS6下编译安装Python2.7.6的方法非常的多了,小编以前也介绍过相关的文章了,下面一聚教程小编再来为各位介绍一下吧,希望文章能帮助到各位.   CentOS下面Python在升级 ...

  6. Mysql系列三:Centos6下安装Mysql和Mysql主从复制的搭建

    一.Centos6下安装Mysql 检测下系统有没有自带的mysql:yum list installed | grep mysql, 如果已经有的话执行命令yum -y remove mysql-l ...

  7. Centos6下Python3的编译安装

    本文转载自 Centos6下Python3的编译安装 系统环境:CentOS 6.8-Minimal 安装Python依赖包: 1 [root@Python src]# yum install zli ...

  8. CentOS6下docker的安装和使用

    CentOS6下docker的安装和使用 Docker是一个开源的应用容器引擎,可以轻松的为任何应用创建一个轻量级的.可移植的.自给自足的容器.利用Linux的LXC.AUFS.Go语言.cgroup ...

  9. CentOS6 下编译安装 MySQL 5.6.26

    CentOS6下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的5.6.26. 一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server rpm -qa | ...

随机推荐

  1. liunx系统二进制包安装编译mysql数据库

    liunx系统二进制包安装编译mysql数据库 # 解压二进制压缩包 [root@localhost ~]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz -C ...

  2. Windows 计划任务 如果选择未登录就运行 则看不到GUI

    You can specify that a task should run even if the account under which the task is scheduled to run ...

  3. Window+Protobuf使用说明

    Window+Protobuf使用说明 C++WindowCmakeProtocbuf 介绍 起因 由于项目中要用到二进制存储数据,之前使用的方式是按照字节数依次将数据写入字节流中, 但是这样做起来做 ...

  4. (转)如何学好C++语言

    原文:http://coolshell.cn/articles/4119.html   作者:陈皓 昨天写了一篇如何学好C语言,就有人回复问我如何学好C++,所以,我把我个人的一些学习经验写在这里,希 ...

  5. js 实现对象的混合与克隆效果,带完整版解析代码[helpers.js]

    前言:         本人纯小白一个,有很多地方理解的没有各位大牛那么透彻,如有错误,请各位大牛指出斧正!小弟感激不尽.         本篇文章为您分析一下原生JS写淘宝无缝轮播图效果 对象混合 ...

  6. 【linux三剑客】sed命令

    sed - stream editor for filtering and transforming text sed 流编辑器 strem edition,实现对文件的增删改替换查是Linux中第二 ...

  7. CSS常用遮罩层

    为什么80%的码农都做不了架构师?>>>   CSS常用遮罩层 应用场景: 上传了一张图片,鼠标移入到图片上的时候显示遮罩层,并且提示点击删除. 通过改变遮罩层的透明度来实现显示隐藏 ...

  8. Android 项目 Android 学习手册(一)

    前言: 当每次查询android 知识的时候,内心是凌乱的,总觉得要是有一个工具多好, 尤其在手机端如何可以查询的话,会非常完美,能大大减少选择查询的时间, 之前见了很多java 学习手册,把一些重要 ...

  9. Java 线程池(ThreadPoolExecutor)原理分析与实际运用

    在我们的开发中"池"的概念并不罕见,有数据库连接池.线程池.对象池.常量池等等.下面我们主要针对线程池来一步一步揭开线程池的面纱. 有关java线程技术文章还可以推荐阅读:< ...

  10. 2019 Multi-University Training Contest 10 I Block Breaker

    Problem Description Given a rectangle frame of size n×m. Initially, the frame is strewn with n×m squ ...