一、安装elasticsearch

官网:https://www.elastic.co/guide/index.html

https://www.elastic.co/guide/en/elasticsearch/reference/2.3/index.html

参考搭建文档

Elasticsearch-6.0.
logstash-6.0.
kibana-6.0.
filebeat-6.0.
https://blog.51cto.com/zero01/2079879 上篇
https://blog.51cto.com/zero01/2082794 下篇
参考 https://www.cnblogs.com/superlinux/p/10591428.html
filebeat写入kafka :https://www.jianshu.com/p/da8113f58115

1)环境准备

[root@k8s6 ~]# java -version
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK -Bit Server VM (build 25.201-b09, mixed mode) )
[root@k8s6 ~]# ls elktools/
elasticsearch-2.3..rpm kibana-4.5.-.x86_64.rpm logstash-2.3.-.noarch.rpm

2)rpm包安装

[root@k8s6 ~]# rpm -ivh elktools/elasticsearch-2.3..rpm 

3)修改配置文件

备份配置文件
cp /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.bak
修改配置文件
[root@k8s6 elasticsearch]# diff /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.bak
17c17
< cluster.name: myes
---
> # cluster.name: my-application
23c23
< node.name: master_node
---
> # node.name: node-
54c54
< network.host: 192.168.10.22
---
> # network.host: 192.168.0.1
58c58
< http.port:
---
> # http.port:

补充:

bootstrap.mlockall: false
bootstrap.system_call_filter: false

4)启动服务

[root@k8s6 elasticsearch]# systemctl start elasticsearch    启动服务
[root@k8s6 elasticsearch]# netstat -lntup|grep java
tcp6 192.168.10.22: :::* LISTEN /java
tcp6 192.168.10.22: :::* LISTEN /java

5)对elasticsearch的api验证

[root@k8s6 elasticsearch]# curl http://192.168.10.22:9200
{
"name" : "master_node",
"cluster_name" : "myes",
"version" : {
"number" : "2.3.5",
"build_hash" : "90f439ff60a3c0f497f91663701e64ccd01edbb4",
"build_timestamp" : "2016-07-27T10:36:52Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}

二、安装elasticsearch的插件安装

1)查看执行的命令和插件位置

[root@k8s6 ~]# ls /usr/share/elasticsearch/
bin lib LICENSE.txt modules NOTICE.txt plugins README.textile

2)安装head插件

[root@k8s6 ~]# /usr/share/elasticsearch/bin/plugin install mobz/elasticsearch-head        从github下载
[root@k8s6 ~]# ls /usr/share/elasticsearch/plugins/head/
Dockerfile Gruntfile.js LICENCE proxy src
Dockerfile-alpine grunt_fileSets.js package.json README.textile test
elasticsearch-head.sublime-project index.html plugin-descriptor.properties _site

2.1)访问测试

http://192.168.10.22:9200/_plugin/head/

3.1)安装 kopf 插件

[root@k8s6 ~]# /usr/share/elasticsearch/bin/plugin install lmenezes/elasticsearch-kopf

3.2)访问测试

http://192.168.10.22:9200/_plugin/kopf/

4)模拟提交post请求

刷新连接

二、es的集群测试

1)另一台机器同样安装好es,修改配置文件(主播模式)测试vm会存在问题

[root@node01 elasticsearch]# grep '^[a-Z]' elasticsearch.yml
cluster.name: myes
node.name: node01
path.data: /data/es-data
path.logs: /var/log/elasticsearch
bootstrap.mlockall: false
bootstrap.system_call_filter: false
network.host: 192.168.10.23
http.port:

创建目录,并授权

[root@node01 elasticsearch]# mkdir -p /data/es-data
[root@node01 elasticsearch]# chown elasticsearch:elasticsearch /data/es-data/

2)单播模式

[root@node01 elasticsearch]# grep '^[a-Z]' elasticsearch.yml
cluster.name: myes
node.name: node01
path.data: /data/es-data
path.logs: /var/log/elasticsearch
bootstrap.mlockall: true
network.host: 192.168.10.23
http.port:
discovery.zen.ping.unicast.hosts: ["192.168.10.22", "192.168.10.23"]

3)启动服务

强调,一点要关闭防火墙。否则无法弄成集群

[root@node01 elasticsearch]# /etc/init.d/elasticsearch start

4)查询集群的状态

[root@node01 ~]# curl -XGET 'http://192.168.10.22:9200/_cluster/health?pretty=true'
{
"cluster_name" : "myes",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : , # 2个节点
"number_of_data_nodes" : ,
"active_primary_shards" : ,
"active_shards" : ,
"relocating_shards" : ,
"initializing_shards" : ,
"unassigned_shards" : ,
"delayed_unassigned_shards" : ,
"number_of_pending_tasks" : ,
"number_of_in_flight_fetch" : ,
"task_max_waiting_in_queue_millis" : ,
"active_shards_percent_as_number" : 100.0
}

三、在主节点安装 logstash

1)安装logstash

[root@k8s6 elktools]# rpm -ivh logstash-2.3.-.noarch.rpm
准备中... ################################# [%]
正在升级/安装...
:logstash-:2.3.- ################################# [%]
[root@k8s6 elktools]# rpm -qa|grep logstash
logstash-2.3.-.noarch
[root@k8s6 elktools]# rpm -ql logstash # 查看安装生成了哪些文件

2)模拟日志标准输出:/opt/logstash/bin/logstash -e 'input { stdin{} } output { stdout{} }'

[root@k8s6 elktools]# /opt/logstash/bin/logstash -e 'input { stdin{} } output { stdout{} }'
Settings: Default pipeline workers:
Pipeline main started
hello
--15T04::.106Z k8s6 hello
hello world
--15T04::.121Z k8s6 hello world

json格式输出: /opt/logstash/bin/logstash -e 'input { stdin{} } output { stdout{ codec => rubydebug } }'

[root@k8s6 elktools]# /opt/logstash/bin/logstash -e 'input { stdin{} } output { stdout{ codec => rubydebug } }'
Settings: Default pipeline workers:
Pipeline main started
hello world
{
"message" => "hello world",
"@version" => "",
"@timestamp" => "2019-03-15T04:47:12.509Z",
"host" => "k8s6"
}

3)命令行模拟输出到elasticsearch: /opt/logstash/bin/logstash -e 'input { stdin{} } output { elasticsearch{ hosts => ["192.168.10.22:9200"] index => "logstash-%{+YYYY.MM.dd}" } }'

[root@k8s6 elktools]# /opt/logstash/bin/logstash -e 'input { stdin{} } output { elasticsearch{ hosts => ["192.168.10.22:9200"] index => "logstash-%{+YYYY.MM.dd}" } }'
Settings: Default pipeline workers:
Pipeline main started
hhhee

查询到输出的值

4)同时进行屏幕输出并写入es

[root@k8s6 elktools]# /opt/logstash/bin/logstash -e 'input { stdin{} } output { stdout{ codec => rubydebug }  elasticsearch{ hosts => ["192.168.10.22:9200"] index => "logstash-%{+YYYY.MM.dd}" } }'
Settings: Default pipeline workers:
Pipeline main started
天天向上
{
"message" => "天天向上",
"@version" => "",
"@timestamp" => "2019-03-15T05:02:55.388Z",
"host" => "k8s6"
}

四、使用配置文件启动logstash

检测语法

[root@node01 ~]# /opt/logstash/bin/logstash -t -f /etc/logstash/conf.d/nginx.conf
Configuration OK

1)进入到配置文件目录。cd /etc/logstash/conf.d/   ,该目录由/etc/init.d/logstash 这里定义的

[root@k8s6 elktools]# cd /etc/logstash/conf.d/
[root@k8s6 conf.d]# ls
[root@k8s6 conf.d]#

编辑 demo.conf文件,既输出在屏幕,也存入es

YYYY.MM.dd  每天

[root@k8s6 conf.d]# cat demo.conf
input {
stdin{}
} filter{
} output{
elasticsearch {
hosts => ["192.168.10.22:9200"]
index => "logstash-%{+YYYY.MM.dd}"
} stdout{ codec => rubydebug }
}

启动服务:[root@k8s6 conf.d]# /opt/logstash/bin/logstash -f /etc/logstash/conf.d/demo.conf

2)使用file插件,指定要记录日志的目录

[root@k8s6 conf.d]# cat file.conf
input {
file{
path => ["/var/log/messages", "/var/log/secure"]
type => "system-log"
start_position => "beginning"
}
} filter{
} output{
elasticsearch {
hosts => ["192.168.10.22:9200"]
index => "system-log-%{+YYYY.MM}"
}
}

file.conf

启动服务: /opt/logstash/bin/logstash -f /etc/logstash/conf.d/file.conf

五、安装kibana

1)在主节点安装kibana

[root@k8s6 elktools]# rpm -ivh kibana-4.5.-.x86_64.rpm 

查看安装到了哪些位置

[root@k8s6 elktools]# rpm -ql kibana

2)修改配置文件

[root@k8s6 config]# pwd
/opt/kibana/config
[root@k8s6 config]# grep '^[a-Z]' kibana.yml
server.port:
server.host: "0.0.0.0"
elasticsearch.url: "http://192.168.10.22:9200"
kibana.index: ".kibana"

/opt/kibana/config/kibana.yml

启动服务:[root@k8s6 config]# /etc/init.d/kibana start

[root@k8s6 config]# netstat -lntup|grep
tcp 0.0.0.0: 0.0.0.0:* LISTEN /node

网页访问:192.168.10.22:5601

2)配置索引,配置哪个,显示哪个的日志文件

匹配到了创建,即可

ELK的文档搭建的更多相关文章

  1. ELK安装文档

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

  2. swagger在线api文档搭建指南,用于线上合适么?

    在上一篇文章中,我们讲解了什么是 api,什么是 sdk: https://www.cnblogs.com/tanshaoshenghao/p/16217608.html 今天将来到我们万丈高楼平地起 ...

  3. ELK 部署文档

    1. 前言 在日常运维工作中,对于系统和业务日志的处理尤为重要.尤其是分布式架构,每个服务都会有很多节点,如果要手工一个一个的去取日志,运维怕是要累死. 简单介绍: ELK 是 elasticsear ...

  4. Filebeat+ELK部署文档

    在日常运维工作中,对于系统和业务日志的处理尤为重要.今天,在这里分享一下自己部署的Filebeat+ELK开源实时日志分析平台的记录过程,有不对的地方还望指出. 简单介绍: 日志主要包括系统日志.应用 ...

  5. ELK帮助文档

    elasticsearch: API中文指南:https://es.xiaoleilu.com/010_Intro/15_API.html 官方文档:https://www.elastic.co/cn ...

  6. elk升级文档

    1.kibana等都统一版本了,5.4版本的kibana要5.4版本的elasticsearch 2.现有架构: logstash logstash读取日志-------->内网redis做队列 ...

  7. 一文搭建自己博客/文档系统:搭建,自动编译和部署,域名,HTTPS,备案等

    本文纯原创,搭建后的博客/文档网站可以参考: Java 全栈知识体系.如需转载请说明原处. 第一部分 - 博客/文档系统的搭建 搭建博客有很多选择,平台性的比如: 知名的CSDN, 博客园, 知乎,简 ...

  8. hadoop2.6.0汇总:新增功能最新编译 32位、64位安装、源码包、API下载及部署文档

    相关内容: hadoop2.5.2汇总:新增功能最新编译 32位.64位安装.源码包.API.eclipse插件下载Hadoop2.5 Eclipse插件制作.连接集群视频.及hadoop-eclip ...

  9. ASP.NET API Helper Page 创建并生成相关帮助文档

    创建API项目 修改原工程文件,该行为是为了避免和引入第三方API工程文件冲突 修改发布设置 引入需要生成文档的相关文件,将第三方API依赖的相关文件(XML文件非常重要,是注释显示的关键),复制到文 ...

随机推荐

  1. vs2015 工具栏添加控件

    就是“添加”——“组件(N)”,然后把需要的代码写进去,但是工具栏里面却显示不出来. 结果是得重启系统才行,重启之后的确显示在工具栏显示出来了,但是拖到设计界面的时候还会出现“未能加载工具箱项xxx, ...

  2. java学习--修饰符

    Java语言提供了很多修饰符,主要分为以下两类: 访问修饰符 非访问修饰符 访问控制修饰符 访问控制修饰符用来修饰类和类内部的成员变量和成员方法,来确定其访问权限 类的访问控制修饰符只有两种 defa ...

  3. 【Debug】串口发送数据时部分字节被拉长,出现帧错误,原因MCU进入低功耗模式导致串口时钟停了!

    串口发送数据时部分字节被拉长,出现帧错误,原因MCU进入低功耗模式导致串口时钟停了!

  4. 读取文件不是真实的具体路径 setZh.ini

    读取 c:\windows\Syswow64\XX\XX.ini 时内容不正确. 发现真实文件为: C:\Users\用户名\AppData\Local\VirtualStore\Windows\Sy ...

  5. eayUi panel实现上一页下一页

    function 是为了第一次加载的时候显示页面 butt1和butt2触发上一页下一页,后面绑定参数即可 问题:.panel({href:href})到后台的时候会请求两次,这个问题还没有解决 把 ...

  6. GitLab管理之 - Gitlab 用户管理

    1. 移除用户 (1) 使用管理员登陆Gitlab服务器 (2) 点击管理区域 (3) 点击Users. (4)点击[Block User] 2. 添加用户(1)用root 管理员登陆.(2)点击[管 ...

  7. 定义返回结果 Resultmodel

    web: checkPath: localhost:9099 success: 1 error: 0 package com.worker.config; import org.springframe ...

  8. vue axios跨域

    现在应用都是前后端分离,这也造成前端在调用接口时出现跨域问题,在控制台会这样提示 ,如果有类似于此图的提示,就已经表明你的接口调用出现了跨域问题,此文章是我对于vue跨域其中一种方式的一些经验,如果错 ...

  9. 转载:让Windows Server 2012r2 IIS8 ASP.NET 支持10万并发请求

    由于之前使用的是默认配置,服务器最多只能处理5000个同时请求,今天下午由于某种情况造成同时请求超过5000,从而出现了上面的错误. 为了避免这样的错误,我们根据相关文档调整了设置,让服务器从设置上支 ...

  10. 【1天】黑马程序员27天视频学习笔记【Day02】

    02.01常量的概述和使用 * A:什么是常量    * 在程序执行的过程中其值不可以发生改变 * B:Java中常量的分类    * 字面值常量    * 自定义常量(面向对象部分讲) * C:字面 ...