参考:https://www.elastic.co/guide/en/logstash/current/installing-logstash.html
一、下载安装jdk (要求java 8 ,不支持java 9,如果之前已安装非java 8 版本的,需要删除,如yum groupremove java)
cd /data/soft/
wget –no-check-certificate –no-cookies –header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.tar.gz
tar zvxf jdk-8u112-linux-x64.tar.gz
ln -s /data/soft/jdk1.8.0_112 /data/soft/jdk
vi /etc/profile.d/java.sh #新建登陆加载项
JAVA_HOME=/data/soft/jdk/ PATH=$JAVA_HOME/bin:$PATH CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME export PATH export CLASSPATH
重新连接后确认java版本
java -version
二、安装elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.zip
unzip elasticsearch-5.4.0.zip
chown Linuxuser.Linuxuser -R elasticsearch-5.4.0 (不允许用root 运行,所以改成普通用户)
su – Linuxuser
cd elasticsearch-5.4.0/bin
./elasticsearch
三、安装filebeat,用于读取日志文件并传给logstash
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.4.0-x86_64.rpm
rpm -vi filebeat-5.4.0-x86_64.rpm
下载日志样本:
wget https://download.elastic.co/demos/logstash/gettingstarted/logstash-tutorial.log.gz
修改配置:
vim /etc/filebeat/filebeat.yml
filebeat.prospectors:
– input_type: log
paths:
– /data/soft/logstash-5.4.0/logstash-tutorial.log
output.logstash:
hosts: ["localhost:5043"]
启动:
/usr/share/filebeat/bin/filebeat -e -c /etc/filebeat/filebeat.yml -d "publish"
四、安装logstash
wget https://artifacts.elastic.co/downloads/logstash/logstash-5.4.0.zip
unzip logstash-5.4.0.zip
cd logstash-5.4.0
vim first-pipeline.conf #控制台输出
input {
beats {
port => "5043"
}}
filter {
grok {
match => { "message" => "%{COMBINEDAPACHELOG}"}
}
geoip {
source => "clientip"
}}
output {
stdout { codec => rubydebug }}
bin/logstash -f first-pipeline.conf –config.test_and_exit #进行配置测试
bin/logstash -f first-pipeline.conf –config.reload.automatic #启动,添加参数以使得配置更改时自动重新加载
删除第三步filebeat的注册文件,并重新启动
rm /usr/share/filebeat/bin/data/registry
/usr/share/filebeat/bin/filebeat -e -c /etc/filebeat/filebeat.yml -d "publish"
vim first-pipeline.conf #使用elasticsearch接收
input {
beats {
port => "5043"
}}
filter {
grok {
match => { "message" => "%{COMBINEDAPACHELOG}"}
}
geoip {
source => "clientip"
}}
output {
elasticsearch {
hosts => [ "localhost:9200" ]
}}
删除第三步filebeat的注册文件,并重新启动
rm /usr/share/filebeat/bin/data/registry
/usr/share/filebeat/bin/filebeat -e -c/etc/filebeat/filebeat.yml -d "publish"
五、安装kibana
wget https://artifacts.elastic.co/downloads/kibana/kibana-5.4.0-linux-x86_64.tar.gz
tar zvxf kibana-5.4.0-linux-x86_64.tar.gz
cd kibana-5.4.0-linux-x86_64
vim config/kibana.yml #修改配置:
server.host: "0.0.0.0" #默认只监控127.0.0.1,这里改成监听所有
启动服务:
bin/kibana
此时就要以通过浏览器访问:http://0.0.0.0:5601
首次访问时会跳转配置页面,直接确认即可(logstash-*)
进行可视化图表配置测试:
点击左侧栏“Visualize”,选择右上角的时间为“Today”,如下图进行配置,并右击“Save”
原文出自:
http://blog.too2.net/?p=349
转载请注明转自:辛碌力成【http://blog.too2.net】
💡 ➡ 😐 😥
❓