PK服務器arm架構 Filebeat 7.4.1安裝和部署

介紹

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


安裝使用

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


pk:

x86安裝方法這里就不闡述了,主要介紹pk版本的filebeat安裝方法。

1. 安裝golang

  1. 從golang官網(wǎng)下下載golang-1.14.3_arm64
    https://studygolang.com/dl
    go1.14.3.linux-arm64.tar.gz

  2. 解壓到/usr/lib下

ln -s /usr/lib/go/bin/go  /usr/bin/go
ln -s /usr/lib/go/bin/gofmt  /usr/bin/gofmt
  1. 配置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安裝

  1. Filebeat下載編譯
cd /data/software
wget https://github.com/elastic/beats/archive/v7.4.1.tar.gz
  1. 創(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
  1. 修改配置文件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 &

啟動成功后能看到日志
最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容