elasticSearch插件的安装以及使用nginx的modles收集nginx的日志
1、首先在windows环境上搭建es的集群
集群的配置如下
#node01的配置:
cluster.name: es-itcast-cluster
node.name: node01
node.master: true
node.data: true
network.host: 0.0.0.0
http.port:
transport.tcp.port:
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300","127.0.0.1:9301","127.0.0.1:9302"]
discovery.zen.minimum_master_nodes:
http.cors.enabled: true
http.cors.allow-origin: "*"
#node01的配置:
cluster.name: es-itcast-cluster
node.name: node02
node.master: true
node.data: true
network.host: 0.0.0.0
http.port:
transport.tcp.port:
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300","127.0.0.1:9301","127.0.0.1:9302"]
discovery.zen.minimum_master_nodes:
http.cors.enabled: true
http.cors.allow-origin: "*"
#node01的配置:
cluster.name: es-itcast-cluster
node.name: node03
node.master: true
node.data: true
network.host: 0.0.0.0
http.port:
transport.tcp.port:
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300","127.0.0.1:9301","127.0.0.1:9302"]
discovery.zen.minimum_master_nodes:
http.cors.enabled: true
http.cors.allow-origin: "*"
在linux环境下配置es集群的配置文件为
ELasticsearch的集群是由多个节点组成的,通过cluster.name设置集群名称,并且用于区分其它的集群,每个节点
通过node.name指定节点的名称。
在Elasticsearch中,节点的类型主要有4种:
master节点
配置文件中node.master属性为true(默认为true),就有资格被选为master节点。
master节点用于控制整个集群的操作。比如创建或删除索引,管理其它非master节点等。
data节点
配置文件中node.data属性为true(默认为true),就有资格被设置成data节点。
data节点主要用于执行数据相关的操作。比如文档的CRUD。
客户端节点
配置文件中node.master属性和node.data属性均为false。
北京市昌平区建材城西路金燕龙办公楼一层 电话:400-618-9090
该节点不能作为master节点,也不能作为data节点。
可以作为客户端节点,用于响应用户的请求,把请求转发到其他节点
部落节点
当一个节点配置tribe.*的时候,它是一个特殊的客户端,它可以连接多个集群,在所有连接的集群上执行
搜索和其他操作。
#启动3个虚拟机,分别在3台虚拟机上部署安装Elasticsearch
mkdir /itcast/es-cluster
#分发到其它机器
scp -r es-cluster elsearch@192.168.40.134:/itcast
#node01的配置:
cluster.name: es-itcast-cluster
node.name: node01
node.master: true
node.data: true
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.40.133","192.168.40.134","192.168.40.135"]
discovery.zen.minimum_master_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"
#node02的配置:
cluster.name: es-itcast-cluster
node.name: node02
node.master: true
node.data: true
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.40.133","192.168.40.134","192.168.40.135"]
discovery.zen.minimum_master_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"
#node03的配置:
cluster.name: es-itcast-cluster
node.name: node02
node.master: true
node.data: true
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.40.133","192.168.40.134","192.168.40.135"]
discovery.zen.minimum_master_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"
#分别启动3个节点
./elasticsearch
特别需要的是下面参数
特别说明:
如果在配置文件中discovery.zen.minimum_master_nodes设置的不是N/2+1时,会出现脑裂问题,之前宕机
的主节点恢复后不会加入到集群。
接下来我们要安装es的插件:插件一定要和es的版本一致,例如当前es是6.2.4版本,那离线安装插件的版本也必须是6.2.4版本
接下来我们要安装三个插件analysis-ik、ingest-geoip和ingest-user-agent
在线安装插件的方式
sudo bin/elasticsearch-plugin install ingest-user-agent
sudo bin/elasticsearch-plugin install ingest-geoip
离线安装的方式:
下载对应的插件版本,当前es是6.2.4,插件一定要是6.2.4版本,如果是其他版本就会报错
elasticsearch-plugin install file:C:\Users\Administrator\Desktop\ELK\es-cluster\ingest-geoip-6.2.4.zip
离线安装ingest-geoip-6.2.4.zip
4.7、Module
前面要想实现日志数据的读取以及处理都是自己手动配置的,其实,在Filebeat中,有大量的Module,可以简化我
们的配置,直接就可以使用,如下
./filebeat modules list
Enabled:
Disabled:
apache2
auditd
elasticsearch
haproxy
icinga
iis
kafka
1 2 3 4 5 6 7 8 9
10
11
12
北京市昌平区建材城西路金燕龙办公楼一层 电话:400-618-9090
可以看到,内置了很多的module,但是都没有启用,如果需要启用需要进行enable操作:
可以发现,nginx的module已经被启用。
4.7.1、nginx module 配置
kibana
logstash
mongodb
mysql
nginx
osquery
postgresql
redis
suricata
system
traefik
可以看到,内置了很多的module,但是都没有启用,如果需要启用需要进行enable操作:
可以发现,nginx的module已经被启用
nginx module 配置
- module: nginx
# Access logs
access:
enabled: true
var.paths: ["C:/Users/Administrator/Desktop/ELK/nginx-1.15.5/nginx-1.15.5/logs/access.log"]
# Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
#var.paths: # Error logs
error:
enabled: true
var.paths: ["C:/Users/Administrator/Desktop/ELK/nginx-1.15.5/nginx-1.15.5/logs/error.log"]
# Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
#var.paths:
在这里指定nginx日志的位置
var.paths: ["C:/Users/Administrator/Desktop/ELK/nginx-1.15.5/nginx-1.15.5/logs/access.log"]
接下来配置配置filebeat的配置文件
filebeatwithnginxmoudles.yml
#============================= Filebeat modules =============================== filebeat.config.modules:
# Glob pattern for configuration loading
path: ${path.config}/modules.d/*.yml
reload.enabled: true
setup.template.settings:
index.number_of_shards: 3 setup.kibana: #----------------------------- Logstash output --------------------------------
output:
elasticsearch:
hosts: ["127.0.0.1:9200","127.0.0.1:9201","127.0.0.1:9202"]
整个filebeat的配置文件我们都要分析下
filebeat.config.modules:
# Glob pattern for configuration loading
path: ${path.config}/modules.d/*.yml
reload.enabled: true
这个配置就会去加载上面的modules.d目录下面的nginx.yml配置文件,在这个配置文件中使用moudles来收集nginx的配置文件
output:
elasticsearch:
hosts: ["127.0.0.1:9200","127.0.0.1:9201","127.0.0.1:9202"]
这个指定filebeat收集到日志之后直接发送到es的集群中
setup.template.settings:
index.number_of_shards: 3
这个指定一个索引文件存储在3个分片中
es-head中0 1 2 就是对于的分片,每个文档都是分别存储在上面的三个分片中
最新文章
- Web安全相关(一):跨站脚本攻击(XSS)
- oracle更改用户名
- webservice服务的简单应用
- MS - 1 - 把二元查找树转变成排序的双向链表
- C语言数组删除增加一个元素
- 斜堆(二)之 C++的实现
- c# 计算1-100之间的所有质数(素数)的和
- eclipse 或MyEclipse将工程进行移动的时候会对@Override报错的处理方法
- mysql单引号和双引号的用法
- Spark Streaming揭秘 Day9 从Receiver的设计到Spark框架的扩展
- [cocos2d-x 2.0.4][iOS7]图片加载错误
- Android动态加载代码技术
- QT 判断当前焦点是否在某控件上(使用hasFocus函数,毕竟QT是DIRECTUI,所以这个Focus到底代表了什么呢?)
- Swift - 使用闭包筛选过滤数据元素
- springboot整合shiro
- 为什么在有的服务器上禅道、蝉知安装会报错? 之理解MySQL的SQL_MODE
- Tiny4412 烧写uboot到emmc步骤
- git 版本回滚
- Maven将远程包拉去到项目指定路径
- windows攻击实验
热门文章
- [Python基础]002.语法(1)
- 分布式项目开发-springmvc.xmll基础配置
- MySQL8.0 忘记密码、重置密码
- 轻便的一句话反弹shell语句
- 管程(Monitor)概念及Java的实现原理
- Rocket - debug - Example: Read Memory
- Java实现 LeetCode 551 学生出勤记录 I(暴力大法好)
- Java实现 LeetCode 440 字典序的第K小数字
- Java实现 LeetCode 208 实现 Trie (前缀树)
- Java实现 LeetCode 23 合并K个排序链表