[root@localhost ~]# vim /etc/filebeat/filebeat.yml
#=========================== Filebeat inputs =============================
filebeat.inputs:
# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.
- type: log
# Change to true to enable this input configuration.
enabled: true
# Paths that should be crawled and fetched. Glob based paths.
paths:
- /opt/access.log
#================================ Outputs =====================================
# Configure what output to use when sending the data collected by the beat.
output.redis:
hosts: ["172.20.67.50:6379"]
#port: 6379
#password: "123456"
db: 2
timeout: 10
key: "nginx-log"
#####备注:目前使用filebeat向redis写日志的时候不能向redis集群里写,会提示报错,所有redis只能写到单台里,
root@localhost ~]# systemctl start filebeat
[root@localhost ~]# systemctl status filebeat
● filebeat.service - Filebeat sends log files to Logstash or directly to Elasticsearch.
Loaded: loaded (/usr/lib/systemd/system/filebeat.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2018-09-20 19:48:36 CST; 3s ago
Docs: https://www.elastic.co/products/beats/filebeat
Main PID: 11947 (filebeat)
CGroup: /system.slice/filebeat.service
└─11947 /usr/share/filebeat/bin/filebeat -c /etc/filebeat/filebeat.yml -path.home /usr/share/filebeat -path.config /etc/filebeat -path.data /var/lib/filebeat -path.logs /var/log/filebeat
Sep 20 19:48:36 localhost.localdomain systemd[1]: Started Filebeat sends log files to Logstash or directly to Elasticsearch..
Sep 20 19:48:36 localhost.localdomain systemd[1]: Starting Filebeat sends log files to Logstash or directly to Elasticsearch....
[root@localhost ~]#
2、Redis具体的操作
在redis上查看具体导入的数据
3、logstash 具体的配置
“2018-09-20T17:58:05.029+0800 ERROR redis/client.go:231 Failed to RPUSH to redis list with: MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands
that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for det
ails about the RDB error.”
解决方案:去redis上查看日志,出现了“
18180:M 20 Sep 18:10:35.061 * 10 changes in 300 seconds. Saving...
18180:M 20 Sep 18:10:35.061 # Can't save in background: fork: Cannot al”
彻底解决的办法是在redis服务器上依次执行:
1、vim /etc/sysctl.conf
2、添加 vm.overcommit_memory=1
3、sysctl -p
错误二、
[WARN ][logstash.inputs.redis ] Redis connection problem {:exception=>#}
Redis connection problem {:exception=># 1