Syslog+Fluentd+InfluxDB日志收集系統搭建


環境配置

節點 配置 類型 操作系統
Sched 2G 2CPU 50GB ens3=>192.168.200.11 KVM虛擬機 CentOS 7
Nova 4G 2CPU 50GB ens3=>192.168.2000.12 KVM虛擬機 CentOS 7

Sched節點配置

配置InfluxDB軟件源

# cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL \$releasever
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOF

# yum makecache

安裝InfluxDB

# yum install influxdb -y

### 設置開機啟動
# systemctl start influxdb
# systemctl enable influxdb
# systemctl stop firewalld
# systemctl disable firewalld

### 查詢InfluxDB默認配置
# influxd config
### 開啟web訪問,URL地址http://192.168.200.11:8083
# vim /etc/influxdb/influxdb.conf
[admin]
  enabled = true
# systemctl restart influxdb

### 如果不是使用標准的默認目錄,需要手動修改目錄權限
# chown -R influxdb:influxdb /mnt/influx
# chown -R influxdb:influxdb /mnt/db

### 創建test數據庫
# influx
> CREATE DATABASE test
> use test

安裝Fluentd

# yum install epel-release
# yum makecache
# curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent2.sh | sh

安裝InfluxDB插件

# td-agent-gem install fluent-plugin-influxdb

配置Fluentd

# vim /etc/td-agent/td-agent.conf
<source>
  type syslog
  port 42185
  tag  system
</source>

<match system.*.*>
  type influxdb
  dbname test
  flush_interval 10s
  host 192.168.200.11
  port 8086
</match>
# systemctl restart td-agent

Nova節點配置

配置rsyslog

# wget http://rpms.adiscon.com/v8-stable/rsyslog.repo -O /etc/yum.repos.d/rsyslog.repo
# yum makecache
# yum install rsyslog
# vim /etc/rsyslog.conf
*.* @192.168.200.11:42185
# systemctl restart rsyslog

驗證安裝

### 在Nova節點執行
# logger -p "local3.notice" "fwd test"

### 在Sched節點執行
# influx
> USE test
> SHOW MEASUREMENTS
> SELECT * FROM "system.local3.notice"

參考文檔

Aggregate and Analyze Syslog with InfluxDB
influxdb的簡單使用


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM