Logstash收集mysql数据库日志

说明

1
2
ELK服务器IP:192.168.10.21
Mysql服务器IP:192.168.10.27
1、修改Logstash客户端配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
vim /etc/logstash/mysql.conf

input {
#mysql_log
file {
path => "/var/log/mysqld.log"
type => "mysql_log"
}
}

}


output {
if [type] == "mysql_log" {
rabbitmq {
host => "192.168.10.21"
port => 5672
key => "mysql_log"
user => "nong"
password => "nong"
exchange => "amq.direct"
exchange_type => "direct"
}
}

}
2、检查配置文件是否正确
1
/a01/apps/logstash/bin/logstash -t -f /etc/logstash/
3、修改Logstash服务端配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
vim /etc/logstash/mysql.conf

input {
#mysql_log
rabbitmq {
host => "192.168.10.21"
port => 5672
key => "mysql_log"
user => "nong"
password => "nong"
exchange => "amq.direct"
exchange_type => "direct"
}


}

output {
if [type] == "mysql_log" {
elasticsearch {
hosts => "192.168.10.21:9200"
index => "mysql_log-%{+YYYY.MM.dd}"
}
}


}
4、检查配置文件是否正确
1
/data1/logstash/bin/logstash -t -f /etc/logstash/
5、重启服务端Logstash,再重启客户端Logstash
6、重启MySQL服务,产生日志
7、Kibana创建新index

PWQza6.png

PWlSIK.png

PWl9PO.png

博主QQ:1012405802
技术交流QQ群:830339411
版权声明:网站内容有原创和转载,如有侵权,请联系删除,谢谢!!
感谢打赏,93bok因你们而精彩!!(支付宝支持花呗)
0%