CentOS 7 安装 ELK 7 简明文档
由于本人在安装和使用elk的过程中看了网上大量的文档而踩坑无数,遂把自己心得总结如下,做成简明文档供有需要之人。如果发现什么问题欢迎和我交流。
准备工作
ELK简介
Logstash 对各个服务的日志进行采集、过滤、推送。
Elasticsearch 存储 Logstash 传送的结构化数据,提供给 Kibana 。
Kibana 提供用户 UIweb 页面进行,数据展示和分析形成图表等。
操作系统:CentOS7 安装模式如下图。(推荐)
IP:192.168.31.200
如果是内网使用,安装好系统之后可以关闭防火墙,并且关闭开机启动。
systemctl stop firewalld
systemctl disable firewalld
软件准备 (以7.9.1版本为例,软件版本需统一.)
下载以下软件到服务器.
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.1-x86_64.rpm
https://artifacts.elastic.co/downloads/logstash/logstash-7.9.1.rpm
https://artifacts.elastic.co/downloads/kibana/kibana-7.9.1-x86_64.rpm
p.s
mkdir /download
cd /download
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.1-x86_64.rpm
wget https://artifacts.elastic.co/downloads/logstash/logstash-7.9.1.rpm
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.9.1-x86_64.rpm
国内下载较慢,可以选择用迅雷下载到PC,然后使用SFTP上传到服务器。
开始安装
首先安装java环境
yum -y install java-1.8.0-openjdk.x86_64
安装E.L.K.
rpm -ivh elasticsearch-7.9.1-x86_64.rpm
rpm -ivh logstash-7.9.1.rpm
rpm -ivh kibana-7.9.1-x86_64.rpm
p.s 使用rpm安装会自动创建好service,使用这种安装方式配置文件一般在/etc/xxx/下,
程序文件一般在/usr/share/xxx/下。
配置elasticsearch
1.创建elasticsearch所需的目录,并授权。
mkdir -p /data/elasticsearch
mkdir -p /data/log/elasticsearch
chown -R elasticsearch.elasticsearch /data/elasticsearch
chown -R elasticsearch.elasticsearch /data/log/elasticsearch
2.编辑elasticsearch配置
vi /etc/elasticsearch/elasticsearch.yml
3.编辑以下内容
cluster.name: xxx #群集名称