1.实验环境:

  使用8台CentOS主机,实现filebeat+redis+logstash+els集群(3台)+kibana来完成搜索日志相关内容,目标:filebeat来完成收集本机http数据,收集完成后发送给redis,redis主要是来避免数据量过大,logstash处理不过来,logstash是用来格式化数据,将收集来的数据格式化成指定格式,els集群是将格式化完成的数据,进行文档分析,,构建索引,提供查询等操作,kibana提供图形化界面查询的组件
逻辑拓扑图

2.实验步骤

本实验所用的四个软件包全部都是5.6版本
下载相关网站:https://www.elastic.co/cn/products
配置前注意事项:1.关闭防火墙。2.关闭SELinux。3.同步时间
步骤1.实现收集httpd服务的日志文件,并将数据发送给redis服务
http+filebeat服务器相关配置

[root@filebeat ~]# yum install -y httpd
[root@filebeat ~]# echo test > /var/www/html/index.html
[root@filebeat ~]# systemctl start httpd
[root@filebeat ~]# rpm -ivh filebeat-5.6.10-x86_64.rpm
相关配置文件
/etc/filebeat/filebeat.full.yml  #模板配置文件
/etc/filebeat/filebeat.yml 主配置文件
配置redis需要从模板文件中将模板复制到主配置文件中
output.redis:enabled: true   #开启hosts: ["172.18.100.2:6379"] #redis服务器port: 6379 key: filebeat  #key的名字password:  centos #密码若没有设置则不用填db: 0 #写入哪个数据库datatype: list  #数据类型worker: 1  #开几个进行写数据loadbalance: true  #是否支持将多个redis中写入
[root@filebeat ~]# systemctl start filebeat

redis相关配置

[root@redis ~]# yum install -y redis
[root@redis ~]# vim /etc/redis.conf
bind 0.0.0.0
port 6379
requirepass centos
[root@nginx1 ~]# systemctl start redis
增加访问日志,在redis中查询
[root@nginx1 ~]# redis-cli -a centos
127.0.0.1:6379> KEYS *
1) "filebeat"   #即可验证成功

步骤2配置logstash从redis中拿数据,并且格式化,然后存入elasticsearch,并且显示
logstash相关配置,配置该服务之前需要安装JVM相关组件

[root@nginx2 ~]# rpm -ivh logstash-5.6.10.rpm
[root@nginx2 ~]# cd /etc/logstash/conf.d/
[root@nginx2 conf.d]# vim redis-logstash-els.conf  #创建文件,只要以.conf结尾即可
input {redis {batch_count => 1data_type => "list"key => "filebeat"host => "172.18.100.2"port => 6379password => "centos"threads => 5}
}
filter {grok {match => {"message" => "%{HTTPD_COMBINEDLOG}"}remove_field => "message"}date {match => ["timestamp","dd/MM/YYYY:H:m:s Z"]remove_field => "timestamp"}}
output {stdout {codec => rubydebug}
}
在终端显示格式化好的内容
[root@nginx2 conf.d]# /usr/share/logstash/bin/logstash -f redis-logstash-els.conf
{"request" => "/","agent" => "\"curl/7.29.0\"","offset" => 93516,"auth" => "-","ident" => "-","input_type" => "log","verb" => "GET","source" => "/var/log/httpd/access_log","type" => "log","tags" => [[0] "_dateparsefailure"],"referrer" => "\"-\"","@timestamp" => 2018-06-20T15:21:20.094Z,"response" => "200","bytes" => "5","clientip" => "127.0.0.1","beat" => {"name" => "filebeat.test.com","hostname" => "filebeat.test.com","version" => "5.6.10"},"@version" => "1","httpversion" => "1.1","timestamp" => "20/Jun/2018:11:21:19 -0400"
}
将output修改成传递给els集群
output {elasticsearch {hosts => ["http://172.18.100.4:9200/","http://172.18.100.5:9200/","http://172.18.100.6:9200/"]index => "logstash-%{+YYYY.MM.dd}"document_type => "apache_logs"}
}检查没有错误即可
[root@nginx2 conf.d]# /usr/share/logstash/bin/logstash -f redis-logstash-els.conf  -t
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
Configuration OK

步骤3配置els集群服务,需要先安装JVM服务
节点1:

[root@tomcat1 ~]# rpm -ivh elasticsearch-5.6.10.rpm
[root@els1 ~]# vim /etc/elasticsearch/elasticsearch.yml
cluster.name: myels
node.name: els.test.com
network.host: 172.18.100.4
http.port: 9200
discovery.zen.ping.unicast.hosts: ["172.18.100.4", "172.18.100.5","172.18.100.6"]
discovery.zen.minimum_master_nodes: 2

节点2:

[root@tomcat1 ~]# rpm -ivh elasticsearch-5.6.10.rpm
[root@els1 ~]# vim /etc/elasticsearch/elasticsearch.yml
cluster.name: myels
node.name: els.test.com
network.host: 172.18.100.5
http.port: 9200
discovery.zen.ping.unicast.hosts: ["172.18.100.4", "172.18.100.5","172.18.100.6"]
discovery.zen.minimum_master_nodes: 2

节点3:

[root@tomcat1 ~]# rpm -ivh elasticsearch-5.6.10.rpm
[root@els1 ~]# vim /etc/elasticsearch/elasticsearch.yml
cluster.name: myels
node.name: els.test.com
network.host: 172.18.100.6
http.port: 9200
discovery.zen.ping.unicast.hosts: ["172.18.100.4", "172.18.100.5","172.18.100.6"]
discovery.zen.minimum_master_nodes: 2

在els任意一个节点上查看数据

[root@els1 ~]# curl -XGET 'http://172.18.100.4:9200/logstash-2018.06.21?pretty=true'  显示传过来的数据"settings" : {"index" : {"refresh_interval" : "5s","number_of_shards" : "5","provided_name" : "logstash-2018.06.21","creation_date" : "1529545212157","number_of_replicas" : "1","uuid" : "3n74gNpCQUyCLq58vAwL6A","version" : {"created" : "5061099"}}}}
}

步骤4:配置Nginx反向代理,若其中有一个故障,还可以被查询

[root@mysql1 ~]# yum install -y nginx
[root@mysql1 ~]# vim /etc/nginx/conf.d/test.conf
upstream ser {server 172.18.100.4:9200;server 172.18.100.5:9200;server 172.18.100.6:9200;
}
server {listen 80;server_name www.test.com;root /app/;index index.html;location / {proxy_pass http://ser;}
}

步骤5:配置kibana实现图形化查看

server.host: "0.0.0.0"
server.basePath: ""
server.name: "172.18.100.8"
elasticsearch.url: "http://172.18.100.7:80"  #反向代理服务器
elasticsearch.preserveHost: true
kibana.index: ".kibana"


转载于:https://blog.51cto.com/10492754/2131477

Elasticsearch配置使用相关推荐

  1. elasticsearch配置小记

    2019独角兽企业重金招聘Python工程师标准>>> elasticsearch配置小记 博客分类: 搜索引擎,爬虫 基于 elasticsearch 1.4.4 版本.安装方式为 ...

  2. ElasticSearch配置详解

    2019独角兽企业重金招聘Python工程师标准>>> 配置文件详解 配置文件位于es根目录的config目录下面,有elasticsearch.yml和logging.yml两个配 ...

  3. springboot Elasticsearch 配置 Demo

    1.配置 yml # Elasticsearch配置 elasticsearch:hostname: 172.16.17.83port: 9200# es索引库名称 indexName: docume ...

  4. springboot ElasticSearch配置自定义转换器ElasticsearchCustomConversions

    springboot ElasticSearch配置自定义转换器ElasticsearchCustomConversions 问题场景 在将Timestamp类型存进Elasticsearc后,将其取 ...

  5. ElasticSearch配置优先使用自带jdk

    文章目录 1 介绍 2 windows 1 介绍 ElasticSearch jdk配置 2 windows 修改elasticsearch-env.bat if defined ES_JAVA_HO ...

  6. ElasticSearch配置扩展分词

    IK支持自定义扩展词典和停用词典,所谓扩展词典就是有些词并不是关键词,但是也希望被ES用来作为检索的关键词,可以将这些词加入扩展词典.停用词典就是有些词是关键词,但是出于业务场景不想使用这些关键词被检 ...

  7. elasticsearch配置优化

    http://m.blog.csdn.net/article/details?id=50330149 节点 Elasticsearch 节点有四种 : master and data--- 默认是这种 ...

  8. elasticsearch 配置安全认证X-pack

    在ElasticSearch6.8及以上版本开启安全认证功能 es之前版本一直无用户验证功能,不过官方有提供一x-pack,但是问题是付费.在es的6.7.0版本中,已经集成了x-pack,虽然es团 ...

  9. elasticsearch配置x-pack和SSL安全认证常见问题

    精选30+云产品,助力企业轻松上云!>>> 异常 当客户端为rest-high-level-client时,客户端异常: com.mamaqunaer.elasticsearch.E ...

最新文章

  1. zabbix Server 4.0 监控TCP的12种状态
  2. linux 内核网络协议栈--linux内核路由机制(一)
  3. 掌握 Ajax,第 6 部分: 建立基于 DOM 的 Web 应用程序
  4. 《微机原理及接口技术》第07章在线测试
  5. 数据库字段属性配置工具界面[用于代码生成]
  6. python比较excel表格内容并提取_利用python提取多张excel表数据并汇总到同一张新表中...
  7. HDU 2586 How far away ?【LCA】
  8. c++ new, operator new, placement new
  9. sre8 sre10_是什么使SRE出色?
  10. PPT出图修改dpi
  11. 单点登录CAS-01:如何找到适合自己JDK版本的CAS?
  12. 那些值得推荐的Superbrowser跨境工具
  13. 阵列卡直通模式和raid模式_详解磁盘阵列RAID原理、种类及性能优缺点
  14. 关于伪元素如何添加过渡动画功能
  15. 计算机绘画社团活动教案,电脑绘画社团课教师教案.doc
  16. C++遍历(traversal)总结
  17. 一个和尚挑水吃,两个和尚抬水吃,三个和尚没水吃
  18. 剑指offer | 面试题10:斐波那切数列
  19. Unique Snowflakes 详细题解
  20. 日元兑人民币用计算机怎么算,日元兑换人民币是以什么计算?谢谢我有日元 – 手机爱问...

热门文章

  1. Android之四大组件概念讲解
  2. mapinfo在线地图插件_地图数据获取|2、CAD地图获取
  3. lodop打印不显示页码_CAD上明明有图,但是打印的时候不显示怎么办?原来要这样设置...
  4. 2018 Multi-University Training Contest 7 - Age of Moyu
  5. Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第十五章:第一人称摄像机和动态索引...
  6. pip install whl
  7. Linux命令缩写来由
  8. oracle的一知半解
  9. Java高级规范之二
  10. CRM问题:导入、导出实体错误