OS: Centos7
Logstash: 6.8.7
1. 安装Open-JDK
yum install java
2. rpm安装Logstash
wget https://artifacts.elastic.co/downloads/logstash/logstash-6.8.7.rpm
rpm -ivh logstash-6.8.7.rpm
3. 创建syslog配置
创建配置文件 /etc/logstash/conf.d/syslog.conf
input{ syslog{ type => "system-syslog" port => 514 } } output{ stdout{ codec => rubydebug # 收集到的日志以rubydebug格式显示, 还可以使用 json } }
4. 测试效果
直接在命令行运行查看效果
/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/syslog.conf
5. 启动Logstash服务
生成Unit启动文件
/usr/share/logstash/bin/system-install /etc/logstash/startup.options systemd
启动服务
systemctl enable --now logstash.service
将Unit文件中的user和group修改为root用户
/etc/systemd/system/logstash.service
重启服务
systemctl restart logstash.service