本文地址 http://www.cnblogs.com/jasonxuli/p/6397244.html
 
https://www.elastic.co 上,elasticsearch,logstash (filebeat),kibana 都有各自的教程,基本照做就可以跑通。
但只是初步跑起来,如果要都作为服务运行,需要使用 rpm 包安装。
 
系统:
# cat /etc/issue
CentOS release 6.5 (Final)
 
ElasticSearch
 
安装后会创建用户 elasticsearch。
 
修改配置文件:
> vim /etc/elasticsearch/elasticsearch.yml

# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
# network.host: 127.0.0.1
network.host: 192.168.20.50
#
# Set a custom port for HTTP:
#
http.port: ... bootstrap.system_call_filter: false

!使用本地 IP(127.0.0.1)时,Elasticsearch 进入 dev mode,只能从本机访问,只显示警告。

!使用局域网IP后,可以从其他机器访问,但启动时进入 production mode,并进行 bootstrap check,有可能对不合适的系统参数报错。
例如:
ERROR: bootstrap checks failed
max file descriptors [] for elasticsearch process likely too low, increase to at least []
memory locking requested for elasticsearch process but memory is not locked
max number of threads [] for user [jason] likely too low, increase to at least []
max virtual memory areas vm.max_map_count [] likely too low, increase to at least []
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

需要针对这些参数进行设置:

> vim /etc/security/limits.conf
...
elasticsearch hard nofile # 针对 max file descriptors
elasticsearch soft nproc # 针对 max number of threads > vim /etc/sysctl.conf
...
vm.max_map_count= # 针对 max virtual memory areas > vim /etc/elasticsearch/elasticsearch.yml ...
bootstrap.system_call_filter: false # 针对 system call filters failed to install, 参见 https://www.elastic.co/guide/en/elasticsearch/reference/current/system-call-filter-check.html
memory locking 的问题似乎改了上面几个就没有出现了。
 
sudo chkconfig --add elasticsearch   # configure Elasticsearch to start automatically when the system boots up
sudo -i service elasticsearch start
sudo -i service elasticsearch stop

日志: /var/log/elasticsearch/

 
 
LogStash
 

安装: 
rpm -vi logstash-5.2..rpm

这个例子里使用 Filebeat 将测试用的 Apache web log 作为 logstash的输入,解析并写入数据到 ElasticSearch 中。

 
目前还不需要修改 logstash.yml,logstash 会读取 /etc/logstash/conf.d/ 目录下的文件作为 pipeline 配置文件。
 
新建 logstash pipeline 配置文件:
> vim /etc/logstash/conf.d/first-pipeline.conf

input {
beats {
port => ""
}
}
filter {
grok {
match => { "message" => "%{COMBINEDAPACHELOG}"}
}
geoip {
source => "clientip"
}
}
output {
elasticsearch {
hosts => [ "192.168.20.50:9200" ]
index => "testlog-%{+YYYY.MM.dd}"
}
}
 grok 可以解析未结构化的日志数据,Grok filter pattern 测试网站:http://grokdebug.herokuapp.com/
 
上述日志匹配模式为: 
%{COMBINEDAPACHELOG}
相当于:
%{IPORHOST:clientip} %{USER:ident} %{USER:auth}
\[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{NOTSPACE:request}
(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" %{NUMBER:response}
(?:%{NUMBER:bytes}|-) %{QS:referrer} %{QS:agent}

启动:

sudo initctl start logstash  // 作为服务运行,在使用Upstart的系统中
接下来需要安装 Filebeat 来作为 input 获取数据。
解压用 gzip -d logstash-tutorial.log.gz
 
Filebeat
The Beats are open source data shippers that you install as agents on your servers to send different types of operational data to Elasticsearch. Beats can send data directly to Elasticsearch or send it to Elasticsearch via Logstash, which you can use to parse and transform the data.
 
 
安装:
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.2.0-x86_64.rpm
sudo rpm -vi filebeat-5.2.-x86_64.rpm
配置:
> vim /etc/filebeat/filebeat.yml

filebeat.prospectors:

- input_type: log
paths:
- /var/log/logstash-tutorial.log # 之前下载的测试文件
#- /var/log/*.log
#- c:\programdata\elasticsearch\logs\* ... #----------------------------- Logstash output --------------------------------
output.logstash:
# The Logstash hosts
#hosts: ["localhost:5044"]
hosts: ["localhost:5043"]
rpm 安装、启动
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.2.0-x86_64.rpm
sudo rpm -vi filebeat-5.2.-x86_64.rpm
sudo /etc/init.d/filebeat start
kibana
 
kibana 5.2.0 要求 Elasticsearch 也为 5.2.0 。
 
修改配置:
> vim /etc/kibana/kibana.yml

server.host: "192.168.20.50"

elasticsearch.url: "http://192.168.20.50:9200"
> sudo chkconfig --add kibana   # 设置自动启动

> sudo -i service kibana start
> sudo -i service kibana stop
 
验证
 
1,检查 Elasticsearch 的索引:
http://192.168.20.50:9200/_cat/indices?v
 
2,根据之前 first-pipeline.conf 中的索引设置,创建出的索引应该是 testlog-2017.02.14,查询API为:
http://192.168.20.50:9200/testlog-2017.02.14/_search?
 
3,filebeat 第一次启动后应该会解析测试日志文件中的所有数据。
     之后可以添加新日志进去,然后刷新 ES 索引的url,看到该索引的 count 增加就说明解析新日志成功了。这个延迟大概几秒钟。
echo '1.1.1.3 - - [04/Jan/2015:05:13:42 +0000] "GET /test.png HTTP/1.1" 200 203023 "http://test.com/" "Mozilla/5.0"' >> /var/log/logstash-tutorial.log
 

ELK+Filebeat 安装配置入门的更多相关文章

  1. ELK 架构之 Logstash 和 Filebeat 安装配置

    上一篇:ELK 架构之 Elasticsearch 和 Kibana 安装配置 阅读目录: 1. 环境准备 2. 安装 Logstash 3. 配置 Logstash 4. Logstash 采集的日 ...

  2. ELK 架构之 Elasticsearch、Kibana、Logstash 和 Filebeat 安装配置汇总(6.2.4 版本)

    相关文章: ELK 架构之 Elasticsearch 和 Kibana 安装配置 ELK 架构之 Logstash 和 Filebeat 安装配置 ELK 架构之 Logstash 和 Filebe ...

  3. ELK 6安装配置 nginx日志收集 kabana汉化

    #ELK 6安装配置 nginx日志收集 kabana汉化 #环境 centos 7.4 ,ELK 6 ,单节点 #服务端 Logstash 收集,过滤 Elasticsearch 存储,索引日志 K ...

  4. FileBeat安装配置

    在ELK中因为logstash是在jvm上跑的,资源消耗比较大,对机器的要求比较高.而Filebeat是一个轻量级的logstash-forwarder,在服务器上安装后,Filebeat可以监控日志 ...

  5. elk集成安装配置

    三台虚拟机 193,194,195 本机 78 流程 pythonserver -> nginx -> logstash_shipper->kafka->logstash_in ...

  6. 转载maven安装,配置,入门

    转载:http://www.cnblogs.com/dcba1112/archive/2011/05/01/2033805.html 本书代码下载 大家可以从我的网站下载本书的代码:http://ww ...

  7. 第二篇:Filebeat 安装配置

    Filebeat 简介:Filebeat 是一款轻量型日志收集工具,可转发汇总日志.文件等内容.                         其主要特点为:1. 断点续传.(如遇日志转发过程中网络 ...

  8. Docker: 安装配置入门[二]

    一.安装配置启动 1.环境 [root@docker1 ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) [root@d ...

  9. Keepalived安装配置入门

    准备两台虚拟机,IP如下: A:192.168.1.11 B:192.168.1.12 A为Master,B为BackUp 1.安装 yum install keepalived -y 2.配置 A服 ...

随机推荐

  1. day9--paramiko模块

    志不坚者智不达 paramiko:在Linux链接其他机器,每台Linux机器都有一个SSHClient:Python自己也写了一个SSHClient,那么Python写paramiko创建SSHCl ...

  2. hdoj2955 Robberies(01背包)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2955 题意 有n家银行,每家银行有两个属性:钱数m,概率p,p表示抢这家银行被逮着的概率.有一个人想抢 ...

  3. EcOS安装

    从ubuntu 拷贝到 centos cd /media ls cd ./sf_EcOS 这个目录就是共享目录,名字可能不一样 cp -r studio.zip /home/ 1. 查看版本 cent ...

  4. 关于ecshop的mobile里user.php登录和注册验证码不显示

    在做ecshop模板的时候由于user.php里的登录和注册是在一个页面里切换的,这就致使这里的登录和注册里的验证码不显示 找到mobile/themesmobile/ecshoptemplate_m ...

  5. tensorflow初始化参数内存占满问题

    最近使用tensorflow构建了一个浅层的网络,初始化参数的时候发现两个1080ti 22G的显存马上占满 后来发现解决办法为:在创建session的时候把显存设置为自适应即可,如下 config ...

  6. 查看shell 版本

    cat /etc/shells 查看本机支持的解释器: echo $SHELL 当我们直接使用./a.sh来执行这个脚本的时候,如果没有shebang,那么它就会默认用$SHELL指定的解释器,否则就 ...

  7. Python2字符编码问题汇总

    目录 从字符编码说起 unicode与utf-8 当编解码遇上Python2.x unicode 与 str 区别 __str__ __repr__的区别 unicode str utf-8关系 un ...

  8. [ 原创 ]学习笔记-Android 学习笔记 Contacts (一)ContentResolver query 参数详解 [转载]

    此博文转载自:http://blog.csdn.net/wssiqi/article/details/8132603 1.获取联系人姓名 一个简单的例子,这个函数获取设备上所有的联系人ID和联系人NA ...

  9. leetcode 奇偶链表 python

    要求空间复杂度O(1) 那就只能用指针不断改链表的指针, 不能建立新的内存 时间复杂度O(1) 一遍遍历 不能嵌套循环 我的思想是: 1 如果链表元素数量小于等于2个,那就无法操作 2 能操作的情况下 ...

  10. HDU 3949 XOR 线性基

    http://acm.hdu.edu.cn/showproblem.php?pid=3949 求异或第k小,结论是第k小就是 k二进制的第i位为1就把i位的线性基异或上去. 但是这道题和上一道线性基不 ...