ELK(ElasticSearch, Logstash, Kibana)搭建实时日志分析平台

来源:互联网 发布:网络监控工作的短板 编辑:程序博客网 时间:2024/05/22 00:00

原文网址: http://www.tuicool.com/articles/YR7RRr     http://www.importnew.com/20464.html


此文是根据上面链接进行整理(就是做个笔记)而来,采用的也是相对比较新的版本,跟链接里面的有所不同,另:笔记可能比较简单、粗暴。想要比较仔细的文章请鼠标往上一行--》左移--》点击鼠标左键

一  系统环境要求

        kernel 3.2 或及以上

        java openjdk version "1.8.0_111" 或最新版java

        elasticsearch 2.4.1

        logstash        2.4.0

        Kibana           4.6.1

       注:下载网站:https://www.elastic.co/downloads

二  配置

      1.  配置 elasticsearch:

          tar -xvf elasticsearch-2.4.1.tar.gz

         cd elasticsearch

          安装head插件(可以从浏览器查看集群状态,doc内容,搜索等)

           ./bin/plugin install mobz/elasticsearch-head

          编辑es的配置文件

         vim config/elasticsearch.yml

                  cluster.name=es_cluster
                  node.name=node0
                  path.data=/tmp/elasticsearch/data         #没有此目录需新建或者其他目录或系统默认
                  path.logs=/tmp/elasticsearch/logs         #同上
                  #当前hostname或IP
                  network.host=bogon
                  network.port=9200

           :wq                    #保存退出

            启动

            ./bin/elasticsearch

            若启动失败:先 chmod 757 -R elashticsearch  再切换到其他用户再执行

          ctl + c 停止    ./bin/elasticsearch &    后台启动

          打开浏览器 输入   localhost:9200  

          

{  "name" : "node0",  "cluster_name" : "es_cluster",  "cluster_uuid" : "*****************",  "version" : {    "number" : "2.4.1",    "build_hash" : "******************************",    "build_timestamp" : "2016-09-27T18:57:55Z",    "build_snapshot" : false,    "lucene_version" : "5.5.2"  },  "tagline" : "You Know, for Search"}
       也可以这样:http://IP:9200/_plugin/head/      通过head查看ES集群状态

      2. 配置logstash

          tar -xvf logstash-2.4.0

          cd logstash

         新建编辑配置文件(名称任意以apache为例,搜索的为apache的访问日志)

         vim httpd.conf

               input {
    file {
        path => "/var/log/httpd/access_log"
        start_position => beginning
        ignore_older => 0
    }
}
filter {
    grok {
        match => { "message" => "%{COMBINEDAPACHELOG}"}
    }
    geoip {
        source => "clientip"
    }
}
output {
    elasticsearch {
        action => "index"
        hosts => [ "bogon:9200" ]
        index => "httpdlog"
    }
}

启动   -f  指定配置文件

  ./bin/logstash -f httpd.conf


3. 配置kibana

    tar -xvf kibana-4.6.1

    cd kibana-4.6.1

      vim config/kibana.yml

      server.port: 5601

      server.host: "bogon"

      elasticsearch.url: http://bogon:9200

      kibana.indx: ".kibana"


     启动

     ./bin/kibana


     浏览器打开:localhost:5601

      剩下的其他步骤请参考文章顶部链接 :) 

      如有其他错误恳请指出

0 0
原创粉丝点击