当前位置: 首页 > news >正文

源码部署EFK

目录

资源列表

基础环境

关闭防护墙

关闭内核安全机制

修改主机名

添加hosts映射

一、部署elasticsearch

修改limit限制

部署elasticsearch

修改配置文件

单节点

集群(3台节点集群为例)

启动

二、部署filebeat

部署filebeat

添加配置文件

启动

三、部署kibana

单节点kibana

部署kibana

修改配置文件

启动

多节点kibana


        之前给大家分享的ELK,今天分享的是一个更加轻量级的日志收集EFK,主要就是有filebeat代替了logstash,filebeat采用go语言编写占用资源少,更加轻量级。本文中涉及到的软件包如果有需要可以评论区找我要,无偿提供。

资源列表

操作系统配置主机名IP
CentOS7.3.16112C4Ges01192.168.207.131
CentOS7.3.16112C4Gkibana192.168.207.165
CentOS7.3.16112C4Gfilebeat192.168.207.166

基础环境

关闭防护墙

systemctl stop firewalld
systemctl disable firewalld

关闭内核安全机制

sed -i "s/.*SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
reboot

修改主机名

hostnamectl set-hostname es01
hostnamectl set-hostname kibana
hostnamectl set-hostname filebeat

添加hosts映射

cat >> /etc/hosts << EOF
192.168.207.131 es01
192.168.207.165 kibana
192.168.207.166 filebeat
EOF

一、部署elasticsearch

修改limit限制

cat > /etc/security/limits.d/es.conf << EOF
* soft nproc 655360
* hard nproc 655360
* soft nofile 655360
* hard nofile 655360
EOF
​
cat >> /etc/sysctl.conf << EOF
vm.max_map_count=655360
EOF
sysctl -p

部署elasticsearch

mkdir -p /data/elasticsearch
tar zxvf elasticsearch-7.14.0-linux-x86_64.tar.gz -C /data/elasticsearch

修改配置文件

单节点

mkdir /data/elasticsearch/{data,logs}[root@es01 elasticsearch-7.14.0]# grep -v "^#" /data/elasticsearch/elasticsearch-7.14.0/config/elasticsearch.yml
cluster.name: my-application
node.name: es01
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
bootstrap.memory_lock: false
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["es01"]

集群(3台节点集群为例)

需要准备3台机器,主机名分别是es01,es02,es03

[root@es01 ~]# grep -v "^#" /data/elasticsearch/elasticsearch-7.14.0/config/elasticsearch.yml
cluster.name: es
node.name: es01
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
bootstrap.memory_lock: false
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["es01","es02","es03"]
cluster.initial_master_nodes: ["es01","es02","es03"]
node.master: true
node.data: true
http.cors.enabled: true
http.cors.allow-origin: "*"
​
[root@es02 ~]# grep -v "^#" /data/elasticsearch/elasticsearch-7.14.0/config/elasticsearch.yml
cluster.name: es
node.name: es02
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
bootstrap.memory_lock: false
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["es01","es02","es03"]
cluster.initial_master_nodes: ["es02", "es01", "es03"]
node.master: true
node.data: true
http.cors.enabled: true
http.cors.allow-origin: "*"
​
​
[root@es03 ~]# grep -v "^#" /data/elasticsearch/elasticsearch-7.14.0/config/elasticsearch.yml
cluster.name: es
node.name: es03
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
bootstrap.memory_lock: false
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["es01","es02","es03"]
cluster.initial_master_nodes: ["es01", "es02", "es03"]
node.master: true
node.data: true
http.cors.enabled: true
http.cors.allow-origin: "*"

启动

useradd es 
chown -R es:es /data/
su - es
/data/elasticsearch/elasticsearch-7.14.0/bin/elasticsearch -d

二、部署filebeat

部署filebeat

mkdir -p /data/filebeat
tar zxvf filebeat-7.14.0-linux-x86_64.tar.gz -C /data/filebeat/

添加配置文件

[root@filebeat filebeat-7.14.0-linux-x86_64]# cat filebeat.yml
filebeat.inputs:
- type: logenabled: truepaths:- /var/log/messages
# 定义模板的相关信息
# 不允许自动生成模板
setup.template.enabled: false
# 生成index模板的名称
setup.template.name: "filebeat-test"
# 生成index模板的格式
setup.template.pattern: "filebeat-test-*"
# 7版本自定义ES的索引需要把ilm设置为false
setup.ilm.enabled: false
output.elasticsearch:hosts: ["192.168.207.131:9200"]index: "filebeat-test-%{+yyyy.MM.dd}"
[root@filebeat filebeat-7.14.0-linux-x86_64]# cat filebeat.yml
filebeat.inputs:
- type: logenabled: truepaths:- /var/log/httpd/access_logfields:source: access
- type: logenabled: truepaths:- /var/log/httpd/error_logfields:source: error
setup.template.enabled: false
setup.template.name: "httpd"
setup.template.pattern: "httpd-*"
setup.ilm.enabled: false
output.elasticsearch:hosts: ["192.168.207.131:9200"]index: "httpd-%{[fields.source]}-*"indices:- index: "httpd-access-%{+yyyy.MM.dd}"when.equals:fields.source: "access"- index: "httpd-error-%{+yyyy.MM.dd}"when.equals:fields.source: "error"

启动

/data/filebeat/filebeat-7.14.0-linux-x86_64/filebeat -e -c filebeat.yml

三、部署kibana

单节点kibana

部署kibana

mkdir -p /data/kibana
tar zxvf kibana-7.14.0-linux-x86_64.tar.gz -C /data/kibana/

修改配置文件

grep -v "^#" /data/kibana/kibana-7.14.0-linux-x86_64/config/kibana.yml  | grep -v "^$"
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://192.168.207.131:9200"]
kibana.index: ".kibana"

启动

useradd kibana
chown -R kibana:kibana /data 
su - kibana
/data/kibana/kibana-7.14.0-linux-x86_64/bin/kibana

多节点kibana

每个节点配置相同

[root@es01 ~]# grep -v "^#" /data/kibana/kibana-7.14.0-linux-x86_64/config/kibana.yml  | grep -v "^$"
server.port: 5601
server.host: "0.0.0.0"
server.name: "your-hostname"
elasticsearch.hosts: ["http://es01:9200", "http://es02:9200", "http://es03:9200"]
kibana.index: ".kibana"

http://www.lryc.cn/news/351419.html

相关文章:

  • CSDN智能总结助手
  • setImmediate是在当前事件循环的所有周期的末尾执行,还是再当前事件循环的当前周期的下一个周期执行?
  • 建材行业工程设计资质动态核查不通过怎么办
  • 二叉数之插入操作
  • 【Python】全局变量与init的区别
  • JAVA学习-练习试用Java实现“位1的个数”
  • HTML静态网页成品作业(HTML+CSS)——魅族商城首页网页(1个页面)
  • Windows DNS 服务器配置转发器
  • 基于FPGA的VGA协议实现----条纹-文字-图片
  • hdfs中MapReduce中的shuffle,combine和partitioner(hadoop,Hdfs)
  • Linux应用入门(二)
  • 高仿果汁导航模板
  • 机器学习之一分类支持向量机(One-class SVM)
  • 签发免费https证书的方式
  • Autodl服务器中Faster-rcnn(jwyang)训练自己数据集(二)
  • 安卓手机文件误删或丢失?教你快速找回的方法!
  • C语言 | Leetcode C语言题解之第108题将有序数组转换为二叉搜索树
  • 关于在企业环境中中间人攻击(MITM)可行性研究的报告
  • GitHub Actions 自动部署 AWS Lambda
  • 【NOIP2013普及组复赛】题4:车站分级
  • el-table 表格拖拽 + 表头可修改 + 宽度自定义
  • Google发布的CAT3D,在1分钟内,能够从任意数量的真实或生成的图像创建3D场景。
  • 基于Matlab实现声纹识别系统
  • 【人工智能项目】小车障碍物识别与模型训练(完整工程资料源码)
  • #05【面试问题整理】嵌入式软件工程师
  • 同旺科技 FLUKE ADPT 隔离版发布 ---- 3
  • 探索 JavaScript 新增声明命令与解构赋值的魅力:从 ES5 迈向 ES6
  • HTML5 历史、地理位置处理、全屏处理
  • 打印机驱动程序安装后位置以及注册表中的位置
  • oracle数据库解析过高分析