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的简单使用

posted @ 2017-10-14 11:59  银魔术师  阅读(2098)  评论(0编辑  收藏  举报