相关文章:

之前安装 ELK 的版本是 5.6.9,而且使用yum命令安装的,这边用最新版本 6.2.4 重新再安装一遍,不再使用yum命令安装,而是直接下载tar.gz包,解压执行命令运行。

ELK Stach 包地址:https://www.elastic.co/downloads/past-releases

1. Elasticsearch

之前 Elasticsearch 运行在 root 命令下,因为 Elasticsearch 运行会接受脚本,所以为了安全,正式环境要用非 root 账户进行运行。

创建用户组及用户:

[root@node1 ~]# groupadd es &&
useradd es -g es

切换到 es 用户:

[root@node1 ~]# su es

下载 Elasticsearch 包并解压:

[es@node1 ~]# cd /home/es
[es@node1 es]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz
tar -zvxf elasticsearch-6.2.4.tar.gz

编辑配置文件:

[es@node1 es]# vi /home/es/elasticsearch-6.2.4/config/elasticsearch.yml

network.host: node1
http.port: 9200

启动 Elasticsearch:

[es@node1 es]# cd bin
[es@node1 es]# ./elasticsearch

出现下面错误:

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

解决方案,切换到 root 用户,并在/etc/security/limits.conf中添加配置:

[es@node1 es]# su root
[root@node1 ~]# vi /etc/security/limits.conf * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096

然后切换到 es 用户,后台启动 Elasticsearch:

[es@node1 ~]# cd /home/es/elasticsearch-6.2.4/bin
[es@node1 es]# ./elasticsearch -d

查看 Elasticsearch 运行是否正常:

[es@node1 es]# curl http://node1:9200/
{
"name" : "rK2jCU6",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "m6_Ijnd3Qki3HN20S-Bajg",
"version" : {
"number" : "6.2.4",
"build_hash" : "ccec39f",
"build_date" : "2018-04-12T20:37:28.497551Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

2. Kibana

下载 Kibana 包并解压:

[root@node1 ~]# mkdir software && cd software
[root@node1 software]# wget https://artifacts.elastic.co/downloads/kibana/kibana-6.2.4.tar.gz
[root@node1 software]# tar -zvxf kibana-6.2.4-linux-x86_64.tar.gz

编辑配置文件:

[root@node1 software]# vi /software/kibana-6.2.4-linux-x86_64/config/kibana.yml

# Kibana is served by a back end server. This setting specifies the port to use.
server.port: 5601 # Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
server.host: "192.168.0.11" # The Kibana server's name. This is used for display purposes.
server.name: "kibana-server" # The URL of the Elasticsearch instance to use for all your queries.
elasticsearch.url: "http://node1:9200"

后台运行 Kibana:

[root@node1 software]# cd /software/kibana-6.2.4-linux-x86_64/bin
[root@node1 software]# nohup ./kibana &

浏览器访问:http://node1:5601/

3. Logstash

下载 Logstash 包并解压:

[root@node1 software]# wget https://artifacts.elastic.co/downloads/logstash/logstash-6.2.4.tar.gz
[root@node1 software]# tar -zvxf logstash-6.2.4.tar.gz

创建logstash.conf配置文件:

[root@node1 software]# mkdir /software/logstash-6.2.4/conf.d
[root@node1 software]# vi /software/logstash-6.2.4/conf.d/logstash.conf

添加下面配置内容:

input {
beats {
port => 10515
}
}
filter {
if [fields][logtype] == "syslog" {
grok {
match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{host}" ]
}
syslog_pri { }
date {
match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
}
}
if [fields][logtype] == "spring-boot-log4j2" {
json {
source => "message"
target => "data"
}
}
}
output {
if [fields][logtype] == "spring-boot-log4j2"{
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "spring-boot-log4j2-%{+YYYY.MM.dd}"
}
} if [fields][logtype] == "syslog"{
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "filebeat-%{+YYYY.MM.dd}"
}
}
}

后台启动 Logstash:

[root@node1 software]# cd /software/logstash-6.2.4/bin
[root@node1 bin]# nohup ./logstash -f ../conf.d/logstash.conf &

查看端口是否被监听:

[root@node1 bin]# netstat -lntp |grep 10515
tcp6 0 0 :::10515 :::* LISTEN 28934/java

4. Filebeat

下载 Filebeat 包并解压:

[root@node1 software]# wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.2.4-linux-x86_64.tar.gz
[root@node1 software]# tar -zvxf filebeat-6.2.4-linux-x86_64.tar.gz

编辑配置文件:

[root@node1 software]# vi /software/filebeat-6.2.4-linux-x86_64/filebeat.yml

添加如下配置内容:

filebeat.prospectors:
- input_type: log
paths:
- /var/log/spring-boot-log4j2/*.log
document_type: "spring-boot-log4j2" # 定义写入 ES 时的 _type 值
multiline:
#pattern: '^\s*(\d{4}|\d{2})\-(\d{2}|[a-zA-Z]{3})\-(\d{2}|\d{4})' # 指定匹配的表达式(匹配以 2017-11-15 08:04:23:889 时间格式开头的字符串)
pattern: '^\s*("{)' # 指定匹配的表达式(匹配以 "{ 开头的字符串)
negate: true # 是否匹配到
match: after # 合并到上一行的末尾
max_lines: 1000 # 最大的行数
timeout: 30s # 如果在规定的时候没有新的日志事件就不等待后面的日志
fields:
logsource: node1
logtype: spring-boot-log4j2 - input_type: log
paths:
- /var/log/messages
#- /var/log/*.log
document_type: "syslog" # 定义写入 ES 时的 _type 值
fields:
logsource: node1
logtype: syslog #output.elasticsearch:
#hosts: ["node1:9200"] output.logstash:
hosts: ["node1:10515"]

后台启动 Filebeat:

[root@node1 software]# cd /software/filebeat-6.2.4-linux-x86_64
[root@node1 bin]# nohup ./filebeat -e -c filebeat.yml &

关于 ELK 集成 Spring Boot Log4j2,可以查看下之前的文章。

参考资料:

ELK 架构之 Elasticsearch、Kibana、Logstash 和 Filebeat 安装配置汇总(6.2.4 版本)的更多相关文章

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

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

  2. Docker安装部署ELK教程(Elasticsearch+Kibana+Logstash+Filebeat)

    Elasticsearch 是个开源分布式搜索引擎,它的特点有:分布式,零配置,自动发现,索引自动分片,索引副本机制,restful风格接口,多数据源,自动搜索负载等. Logstash 是一个完全开 ...

  3. ELK 架构之 Elasticsearch 和 Kibana 安装配置

    阅读目录: 1. ELK Stack 简介 2. 环境准备 3. 安装 Elasticsearch 4. 安装 Kibana 5. Kibana 使用 6. Elasticsearch 命令 最近在开 ...

  4. ELK(elasticsearch+kibana+logstash)搜索引擎(一): 环境搭建

    1.ELK简介 这里简单介绍一下elk架构中的各个组件,关于elk的详细介绍的请自行百度 Elasticsearch是个开源分布式搜索引擎,是整个ELK架构的核心 Logstash可以对数据进行收集. ...

  5. 【ELK】【docker】【elasticsearch】2.使用elasticSearch+kibana+logstash+ik分词器+pinyin分词器+繁简体转化分词器 6.5.4 启动 ELK+logstash概念描述

    官网地址:https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-cli-run-prod ...

  6. ELK(elasticsearch+kibana+logstash)搜索引擎(二): elasticsearch基础教程

    1.elasticsearch的结构 首先elasticsearch目前的结构为 /index/type/id  id对应的就是存储的文档ID,elasticsearch一般将数据以JSON格式存储. ...

  7. elasticsearch kibana logstash(ELK)的安装集成应用

    官网关于kibana的学习指导网址是:https://www.elastic.co/guide/en/kibana/current/index.html Kibana是一个开源的分析和可视化平台,设计 ...

  8. Elasticsearch,Kibana,Logstash,NLog实现ASP.NET Core 分布式日志系统

    Elasticsearch - 简介 Elasticsearch 作为核心的部分,是一个具有强大索引功能的文档存储库,并且可以通过 REST API 来搜索数据.它使用 Java 编写,基于 Apac ...

  9. Elasticsearch+Kibana+Logstash安装

    安装环境: [root@node- src]# cat /etc/redhat-release CentOS Linux release (Core) 安装之前关闭防火墙 firewalld 和 se ...

随机推荐

  1. Bash里面如何返回绝对路径

    1.返回当前目录的绝对路径: basepath=$(cd `dirname $0`; pwd) echo $basepath 2.返回当前路径的上一级目录: xp_path=`dirname &quo ...

  2. Android优秀github项目整理

    1.照相选相册,裁剪的 library TakePhotohttps://github.com/crazycodeboy/TakePhoto 2几行代码快速集成二维码扫描功能https://githu ...

  3. 解决ubuntu unity下gvim菜单消失的问题

    #问题描述:在终端下用gvim 指令打开 gvim就不显示菜单.在不启用unity的桌面环境下用终端打开gvim是有菜单的.从程序菜单中打开gvim是显示菜单的.用sudo打开gvim也可以显示菜单, ...

  4. linux下安装apc

    wget htdtp://pecl.php.net/get/APC tar zxvf APC-3.1.3p.tgz cd APC-3.1.3p /usr/local/php/bin/phpize ./ ...

  5. memcached usage

    https://github.com/ragnor/simple-spring-memcached/wiki/Getting-Started 1) maven <dependency> & ...

  6. 为什么在JDBC要使用Class.forName();这句话

    为什么在调用JDBC的时候,我们总要写这句话:Class.forName("驱动类");解释:在JDBC编程中一般有以下几个步骤:1>加载驱动,也就是Class.forNam ...

  7. C++ 文件流的详解

    部分内容转载:http://blog.csdn.net/kingstar158/article/details/6859379 感谢追求执着,原本想自己写,却发现了这么明白的文章. C++文件流操作是 ...

  8. 使用webpack打包后的vue项目如何运行(express)

    我们知道使用webpack打包vue项目后会生成一个dist文件夹,dist文件夹下有html文件和其他css.js以及图片等,那么打包后的文件该如何正确运行呢? 倘若直接打开html文件,会报如下错 ...

  9. C Primer Plus 第8章 字符输入/输出和验证输入 编程练习

    1. #include <stdio.h> int main(){ char ch; int ct = 0; while ((ch=getchar()) != EOF) ct++; pri ...

  10. 微信小程序开发库grace vs wepy

    grace和wepy都是辅助小程序开发的开源库,本文对两者做个对比. 注:本文是作者本人的一些拙见,纯粹的技术讨论,不想引起技术信仰之争,欢迎积极.正向的讨论及建议. 如果你还不了解Grace, 请参 ...