Elastic Stack产品

开源的 Elastic Stack能够安全可靠地获取任何来源、任何格式的数据,并且能够实时地对数据进行搜索、分析和可视化。


一、elasticsearch安装

ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。


安装下载elasticsearch部署包

https://www.elastic.co/cn/downloads/elasticsearch


解压,修改配置文件elasticsearch.yml,修改访问地址

network.host: 172.26.127.72


修改配置文件jvm.yml可以修改内存占用大小

启动elasticsearch: ./elasticsearch


二、kibana安装

Kibana是一个开源的分析与可视化平台,设计出来用于和Elasticsearch一起使用的。你可以用kibana搜索、查看、交互存放在Elasticsearch索引里的数据,使用各种不同的图表、表格、地图等kibana能够很轻易地展示高级数据分析与可视化。

Kibana让我们理解大量数据变得很容易。它简单、基于浏览器的接口使你能快速创建和分享实时展现Elasticsearch查询变化的动态仪表盘。安装Kibana非常快,你可以在几分钟之内安装和开始探索你的Elasticsearch索引数据,不需要写任何代码,没有其他基础软件依赖。


安装下载kibana部署包

https://www.elastic.co/cn/downloads/kibana


解压,修改配置文件kibana.yml,修改访问地址


server.port: 5601

server.host: "172.26.127.72"

elasticsearch.url: "http://172.26.127.72:9200"


启动kibana: ./kibana


三、Beats介绍

Beats 是数据采集的得力工具。将这些采集器安装在您的服务器中,它们就会把数据汇总到 Elasticsearch。如果需要更加强大的处理性能,Beats 还能将数据输送到 Logstash 进行转换和解析。


四、filebeat安装

当您要面对成百上千、甚至成千上万的服务器、虚拟机和容器生成的日志时,请告别 SSH 吧。Filebeat 将为您提供一种轻量型方法,用于转发和汇总日志与文件,让简单的事情不再繁杂。


安装下载filebeat部署包

 https://www.elastic.co/cn/downloads/beats


解压,修改配置文件filebeat.yml


#设置filebeat到kibana
./filebeat setup --dashboards
#启动测试脚本
./filebeat -e -c filebeat.yml -d "publish"  ;测试完成,CRTL+C即可结束
#后台正式启动基本
nohup ./filebeat -e -c filebeat.yml >/dev/null 2>&1 &
#删除运行数据
curl -XDELETE 'http://127.0.0.1:9200/filebeat-*'


关键配置

#=========================== Filebeat prospectors =============================

filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.

- type: log
  # Change to true to enable this prospector configuration.
  enabled: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    #- /var/log/*.log
    - /home/demo/logs/*.log

    #- c:\programdata\elasticsearch\logs\*

#==================== Elasticsearch template setting ==========================

setup.template.settings:
  index.number_of_shards: 3
  #index.codec: best_compression
  #_source.enabled: false

output.elasticsearch.index: "filebeat-%{[beat.version]}-%{+yyyy.MM.dd}"
setup.template.name: "filebeat"
setup.template.pattern: "filebeat-*"
setup.dashboards.index: "filebeat-*"
setup.template.overwrite: true

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  host: "127.0.0.1:5601"

#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["127.0.0.1:9200"]
  #index: "filebeat-%{[beat.version]}-%{+yyyy.MM.dd}"

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  #username: "elastic"
  #password: "changeme"


五、Metricbeat安装

用于从系统和服务收集指标。从 CPU 到内存,从 Redis 到 Nginx,Metricbeat 能够以一种轻量型的方式,输送各种系统和服务统计数据。


安装下载metricbeat部署包

https://www.elastic.co/cn/downloads/beats


解压,修改配置文件metricbeat.yml


#设置metricbeat到kibana
./metricbeat setup --dashboards
#启动测试脚本
./metricbeat -e -c metricbeat.yml -d "publish"  ;测试完成,CRTL+C即可结束
#后台正式启动基本
nohup ./metricbeat -e -c metricbeat.yml >/dev/null 2>&1 &
#删除运行数据
curl -XDELETE 'http://127.0.0.1:9200/metricbeat-*'


关键配置:

#==================== Elasticsearch template setting ==========================

setup.template.settings:
  index.number_of_shards: 1
  index.codec: best_compression
  #_source.enabled: false

output.elasticsearch.index: "metricbeat-%{[beat.version]}-%{+yyyy.MM.dd}"
setup.template.name: "metricbeat"
setup.template.pattern: "metricbeat-*"
setup.dashboards.index: "metricbeat-*"
setup.template.overwrite: true

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  host: "127.0.0.1:5601"

#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["127.0.0.1:9200"]

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  #username: "elastic"
  #password: "changeme"


没有登录不能评论