介紹
由于pk服務器使用arm架構,網(wǎng)上很難找到安裝教程。并且官方也沒有提供arm安裝包,這點很坑!這里筆者整理了一下,供大家參考。
對比x86安裝,相對麻煩一些。但能成功使用,大家有需要一定要耐心看完

安裝使用
首先查看liunx服務器是x86還是pk
uname -a
x86:

pk:

x86安裝方法這里就不闡述了,主要介紹pk版本的filebeat安裝方法。
1. 安裝golang
從golang官網(wǎng)下下載golang-1.14.3_arm64
https://studygolang.com/dl
go1.14.3.linux-arm64.tar.gz解壓到/usr/lib下
ln -s /usr/lib/go/bin/go /usr/bin/go
ln -s /usr/lib/go/bin/gofmt /usr/bin/gofmt
- 配置go環(huán)境變量
vim /etc/profile
export GOROOT=/usr/lib/go
export GOPATH=/root/go # 這里請根據(jù)需要填入,用于存放之后go的各種依賴包,需先創(chuàng)建文件夾
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
source /etc/profile
執(zhí)行go version,如果能成功看到版本信息,表示已經(jīng)安裝成功。
go version
2. Filebeat安裝
- Filebeat下載編譯
cd /data/software
wget https://github.com/elastic/beats/archive/v7.4.1.tar.gz
- 創(chuàng)建目錄并解壓到指定目錄
mkdir -p $GOPATH/src/github.com/elastic
tar -zxvf beats-7.4.1.tar.gz -C $GOPATH/src/github.com/elastic
cd $GOPATH/src/github.com/elastic
mv beats-7.4.1 beats
- 修改配置文件stderr_other.go
cd /root/go/src/github.com/elastic/beats/libbeat/common/file/
拷貝該目錄下的stderr_other.go到本地,用notepad++修改30行,return syscall.Dup2(int(toFile.Fd()),2)為return syscall.Dup3(int(toFile.Fd()),2,0)
放回linux原目錄下
cd $GOPATH/src/github.com/elastic/beats/filebeat
go build
編譯成功后生成可執(zhí)行文件filebeat
修改filebeat.yml配置文件,先打印到控制臺試下
filebeat.inputs:
- type: stdin
enabled: true
setup.template.settings:
index.number_of_shards: 3
output.console:
pretty: true
enable: true
啟動filebeat
./filebeat -e -c filebeat.yml
輸入hello就能看到輸出結(jié)果
filebeat多個應用目錄采集配置方法:
修改filebeat.ymlll
filebeat.inputs:
- type: log
enabled: true
paths:
- /opt/web/8091-cms-boot/logs/CMS_ROOT.log
tags: ["cms"]
fields:
index: "cms"
- type: log
enabled: true
paths:
- /opt/nodes/node-saber/boot/logs/SABER_ROOT.log
tags: ["saber"]
fields:
index: "saber"
setup.template.settings:
index.number_of_shards: 3
output.elasticsearch:
hosts: ["192.168.1.137:9200"]
indices:
- index: "filebeat-cms"
when.contains:
fields:
index: "cms"
- index: "filebeat-saber"
when.contains:
fields:
index: "saber"
把啟動命令做成shell腳本
nohup /root/go/src/github.com/elastic/beats/filebeat/filebeat -e -c /root/go/src/github.com/elastic/beats/filebeat/filebeat.yml > filebeat.log &
啟動成功后能看到日志