简介:

ELK Stack 安装文档,这次都使用最新版本(5.2.2)、RPM 包的方式搭建 ELK Stack。

下载地址:

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.rpm
https://artifacts.elastic.co/downloads/logstash/logstash-5.2.2.rpm
https://artifacts.elastic.co/downloads/kibana/kibana-5.2.2-x86_64.rpm

jre: http://javadl.oracle.com/webapps/download/AutoDL?BundleId=216423
jdk: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

# 如果只是需要 java 环境,那么安装 jre 即可,如还需编译 java 包就需要安装 jdk 了。
# 运行 Elasticsearch jre 即可

一、安装

shell > rpm -e elasticsearch
Stopping elasticsearch service... OK
warning: /etc/sysconfig/elasticsearch saved as /etc/sysconfig/elasticsearch.rpmsave
warning: /etc/init.d/elasticsearch saved as /etc/init.d/elasticsearch.rpmsave
warning: /etc/elasticsearch/elasticsearch.yml saved as /etc/elasticsearch/elasticsearch.yml.rpmsave
Deleting log directory... OK
Deleting plugins directory... OK shell > rpm -e kibana
Stopping kibana service... OK
warning: /opt/kibana/config/kibana.yml saved as /opt/kibana/config/kibana.yml.rpmsave

# 我之前使用 2.4.1 版本,也是通过 rpm 安装的,需要先卸载。

shell > rm -rf /etc/sysconfig/elasticsearch.rpmsave
shell > rm -rf /etc/init.d/elasticsearch.rpmsave
shell > rm -rf /etc/elasticsearch/elasticsearch.yml.rpmsave
shell > rm -rf /opt/kibana/config/kibana.yml.rpmsave

# 可以看到卸载的时候,这些文件没有被删除,强迫症的我是不允许这些文件存在的。

shell > cd /usr/local/src; rpm -ivh elasticsearch-5.2..rpm logstash-5.2..rpm kibana-5.2.-x86_64.rpm

# 由于是测试一下新版本,所以都装在了一台服务器上。

二、配置

1、Elasticsearch

shell > grep -vP '^#|^$' /etc/elasticsearch/elasticsearch.yml
# 集群名称
cluster.name: elk
# 节点名称
node.name: node-
# 数据路径
path.data: /data/elast/data
# 日志路径
path.logs: /data/elast/logs
# 启动时锁住内存,防止数据被交换到 SWAP
bootstrap.memory_lock: true
# 监听地址
network.host: 0.0.0.0
# 与其余节点通信地址
network.publish_host: 10.127.174.217
# 开启 HTTP 协议
http.port:
# 解决启动报错
bootstrap.system_call_filter: false shell > mkdir -p /data/elast/{data,logs}
shell > chown -R elasticsearch.elasticsearch /data/elast

# 创建数据、日志目录

2、Logstash

shell > vim /etc/logstash/conf.d/for_elk.conf
# 输入插件,这里从 redis 中读取数据
input {
redis {
data_type => "list"
key => "for_elk"
host => "10.217.79.61"
port =>
threads =>
}
}
# 过滤插件,按需切割日志、加减字段等
filter {
mutate {
split => ["message", "|"]
add_field => {"clientip" => "%{message[0]}"}
add_field => {"localtime" => "%{message[1]}"}
add_field => {"api" => "%{message[2]}"}
add_field => {"request_all" => "%{message[3]}"}
add_field => {"http_code" => "%{message[4]}"}
add_field => {"request_body" => "%{message[6]}"}
add_field => {"request_time" => "%{message[11]}"}
} date {
match => ["localtime", "dd/MMM/yyyy:HH:mm:ss Z"]
} geoip {
source => "clientip"
fields => ["city_name", "latitude", "longitude"]
} kv {
source => "request_body"
field_split => "&"
remove_field => "host"
remove_field => "path"
remove_field => "message"
remove_field => "request_all"
remove_field => "request_body"
} mutate {
convert => [
"id", "integer",
"cid", "integer",
"tid", "integer",
"vid", "integer",
"version", "float",
"http_code", "integer",
"request_time", "float"
]
}
}
# 输出插件
output {
elasticsearch {
hosts => ["10.127.174.217:9200"]
index => "logstash-%{+YYYY.MM.dd}"
template_overwrite => true
}
# stdout {
# codec => rubydebug
# }
}

# 可以测试能否从 redis 拿到数据,然后在做 filter,最后测试能否写入 elasticsearch

3、Kibana

shell > /etc/kibana/kibana.yml

# Kibana 其实不用修改,暂时采用默认配置即可

三、启动

1、Elasticsearch

shell > /etc/init.d/elasticsearch start

2、Logstash

shell > /usr/share/logstash/bin/logstash --path.settings /etc/logstash > /dev/null &

3、Kibana

shell > /etc/init.d/kibana start

四、访问

# http://x.x.x.x:5601 即可,根据 index 建立索引,嗯 确实比 K4 漂亮

五、插件安装

1、Elasticsearch head (从 5.0 起,该插件以一个单独的服务运行)

shell > cd /usr/local

shell > git clone git://github.com/mobz/elasticsearch-head.git

shell > cd elasticsearch-head

shell > npm install

shell > vim Gruntfile.js

                connect: {
server: {
options: {
hostname: '0.0.0.0',
port: ,
base: '.',
keepalive: true
}
}
}

# 默认只监听 127.0.0.1,所以要加上 hostname: '0.0.0.0'

shell > ./node_modules/grunt/bin/grunt server > /dev/null &

shell > vim /etc/elasticsearch/elasticsearch.yml

# head plugin
http.cors.enabled: true
http.cors.allow-origin: "*"

# elasticsearch 5.x 需要设置该参数,否则无法 head 无法连接 es
# 你可能注意到 es 集群状态为 yellow,不要慌...
# 那是因为副本不可用,因为只有一个 es 节点,而副本不能在本机,不碍事 !

2、IK Analysis for Elasticsearch

shell > wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz
shell > tar zxf apache-maven-3.5.-bin.tar.gz -C /usr/local
shell > echo -e '\nexport JAVA_HOME=/usr/java/default' >> /etc/profile && source /etc/profile shell > wget https://github.com/medcl/elasticsearch-analysis-ik/archive/v5.2.2.zip
shell > unzip v5.2.2.zip
shell > cd elasticsearch-analysis-ik-5.2.
shell > /usr/local/apache-maven-3.5./bin/mvn package
shell > unzip target/releases/elasticsearch-analysis-ik-5.2..zip -d /usr/share/elasticsearch/plugins/ik
shell > /usr/share/elasticsearch/bin/elasticsearch-plugin list
ik
shell > /etc/init.d/elasticsearch restart

附件:

1、Elasticsearch 启动报错

> bootstrap.memory_lock: true 参数导致

memory locking requested for elasticsearch process but memory is not locked

解决方法:

shell > vim /etc/security/limits.conf

# allow user 'elasticsearch' mlockall
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited

> CentOS 6.x 不支持 CONFIG_SECCOMP 导致

[--01T12::,][WARN ][o.e.b.JNANatives         ] unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:) ~[elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:) ~[elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:) [elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:) [elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:) [elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:) [elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:) [elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:) [elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:) [elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:) [elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:) [elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.cli.Command.main(Command.java:) [elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:) [elasticsearch-5.2..jar:5.2.]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:) [elasticsearch-5.2..jar:5.2.] bootstrap checks failed
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

解决方法:

shell > vim /etc/elasticsearch/elasticsearch.yml

bootstrap.system_call_filter: falses

> /etc/security/limits.d/90-nproc.conf 默认参数过低导致启动失败

[--06T14::,][ERROR][o.e.b.Bootstrap          ] [node01] node validation exception
bootstrap checks failed
max number of threads [] for user [elasticsearch] is too low, increase to at least []

解决方法:

shell > vim /etc/security/limits.d/-nproc.conf

*          soft    nproc
root soft nproc unlimited # 将原 改为

ELK Stack 5.2.2 安装文档的更多相关文章

  1. ELK安装文档

    ELK安装文档: http://cuidehua.blog.51cto.com/5449828/1769525 如何将客户端日志通过ogstash-forwarder发送给服务端的logstash h ...

  2. ORACLE LINUX 6.3 + ORACLE 11.2.0.3 RAC + VBOX安装文档

    ORACLE LINUX 6.3 + ORACLE 11.2.0.3 RAC + VBOX安装文档 2015-10-21 12:51 525人阅读 评论(0) 收藏 举报  分类: Oracle RA ...

  3. Oracle 12c RAC 安装文档

    参考文档: https://docs.oracle.com/en/database/oracle/oracle-database/12.2/cwlin/index.html https://docs. ...

  4. Oracle 11g 单实例安装文档

    这里介绍在Red Hat Enterprise Linux Server release 5.7 (Tikanga)下安装ORACLE 11.2.0.1.0的过程,本文仅仅是为了写这样安装指导文档而整 ...

  5. linkedin开源的kafka-monitor安装文档

    linkedin开源的kafka-monitor安装文档 linkedin 开源的kafka-monitor的安装使用可以参考官方的readme:流程介绍的已经比较清楚,但是还是有一些地方需要修正.让 ...

  6. 为什么开发者热衷在Stack Overflow上查阅API文档?

    摘要:一项新研究跟踪了Android开发者的访问历史,发现开发者多达二分之一的文档是从Stack Overflow上获取到的,而Stack Overflow上的示例也多于官方指南,开发者通过搜索更多时 ...

  7. _00024 尼娜抹微笑伊拉克_云计算ClouderaManager以及CHD5.1.0群集部署安装文档V1.0

    笔者博文:妳那伊抹微笑 itdog8 地址链接 : http://www.itdog8.com(个人链接) 博客地址:http://blog.csdn.net/u012185296 博文标题:_000 ...

  8. oracle database 12c R1 安装文档

    INSTALLORACLE DATABASE 12C 完整的安装文档下载地址: http://download.csdn.net/detail/royjj/5665869 OS:ORALCE LINU ...

  9. HAProxy安装文档

    HAProxy安装文档 [toc][TOC] 一.环境说明 系统环境:CentOS Linux release 7.2.1511 (Core) 系统内核:3.10.0-327.el7.x86_64 软 ...

随机推荐

  1. input type="file"在各个浏览器下的默认样式,以及修改自定义样式

    一.<input type="file"/>在各个浏览器中的默认样式: 系统 浏览器 样式效果 点击效果 mac google 点击按钮和输入框都可以打开文件夹 mac ...

  2. LoadRunner设置监控Windows系统资源步骤

    一般在客户端通过LoadRunner对服务器进行压力测试,都需要实时监控服务器端的系统资源,本篇主要简单介绍一下如何设置在LoadRunner的Controller中配置监控Windows Resou ...

  3. Eclipse 项目有红惊叹号

    Eclipse 项目有红感叹号原因:显示红色感叹号是因为jar包的路径不对 解决:在项目上右击Build Path -> Configure Build Paht...(或Propertise- ...

  4. 三十分钟理解:双调排序Bitonic Sort,适合并行计算的排序算法

    欢迎转载,转载请注明:本文出自Bin的专栏blog.csdn.net/xbinworld 技术交流QQ群:433250724,欢迎对算法.技术.应用感兴趣的同学加入 双调排序是data-indepen ...

  5. 06-jenkins的账号相关的问题

    飞测说:最近几天,在团队分享jenkins后,大家都十分感兴趣,各自下载安装和练习,然而jenkins2.3安装默认有权限设置,这块好多人遇到了问题,现在统一就账号登录的问题一起看看,踩过的坑,希望对 ...

  6. 前端安全系列:如何防止CSRF攻击?

    背景 随着互联网的高速发展,信息安全问题已经成为企业最为关注的焦点之一,而前端又是引发企业安全问题的高危据点.在移动互联网时代,前端人员除了传统的 XSS.CSRF 等安全问题之外,又时常遭遇网络劫持 ...

  7. Struts2自定义标签4自定义分页标签

    第一步:webroot/web-inf下的str.tld文件 <?xml version="1.0" encoding="UTF-8"?> < ...

  8. 10055 - Hashmat the Brave Warrior & 各数据类型所占字节数 (C语言)

    Problem A Hashmat the brave warrior Input: standard input Output: standard output Hashmat is a brave ...

  9. Yarn import now uses package-lock.json

    转发自: https://yarnpkg.com/blog/2018/06/04/yarn-import-package-lock/?utm_source=tuicool&utm_medium ...

  10. JAVA通过JDBC连接Oracle数据库详解【转载】

    JAVA通过JDBC连接Oracle数据库详解 (2011-03-15 00:10:03) 转载▼http://blog.sina.com.cn/s/blog_61da86dd0100q27w.htm ...