ELK 实时日志分析系统平台的学习与使用
- ElasticSearch
- Logstash
- Kibana
- Marvel
- Log
- Linux
简介
工作工程中,不论是开发还是运维,都会遇到各种各样的日志,主要包括系统日志、应用程序日志和安全日志,对于开发人员来说,查看日志,可以实时查看程序的运行错误,以及性能分析,通常,一个大中型的应用程序会被部署到多台服务器,那日志文件也会分散到不同的机器上,这样查看日志难道要一台一台去查看?显然是太麻烦了,开源的日志分析系统 ELK 完美的解决了这个问题。
ELK 并不是一个独立的系统,她是由 ElasticSearch、Logstash、Kibana 三个开源的工具组成。
ElasticSearch
ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。
Logstash
Logstash 是一个开源的日志分析、收集工具,并将日志存储以供以后使用。
Kibana
Kibana 是一个为 Logstash 和 ElasticSearch 提供的日志分析的 Web 接口。可使用它对日志进行高效的搜索、可视化、分析等各种操作。
搭建方法
基于一台主机的搭建,没有使用多台集群,logstah 收集日志后直接写入 elasticseach,可以用 redis 来作为日志队列
jdk 安装
jdk 1.8 安装
elasticseach 安装
下载地址:https://www.elastic.co/downloads,选择相应的版本
我这里的版本是 elasticsearch-2.4.0解压目录:
[phachon@localhost elk]$ tar -zxf elasticsearch-2.4.0 [phachon@localhost elasticsearch-2.4.0]$
安装 head 插件
[phachon@localhost elasticsearch-2.4.0]$./bin/plugin install mobz/elasticsearch-head [phachon@localhost elasticsearch-2.4.0]$ ls plugins/ head
编辑 elasticseach 的配置文件
[phachon@localhost elasticsearch-2.4.0]$ vim config/elasticseach.yml 13# ---------------------------------- Cluster ----------------------------------- 14 # 15 # Use a descriptive name for your cluster: 16 # 17 cluster.name: es_cluster #这里是你的el集群的名称 18 # 19 # ------------------------------------ Node ------------------------------------ 20 # 21 # Use a descriptive name for the node: 22 # 23 node.name: node0 # elseach 集群中的节点 24 # 25 # Add custom attributes to the node: 26 # 27 # node.rack: r1 28 # 29 # ----------------------------------- Paths ------------------------------------ 30 # 31 # Path to directory where to store the data (separate multiple locations by comma): 32 # 33 path.data: /tmp/elasticseach/data #设置 data 目录 34 # 35 # Path to log files: 36 # 37 path.logs: /tmp/elasticseach/logs # 设置 logs 目录 # 39 # ----------------------------------- Memory ----------------------------------- 40 # 41 # Lock the memory on startup: 42 # 43 # bootstrap.memory_lock: true 44 # 45 # Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory 46 # available on the system and that the owner of the process is allowed to use this limit. 47 # 48 # Elasticsearch performs poorly when the system is swapping the memory. 49 # 50 # ---------------------------------- Network ----------------------------------- 51 # 52 # Set the bind address to a specific IP (IPv4 or IPv6): 53 # 54 # network.host: 192.168.0.1 55 network.host: 192.168.30.128 # 这里配置本机的 ip 地址,这个是我的虚拟机的 ip 56 # 57 # Set a custom port for HTTP: 58 # 59 http.port: 9200 # 默认的端口
其他配置可先不设置
启动 elstaicse