本次安装是使用的是ELK5.0 版本,即ElasticSearch5.0, Logstash5.0, Kibana5.0.

j_0057.gif


1,确认JDK版本

JDK的安装这里我们就不说了,直接确认我们的版本,这里我们用的是JDK1.8

alvin@iZ28a8qlufiZ:~$ java -version

java version "1.8.0_101"

Java(TM) SE Runtime Environment (build1.8.0_101-b13)

Java HotSpot(TM) 64-Bit Server VM (build25.101-b13, mixed mode)

2,安装ElasticSearch

alvin@iZ28a8qlufiZ:~$ tar xfelasticsearch-5.0.0.tar.gz -C /opt/

alvin@iZ28a8qlufiZ:~$ cd/opt/elasticsearch-5.0.0/

 

修改配置文件为我们指定的内容。

alvin@iZ28a8qlufiZ:/opt/elasticsearch-5.0.0$vim config/elasticsearch.yml

node.name: 10.144.163.187
path.data: /tmp/elasticsearch/data
path.logs: /tmp/elasticsearch/logs
network.host: 10.144.163.187
http.port: 9200


配置相关系统信息。

alvin@iZ28a8qlufiZ:/opt/elasticsearch-5.0.0$sudo vim /etc/sysctl.conf

vm.max_map_count=262144


alvin@iZ28a8qlufiZ:/opt/elasticsearch-5.0.0$sudo sysctl -p

 

alvin@iZ28a8qlufiZ:/opt/elasticsearch-5.0.0$sudo vim  /etc/security/limits.conf

* soft nofile 65536
* hard nofile 65536


alvin@iZ28a8qlufiZ:/opt/elasticsearch-5.0.0$bin/elasticsearch

                   

alvin@iZ28a8qlufiZ:/opt/elasticsearch-5.0.0$bin/elasticsearch > nohup &

3,安装Logstash

#logstash 会使用大约400M物理内存

 

alvin@iZ28a8qlufiZ:~$ tar xflogstash-5.0.0.shenmin.tar.gz -C /opt/

alvin@iZ28a8qlufiZ:~$ cd/opt/logstash-5.0.0/

alvin@iZ28a8qlufiZ:/opt/logstash-5.0.0$ vimshenmin.conf

input {
      file {
               path =>["/opt/apache-tomcat-7.0.55/logs/catalina.out"]
      }
}
filter {
      if ([message] !~ "ERROR|Exception|exception"){
               drop {}
       }
}
output {
elasticsearch { hosts => ["xxx.xx.xx.xx:9200"]}
stdout { codec => rubydebug }
email {
      from => "[email protected]"
      to => "[email protected]"
      via => "smtp"
      port => 25
      subject => "xxx服务器日志发现异常!"
      address => "smtp.exmail.qq.com"
      domain => "smtp.exmail.qq.com"
      username => "[email protected]"
      password => "emailpassword"
      body => " Host:xxx.xx.xx.xx\n Time:%{@timestamp}\n Path:%{path}\n Message:%{message}"
}
}


alvin@iZ28a8qlufiZ:/opt/logstash-5.0.0$./bin/logstash -f shenmin.conf

 

alvin@iZ28a8qlufiZ:/opt/logstash-5.0.0$./bin/logstash -f shenmin.conf > nohup &


4,安装kibana

alvin@iZ28a8qlufiZ:~$ tar xfkibana-5.0.0-linux-x86_64.tar.gz -C /opt/

 

alvin@iZ28a8qlufiZ:~$ cd/opt/kibana-5.0.0-linux-x86_64/

alvin@iZ28a8qlufiZ:/opt/kibana-5.0.0-linux-x86_64$vim config/kibana.yml

server.host: "xx.xx.xxx.xxx"
elasticsearch.url: "http://xx.xx.xxx.xxx:9200"


alvin@iZ28a8qlufiZ:/opt/kibana-5.0.0-linux-x86_64$./bin/kibana

#这个时候,我们可以看到打印出来的一些kibana启动信息,如果没有报错的话,那么就可以放到后台去运行了。

alvin@iZ28a8qlufiZ:/opt/kibana-5.0.0-linux-x86_64$./bin/kibana > nohup &

 

然后,就可以在浏览器里打开http://xx.xx.xxx.xxx:5601 查看kibana web界面了。