基于Centos7系统一键部署EFK服务,值得收藏

原创
ithorizon 7个月前 (10-16) 阅读数 47 #Linux

基于Centos7系统一键部署EFK服务,值得收藏

随着大数据和云计算的飞速进步,日志管理变得越来越重要。ELK(Elasticsearch、Logstash、Kibana)是一个强劲的日志收集、存储、搜索和分析平台。而EFK则是ELK的扩展,它包括Elasticsearch、Fluentd和Kibana三个组件。本文将为您介绍怎样在Centos7系统上一键部署EFK服务,让您轻松实现日志的集中管理和分析。

一、准备工作

在开端部署EFK之前,请确保您的Centos7系统满足以下要求:

  • 操作系统:Centos 7
  • 内存:至少2GB
  • 存储空间:至少10GB
  • 网络:确保网络畅通

二、安装Elasticsearch

Elasticsearch是EFK中的核心组件,负责存储和检索数据。

1. 下载Elasticsearch安装包

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.1.tar.gz

2. 解压安装包

tar -zxvf elasticsearch-7.10.1.tar.gz

3. 将Elasticsearch移动到系统目录

mv elasticsearch-7.10.1 /usr/local/elasticsearch

4. 设置Elasticsearch为系统服务

cd /usr/local/elasticsearch

vi bin/elasticsearch.in.sh

在文件中找到并修改以下配置:

# 增多以下配置

# -Xms512m

# -Xmx512m

保存并退出文件。

5. 启动Elasticsearch服务

systemctl start elasticsearch

6. 设置Elasticsearch服务开机自启

systemctl enable elasticsearch

三、安装Fluentd

Fluentd是一个灵活的日志记录工具,可以将各种类型的日志发送到Elasticsearch。

1. 安装Fluentd

yum install -y epel-release

yum install -y fluentd

2. 创建Fluentd配置文件

vi /etc/fluentd/fluent.conf

在文件中添加以下配置:

source tail

match **.log

format json

flush 10

buffer_time 2

buffer_queue_size 8

write fluentd-elasticsearch

保存并退出文件。

3. 启动Fluentd服务

systemctl start fluentd

4. 设置Fluentd服务开机自启

systemctl enable fluentd

四、安装Kibana

Kibana是EFK中的可视化组件,用于搜索、分析和可视化Elasticsearch中的数据。

1. 下载Kibana安装包

wget https://artifacts.elastic.co/downloads/kibana/kibana-7.10.1-x86_64.rpm

2. 安装Kibana

yum install -y kibana-7.10.1-x86_64.rpm

3. 配置Kibana

vi /etc/kibana/kibana.yml

在文件中找到并修改以下配置:

# 设置Kibana的Elasticsearch地址

elasticsearch.host: "localhost"

保存并退出文件。

4. 启动Kibana服务

systemctl start kibana

5. 设置Kibana服务开机自启

systemctl enable kibana

五、验证EFK服务

在浏览器中输入以下地址,即可访问Kibana的Web界面:

http://localhost:5601

在Kibana中,您可以创建索引模式、搜索日志、创建可视化等操作。

本文由IT视界版权所有,禁止未经同意的情况下转发

文章标签: Linux


热门