elk

elk配置三個中間的組件:elasticSearch、logstash、kibana前端

  1. elasticSearch是開源分佈式的搜索引擎,主要負責搜索java

  2. logstash對日誌進行收集、過濾,並將其存儲node

  3. kibana做爲elasticSearch和logstash的web界面,能夠幫助彙總、分析和搜索重要的數據日誌linux

  4. elasticSearch和logstash是java語言編寫,而kibana使用node.js框架,在配置elk環境須要保證系統有jre環境nginx

  5. 工做流程:經過logstash收集客戶端APP的日誌數據,將全部的日誌過濾出來,存入Elasticsearch 搜索引擎裏,而後經過Kibana GUI在WEB前端展現給用戶,用戶須要能夠進行查看指定的日誌內容。git

  6. Logstash包含Index和Agent(shipper) ,Agent負責客戶端監控和過濾日誌,而Index負責收集日誌並將日誌交給ElasticSearch,ElasticSearch將日誌存儲本地,創建索引、提供搜索,kibana能夠從ES集羣中獲取想要的日誌信息。github

實驗步驟:web

    1.     192.168.111.128  Elasticsearchredis

            192.168.111.129  Kibananpm

            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 &

四、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

五、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



至此完畢,因爲瀏覽器問題沒有插入圖片,下次修改

相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息