elk配置三个中间的组件:elasticSearch、logstash、kibana

  1. elasticSearch是开源分布式的搜索引擎,主要负责搜索

  2. logstash对日志进行收集、过滤,并将其存储

  3. kibana作为elasticSearch和logstash的web界面,可以帮助汇总、分析和搜索重要的数据日志

  4. elasticSearch和logstash是java语言编写,而kibana使用node.js框架,在配置elk环境需要保证系统有jre环境

  5. 工作流程:通过logstash收集客户端APP的日志数据,将所有的日志过滤出来,存入Elasticsearch 搜索引擎里,然后通过Kibana GUI在WEB前端展示给用户,用户需要可以进行查看指定的日志内容。

  6. Logstash包含Index和Agent(shipper) ,Agent负责客户端监控和过滤日志,而Index负责收集日志并将日志交给ElasticSearch,ElasticSearch将日志存储本地,建立索引、提供搜索,kibana可以从ES集群中获取想要的日志信息。

实验步骤:

    1.     192.168.111.128  Elasticsearch

            192.168.111.129  Kibana

            192.168.111.130  Logstash   

wget   https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.0.tar.gz 

wget   https://artifacts.elastic.co/downloads/logstash/logstash-5.3.0.tar.gz 

wget   https://artifacts.elastic.co/downloads/kibana/kibana-5.3.0-linux-x86_64.tar.gz 

            128和130均需要安装java环境 

            export JAVA_HOME=/usr/java/jdk1.8.0_121

            export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

            export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin

            source    /etc/profile    //使环境变量立刻生效。  

            java    -version 

    2.  128环境配置

         tar xzf elasticsearch-5.3.0.tar.gz;

        mv elasticsearch-5.3.0 /usr/local/elasticsearch;

        设置监听地址为0.0.0.0vim /usr/local/elasticsearch/config/elasticsearch.yml

        (network.host:0.0.0.0   http.port:9200)

        因为elk不能使用root用户启动,所以添加一个普通用户

        useradd  elk;chown -R  elk:elk  /usr/local/elasticsearch;

        启动:su - elk;/usr/local/elasticsearch/bin/elasticsearch -d

        因为centos6.x系列版本问题,高版本会出现很多问题,解决如下:

        1.cent6不支持secComp,     设置   bootstrap.memory_lock: false

        2.内核参数设置:   vim /etc/security/limits.conf 

                    * soft nofile 65536

                    * hard nofile 65536

             vim /etc/security/limits.d/90-nproc.conf 

                    soft nproc 2048

            vi /etc/sysctl.conf

                    vm.max_map_count=262144

         3.syscrl -p 或者exit退出使生效

    3.elasticSearch插件的安装

  1. ES5.0之前老版本的head插件安装比较简单:cd /usr/local/elasticsearch;./bin/plugin  install mobz/elasticsearch-hea,访问http://192.168.111.128:9200/_plugin/head

  2. head是elasticsearch的集群管理工具,全完由H5编写,安装如下:

    1. yum -y install nodejs npm

    2. git clone https://github.com/mobz/elasticsearch-head.git

    3. cd elasticsearch-head/

    4. npm install

    5. 修改elasticsearch.yml文件,增加跨域的设置:

      1. http.cors.enabled: true

      2. http.cors.allow-origin: "*"

    6. 编辑head/Gruntfile.js,修改服务器监听地址

      1. connect: {

      2.         hostname: '*',

      3.         server: {

      4.                 options: {

      5.                         port: 9100,

      6.                         base: '.',

      7.                         keepalive: true

      8.                 }

      9.         }

      10. }

    7. 编辑head/_site/app.js,修改head连接es的地址;

      1. #将localhost修改为ES的IP地

    8.  启动Elasticsearch-head独立服务;

      1. cd elasticsearch-head/;nohup ./node_modules/grunt/bin/grunt server &

4、kibana的安装配置
  1. tar  -xzf  kibana-4.5.4-linux-x64.tar.gz;

  2. mv  kibana-4.5.4-linux-x64  /usr/local/kibana/;

  3. 修改kibana配置文件信息,设置ES地址:

  4. vim /usr/local/kibana/config/kibana.yml

  5. elasticsearch.url    修改为esIP

5、logstash安装配置



tar  xzf  logstash-5.3.0.tar.gzmv logstash-5.3.0 /usr/local/logstash/进入目录/usr/local/logstash/config/etc/:agent.conf文件内容:input {   file {       type => "nginx-access"       path => "/usr/local/nginx/logs/access.log"   }}output {    redis {        host => "localhost"        port => 6379        data_type => "list"        key => "logstash"    }}然后启动Agent:../bin/logstash  -f  agent.conf1) Redis数据-存入ES;index.conf文件内容:input {  redis {    host => "localhost"    port => "6379"    data_type => "list"    key => "logstash"    type => "redis-input"    batch_count => 1  }}output {  elasticsearch {    hosts => "192.168.111.128"  }}然后启动index:../bin/logstash  -f  index.con



至此完毕,由于浏览器问题没有插入图片,下次修改