距离上一次更新该文章已经过了 763 天,文章所描述的內容可能已经发生变化,请留意。
安装好filebeat
plaintext
1 | 站内搜索: 记录日志系统的安装-部署-配置-使用文档(1) |
复制两个子文件夹下来
plaintext
1 | cp -r /etc/filebeat{,1} |
修改各自的filebeat.yml
plaintext
1 | ...(省略inputs之类的) |
这里主要是查看下机器systemd的path

我这里是/usr/lib/systemd/system
添加两份配置文件
vi /usr/lib/systemd/system/filebeat1.service
plaintext1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17[Unit]
Description=Filebeat sends log files to Logstash or directly to Elasticsearch.
Documentation=https://www.elastic.co/beats/filebeat
Wants=network-online.target
After=network-online.target
[Service]
Environment="GODEBUG='madvdontneed=1'"
Environment="BEAT_LOG_OPTS="
Environment="BEAT_CONFIG_OPTS=-c /etc/filebeat1/filebeat.yml"
Environment="BEAT_PATH_OPTS=--path.home /usr/share/filebeat --path.config /etc/filebeat1 --path.data /var/lib/filebeat1 --path.logs /var/log/filebeat1"
ExecStart=/usr/share/filebeat/bin/filebeat --environment systemd $BEAT_LOG_OPTS $BEAT_CONFIG_OPTS $BEAT_PATH_OPTS
Restart=always
[Install]
WantedBy=multi-user.targetvi /usr/lib/systemd/system/filebeat2.service
plaintext1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17[Unit]
Description=Filebeat sends log files to Logstash or directly to Elasticsearch.
Documentation=https://www.elastic.co/beats/filebeat
Wants=network-online.target
After=network-online.target
[Service]
Environment="GODEBUG='madvdontneed=1'"
Environment="BEAT_LOG_OPTS="
Environment="BEAT_CONFIG_OPTS=-c /etc/filebeat2/filebeat.yml"
Environment="BEAT_PATH_OPTS=--path.home /usr/share/filebeat --path.config /etc/filebeat2 --path.data /var/lib/filebeat2 --path.logs /var/log/filebeat2"
ExecStart=/usr/share/filebeat/bin/filebeat --environment systemd $BEAT_LOG_OPTS $BEAT_CONFIG_OPTS $BEAT_PATH_OPTS
Restart=always
[Install]
WantedBy=multi-user.target
然后启动看一下
plaintext
1 | systemctl start filebeat1.service |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 小五的个人杂货铺!