转载他人的efk搭建文章后边有链接和地址
通过部署elasticsearch(三节点)+filebeat+kibana快速入门EFK,并搭建起可用的demo环境测试效果
目录
▪ 用途
▪ 实验架构
▪ EFK软件安装
▪ elasticsearch配置
▪ filebeat配置
▪ kibana配置
▪ 启动服务
▪ kibana界面配置
▪ 测试
▪ 后续文章
用途
▷ 通过filebeat实时收集nginx访问日志、传输至elasticsearch集群
▷ filebeat将收集的日志传输至elasticsearch集群
▷ 通过kibana展示日志
实验架构
▷ 服务器配置
▷ 架构图
我自己的实验ip:el-192.1168.93.31。192.168.93.38。192.168.93.39 filebeat:192.168.93.40 kibana:192.168.93.32
后边都已此为准
EFK软件安装
版本说明
▷ elasticsearch 7.3.2
▷ filebeat 7.3.2
▷ kibana 7.3.2
注意事项
▷ 三个组件版本必须一致
▷ elasticsearch必须3台以上且总数量为单数
安装路径
▷ /opt/elasticsearch
▷ /opt/filebeat
▷ /opt/kibana
elasticsearch安装:3台es均执行相同的安装步骤
mkdir -p /opt/software && cd /opt/software
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz
tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz
mv elasticsearch-7.3.2 /opt/elasticsearch
useradd elasticsearch -d /opt/elasticsearch -s /sbin/nologin
mkdir -p /opt/logs/elasticsearch
chown elasticsearch.elasticsearch /opt/elasticsearch -R
chown elasticsearch.elasticsearch /opt/logs/elasticsearch -R
# 限制一个进程可以拥有的VMA(虚拟内存区域)的数量要超过262144,不然elasticsearch会报max virtual memory areas vm.max_map_count [65535] is too low, increase to at least [262144]
echo "vm.max_map_count = 655350" >> /etc/sysctl.conf
sysctl -p
filebeat安装
mkdir -p /opt/software && cd /opt/software
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.3.2-linux-x86_64.tar.gz
mkdir -p /opt/logs/filebeat/
tar -zxvf filebeat-7.3.2-linux-x86_64.tar.gz
mv filebeat-7.3.2-linux-x86_64 /opt/filebeat
kibana安装
mkdir -p /opt/software && cd /opt/software
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.3.2-linux-x86_64.tar.gz
tar -zxvf kibana-7.3.2-linux-x86_64.tar.gz
mv kibana-7.3.2-linux-x86_64 /opt/kibana
useradd kibana -d /opt/kibana -s /sbin/nologin
chown kibana.kibana /opt/kibana -R
nginx安装(用于生成日志,被filebeat收集)
# 只在192.168.1.11安装
yum install -y nginx
/usr/sbin/nginx -c /etc/nginx/nginx.conf
elasticsearch配置
▷ 192.168.1.31 /opt/elasticsearch/config/elasticsearch.yml
# 集群名字
cluster.name: my-application
# 节点名字
node.name: 192.168.1.31
# 日志位置
path.logs: /opt/logs/elasticsearch
# 本节点访问IP
network.host: 192.168.1.31
# 本节点访问
http.port: 9200
# 节点运输端口
transport.port: 9300
# 集群中其他主机的列表
discovery.seed_hosts: ["192.168.1.31", "192.168.1.32", "192.168.1.33"]
# 首次启动全新的Elasticsearch集群时,在第一次选举中便对其票数进行计数的master节点的集合
cluster.initial_master_nodes: ["192.168.1.31", "192.168.1.32", "192.168.1.33"]
# 启用跨域资源共享
http.cors.enabled: true
http.cors.allow-origin: "*"
# 只要有2台数据或主节点已加入集群,就可以恢复
gateway.recover_after_nodes: 2
▷ 192.168.1.32 /opt/elasticsearch/config/elasticsearch.yml
# 集群名字
cluster.name: my-application
# 节点名字
node.name: 192.168.1.32
# 日志位置
path.logs: /opt/logs/elasticsearch
# 本节点访问IP
network.host: 192.168.1.32
# 本节点访问
http.port: 9200
# 节点运输端口
transport.port: 9300
# 集群中其他主机的列表
discovery.seed_hosts: ["192.168.1.31", "192.168.1.32", "192.168.1.33"]
# 首次启动全新的Elasticsearch集群时,在第一次选举中便对其票数进行计数的master节点的集合
cluster.initial_master_nodes: ["192.168.1.31", "192.168.1.32", "192.168.1.33"]
# 启用跨域资源共享
http.cors.enabled: true
http.cors.allow-origin: "*"
# 只要有2台数据或主节点已加入集群,就可以恢复
gateway.recover_after_nodes: 2
▷ 192.168.1.33 /opt/elasticsearch/config/elasticsearch.yml
# 集群名字
cluster.name: my-application
# 节点名字
node.name: 192.168.1.33
# 日志位置
path.logs: /opt/logs/elasticsearch
# 本节点访问IP
network.host: 192.168.1.33
# 本节点访问
http.port: 9200
# 节点运输端口
transport.port: 9300
# 集群中其他主机的列表
discovery.seed_hosts: ["192.168.1.31", "192.168.1.32", "192.168.1.33"]
# 首次启动全新的Elasticsearch集群时,在第一次选举中便对其票数进行计数的master节点的集合
cluster.initial_master_nodes: ["192.168.1.31", "192.168.1.32", "192.168.1.33"]
# 启用跨域资源共享
http.cors.enabled: true
http.cors.allow-origin: "*"
# 只要有2台数据或主节点已加入集群,就可以恢复
gateway.recover_after_nodes: 2
filebeat配置
192.168.1.11 /opt/filebeat/filebeat.yml
# 文件输入
filebeat.inputs:
# 文件输入类型
- type: log
# 开启加载
enabled: true
# 文件位置
paths:
- /var/log/nginx/access.log
# 自定义参数
fields:
type: nginx_access # 类型是nginx_access,和上面fields.type是一致的
# 输出至elasticsearch
output.elasticsearch:
# elasticsearch集群
hosts: ["http://192.168.1.31:9200",
"http://192.168.1.32:9200",
"http://192.168.1.33:9200"]
# 索引配置
indices:
# 索引名
- index: "nginx_access_%{+yyy.MM}"
# 当类型是nginx_access时使用此索引
when.equals:
fields.type: "nginx_access"
# 关闭自带模板
setup.template.enabled: false
# 开启日志记录
logging.to_files: true
# 日志等级
logging.level: info
# 日志文件
logging.files:
# 日志位置
path: /opt/logs/filebeat/
# 日志名字
name: filebeat
# 日志轮转期限,必须要2~1024
keepfiles: 7
# 日志轮转权限
permissions: 0600
kibana配置
192.168.1.21 /opt/kibana/config/kibana.yml
# 本节点访问端口
server.port: 5601
# 本节点IP
server.host: "192.168.1.21"
# 本节点名字
server.name: "192.168.1.21"
# elasticsearch集群IP
elasticsearch.hosts: ["http://192.168.1.31:9200",
"http://192.168.1.32:9200",
"http://192.168.1.33:9200"]
启动服务
# elasticsearch启动(3台es均启动)
sudo -u elasticsearch /opt/elasticsearch/bin/elasticsearch
# filebeat启动
/opt/filebeat/filebeat -e -c /opt/filebeat/filebeat.yml -d "publish"
# kibana启动
sudo -u kibana /opt/kibana/bin/kibana -c /opt/kibana/config/kibana.yml
上面的启动方法是位于前台运行。systemd配置方法,会在《EFK教程》系列后续文章中提供,敬请关注!
在这里启动时我遇到的问题是el和kibana启动不了
解决办法引用下边
主要出现下面三个错误
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3780] for user [esyonghu] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-12-12T21:54:57,353][INFO ][o.e.n.Node ] [PlbSkhz] stopping ...
[2018-12-12T21:54:57,413][INFO ][o.e.n.Node ] [PlbSkhz] stopped
[2018-12-12T21:54:57,413][INFO ][o.e.n.Node ] [PlbSkhz] closing ...
[2018-12-12T21:54:57,473][INFO ][o.e.n.Node ] [PlbSkhz] closed
[2018-12-12T21:54:57,488][INFO ][o.e.x.m.j.p.NativeController] [PlbSkhz] Native controller process has stopped - no new native processes can be started
解决方法
[root@localhost ~]# vi /etc/security/limits.conf
在文件的末尾加上我们之前创建的用户
elasticsearchsoft nofile 65536
elasticsearch hard nofile 65536
elasticsearch soft nproc 4096
elasticsearch hard nproc 4096
进入到下面文件夹
[root@localhost ~]# cd /etc/security/limits.d
[root@localhost limits.d]# ll
total 4
-rw-r--r--. 1 root root 191 Nov 6 2016 20-nproc.conf
[root@localhost limits.d]# vi 20-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
* soft nproc 4096
root soft nproc unlimited
~
~
将上面内容的*号改成创建时创建的用户名
# See rhbz #432903 for reasoning.
esyonghu soft nproc 4096
root soft nproc unlimited
修改下面文件加上内容
[root@localhost security]# vi /etc/sysctl.conf
vm.max_map_count = 655360
对于上面的内容让其生效
[root@localhost security]# sysctl -p
vm.max_map_count = 655360
原文链接:https://blog.csdn.net/zhanghe687/article/details/84979833
记得el服务器的内存最低也是4G不然会各种报错,CPU最好为2,处理器为4.
还有记得全部关闭防火墙。
kibana界面配置
1️⃣ 使用浏览器访问192.168.1.21:5601,看到以下界面表示启动成功
2️⃣ 点"Try our sample data"
3️⃣ "Help us improve the Elastic Stack by providing usage statistics for basic features. We will not share this data outside of Elastic"点"no”
4️⃣ "Add Data to kibana"点"Add data"
5️⃣ 进入视图
测试
访问nginx,生成日志
curl -I "http://192.168.1.11"
在kibana上查看数据
1️⃣ 创建索引模板
2️⃣ 输入你要创建的索引模板的名字
3️⃣ 查看之前CURL的数据
https://www.cnblogs.com/fzxiaomange/p/efk-getstart.html 文章来源
转载他人的efk搭建文章后边有链接和地址的更多相关文章
- 云端搭建Linux学习环境 链接https://edu.aliyun.com/article/19 (阿里云ECS服务器 )课堂
云端搭建Linux学习环境 链接https://edu.aliyun.com/article/19 1. 开通云服务器 2 1.包年包月 按量付费(适合测试数据的时候) 2 2.地域 服务器数 ...
- android黑科技系列——解析公众号文章消息和链接文章消息自动打开原理
一.辅助功能方案分析 关于WX的各种功能插件已经非常普遍了,而现在的插件都是依赖于Xposed框架进行的,所以个人觉得WX应该在这方便应对Xposed框架的使用防护,防止插件满天飞的现象,本文来介绍一 ...
- 文章目录&友情链接
文章目录&友情链接 1:<公告:本博客开始写博文了> 2.本人网络图书馆
- 【转载】Docker+Kubernetes 干货文章精选
主要涉及到以下关键字: K8S.Docker.微服务.安装.教程.网络.日志.存储.安全.工具.CI/CD.分布式.实践.架构等: 以下盘点2018年一些精选优质文章! 漫画形式: 漫画:小黄人学 S ...
- [转载] Redis集群搭建最佳实践
转载自http://blog.csdn.net/sweetvvck/article/details/38315149?utm_source=tuicool 要搭建Redis集群,首先得考虑下面的几个问 ...
- (转载) android快速搭建项目积累
android快速搭建项目积累 2016-04-05 20:07 519人阅读 评论(0) 收藏 举报 分类: android优化(8) Rx技术(5) 版权声明:本文为博主原创文章,未经博主 ...
- [转载]Sublime Text 3 搭建 React.js 开发环境
[转载]Sublime Text 3 搭建 React.js 开发环境 Sublime有很强的自定义功能,插件库很庞大,针对新语言插件更新很快,配合使用可以快速搭建适配语言的开发环境. 1. babe ...
- [转载]在Windows下搭建Android开发环境
http://jingyan.baidu.com/article/bea41d437a41b6b4c51be6c1.html 在Windows下搭建Android开发环境 | 浏览:30780 | 更 ...
- docker微服务部署之:二、搭建文章微服务项目
docker微服务部署之:一,搭建Eureka微服务项目 一.新增demo_article模块,并编写代码 右键demo_parent->new->Module->Maven,选择M ...
随机推荐
- 重启uwsgi
sudo pkill -f uwsgi -9 uwsgi --ini mysite.uwsgi.ini
- hdu 6044 : Limited Permutation (2017 多校第一场 1012) 【输入挂 组合数学】
题目链接 参考博客: http://blog.csdn.net/jinglinxiao/article/details/76165353 http://blog.csdn.net/qq_3175920 ...
- 【leetcode】486. Predict the Winner
题目如下: Given an array of scores that are non-negative integers. Player 1 picks one of the numbers fro ...
- 第三代DRDS分布式SQL引擎全新发布
DRDS (阿里云分布式关系型数据库服务,https://www.aliyun.com/product/drds)于 4 月 30 号发布了 5.3 版本,这是一个年度大更新.主要带来了以下特性: 性 ...
- 方法返回前面有if - else if - else ,最终返回值是?
-(NSString *)testA{ int a = ?; ) { return @"a大于5"; } ) { return @"a不大于5"; } retu ...
- php stristr()函数 语法
php stristr()函数 语法 作用:返回一个字符串在另一个字符串中开始位置到结束的字符串,不区分大小写.直线电机厂家怎么样? 语法:stristr(string,search,before_s ...
- 20180708-Java修饰符
public class className{ //...} private boolean myFlag;static final double weeks = 9.5;protected stat ...
- NOIp 图论算法专题总结 (1):最短路、最小生成树、最近公共祖先
系列索引: NOIp 图论算法专题总结 (1) NOIp 图论算法专题总结 (2) NOIp 图论算法专题总结 (3) 最短路 Floyd 基本思路:枚举所有点与点的中点,如果从中点走最短,更新两点间 ...
- JDBC链接Mysql失败
错误信息:Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionExc ...
- 16/7/14-MySQL-关键字
Mysql 关键字-保留字 转载:http://linux.it.net.cn/e/data/mysql/2014/1202/9460.html 时间:2014-12-02 13:09来源:linux ...