要432w 发表于 2017-3-21 13:40:27

ELK 5.0部署安装

版本说明:

Elasticsearch 5.0
Logstash 5.0(暂时未用)
Filebeat 5.0
Kibana 5.0

ELK是一套采集日志并进行清洗分析的系统,由于目前的分析的需求较弱,所以仅仅采用filebeat做日志采集,没有使用logstash

一、环境准备&&软件安装:
1、首先,需要安装Java环境
    下载安装包:jre-8u111-linux-x64.rpm
    安装:yum install jre-8u111-linux-x64.rpm

2、 新建一个用户,elsearch,用来启动elasticsearch,因为该软件必须用普通用户启动。
    useradd elsearch

3、修改变量参数:否则启动elasticsearch会报bootstrap错误。

1
   1、ulimit -u 10240#





1
   2、vim /etc/sysctl.conf





1
2
   vm.max_map_count = 655360
   sysctl -p





1
   3、vim /etc/security/limits.conf





1
2
3
4
    *      soft    noproc 65536
    *      hard    noproc 65536
    *      soft    nofile 65536
    *      hard    nofile 65536





4、软件安装
   安装包下载地址:https://www.elastic.co/downloads
   使用的是绿色安装包,解压即用。
   1、filebeat安装

1
2
   tar -xvf filebeat-5.0.0-linux-x86_64.tar.gz
   cp filebeat-5.0.0-linux-x86_64 /usr/local/filebeat -r




   2、kibana安装

1
2
   tar -xvf kibana-5.0.0-linux-x86_64.tar.gz
   cp kibana-5.0.0-linux-x86_64 /usr/local/kibana -r




   3、logstash安装(暂时未用)

1
2
   tar -xvf logstash-5.0.0.tar.gz
   cp logstash-5.0.0 /usr/local/logstash -r




   4、elasticsearch安装

1
2
   unzip elasticsearch-5.0.0.zip
   cp elasticsearch-5.0.0 /usr/local/elasticsearch -r





二、配置&&启动
1、启动elasticsearch

1
2
3
4
   cd /usr/local/
   chown -R elsearch:elsearch elasticsearch 将权限给elsearch用户
   su elsearch
   cd /usr/local/elasticsearch





   修改配置文件如下:

1
   cat config/elasticsearch.yml |grep -v "#"





1
2
3
4
   path.data: /usr/local/elasticsearch/data
   path.logs: /usr/local/elasticsearch/logs
   network.host: 192.168.221.30
   http.port: 9200





   启动:

1
2
   cd /usr/local/elasticsearch/bin
   ./elasticsearch   #使用-d参数,放到后台执行








   查看启动情况:

1
   # lsof -i:9200





1
2
   COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
   java    29987 elsearch237uIPv6 470519   0t0TCP 192.168.221.30:wap-wsp





   在浏览器中查看:
   输入:192.168.221.30:9200
   能看到类似信息则启动成功:

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"name" : "FrmZoqD",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "IcATEXFBQkGsZdh4P_TiTw",
"version" : {
    "number" : "5.0.0",
    "build_hash" : "253032b",
    "build_date" : "2016-10-26T04:37:51.531Z",
    "build_snapshot" : false,
    "lucene_version" : "6.2.0"
},
"tagline" : "You Know, for Search"
}




注意本机防火墙要关掉。

2、配置&&启动filebeat

   修改配置文件:


1
   cd /usr/local/filebeat





1
   cp filebeat.yml filebeat.yml.default





1
2
3
4
5
6
7
8
9
10
      vim filebeat.yml
      filebeat.prospectors:
      - input_type: log
       paths:
         - /var/log/messages
      document_type: "messages"

      output.elasticsearch:
      hosts: ["192.168.221.30:9200"]#filebeat传到Elasticsearch
      index: filebeat-%{+yyyy.MM.dd}#这里的索引index会跟kibana的索引有关系





1
   touch /var/log/test.log#测试日志文件




   启动:

1
   ./filebeat -e -c filebeat.yml -d "publish"




测试

   输入一条语句进行测试

1
   echo "hello,test" >test.log




https://s4.iyunv.com/wyfs02/M02/8E/E9/wKioL1jPSsSw1UEUAABPtsGSOFI790.png
   能看到beat已经将输入的log采集到了。

   将filebeat放入后台执行:


1
   nohup./filebeat -e -c filebeat.yml >>/dev/null 2>&1 &






3、配置&&启动kibana
   修改配置:

1
   cd /usr/local/kibana





1
   vim config/kibana.yml





1
2
3
   server.port: 5601
   server.host: "27.131.221.30"
   elasticsearch.url: "http://27.131.221.30:9200"




修改以上三项。
   启动动服务:

1
2
   cd /usr/local/kibana/bin/
   ./kibana





如果都配置正确的话,会进入到kibana的页面,刚开始会让你配置一个index索引
这条索引跟我们上面filebeat里面配置的索引有关。
filebeat-*
*就是时间格式,我们是按照时间来进行索引的。
如果是用logstash进行采集数据的话,那么索引就是logstash-*
当然,我们也可以配置多条索引,例如我们同时用filebeat和logstash进行采集不同的业务日志。
最终的形式应该是这样的:


zjx1984 发表于 2017-4-22 21:47:53

看过之后感觉非常清晰
页: [1]
查看完整版本: ELK 5.0部署安装