安装ELK(centos7最小化)

本文档详细介绍了在CentOS7最小化环境下安装ELK(Elasticsearch, Logstash, Kibana)的过程。首先,通过同步时间和安装必要的软件作为准备工作。接着,依次进行Elasticsearch的安装,包括先安装Java环境,然后上传并解压ELK压缩包。再安装配置Logstash,用于数据采集和处理,并进行测试。最后,安装Kibana以实现数据的可视化。实验环境为两台2G内存的虚拟机,通过关闭防火墙和SELinux简化安装步骤。" 114324354,1937693,IPFS存储与目录结构详解,"['分布式', 'ipfs', 'DHT', 'P2P', '文件系统']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

## ELK 官网:

https://www.elastic.co/cn/what-is/elk-stack

## ELK是什么:

“ELK”是三个开源项目的首字母缩写,这三个项目分别是:Elasticsearch、Logstash 和 Kibana。Elasticsearch 是一个搜索和分析引擎。Logstash 是服务器端数据处理管道,能够同时从多个来源采集数据,转换数据,然后将数据发送到诸如 Elasticsearch 等“存储库”中。Kibana 则可以让用户在 Elasticsearch 中使用图形和图表对数据进行可视化。
实验环境:两台虚拟机(最小化安装,内核2G)

130: elasticsearch+ logstash
132: kibana

准备工作

关闭防火墙和selinux(最好第一步就做,方便)

systemctl stop firewalld
setenforce 0

同步时间

yum -y install ntp
ntpdate pool.ntp.org

安装所需软件

yum -y install vim vi net-tools unzip

开始安装

1、安装elasticsearch(先安装java环境)

上传ELK压缩包并解压

unzip ELK
进入压缩包
cd ELK
[root@localhost ELK]# ll
总用量 624860
-rw-r--r--. 1 root root 114065764 3月  12 2019 elasticsearch-6.6.2.rpm
-rw-r--r--. 1 root root 169983496 11月 19 2017 jdk-8u131-linux-x64_.rpm
-rw-r--r--. 1 root root 185096267 3月  12 2019 kibana-6.6.2-x86_64.rpm
-rw-r--r--. 1 root root 170703770 11月 13 2019 logstash-6.6.0.rpm
安装javaj环境
[root@localhost ELK]# rpm -ivh jdk-8u131-linux-x64_.rpm 
安装配置elasticsearch
[root@localhost ELK]# yum -y install elasticsearch-6.6.2.rpm
[root@localhost ELK]# systemctl daemon-reload
[root@localhost ELK]# systemctl enable elasticsearch
[root@localhost ELK]# systemctl start elasticsearch
检测是否启动
[root@localhost ELK]# netstat -anpt |grep java
tcp6       0      0 192.168.159.130:9200    :::*                    LISTEN      11327/java          
tcp6       0      0 192.168.159.130:9300    :::*                    LISTEN      11327/java
#这里的俩个端口:
#一个为内部访问
#一个为客户访问
[root@localhost ELK]# vim /etc/elasticsearch/elasticsearch.yml 
[root@localhost ELK]# cat /etc/elasticsearch/elasticsearch.yml |grep -v "^#"
cluster.name: rjc
node.name: node-1
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 192.168.159.130
http.port: 9200
[root@localhost ELK]# systemctl start elasticsearch
[root@localhost ELK]# netstat -anpt | grep java
[root@localhost ELK]# tailf /var/log/elasticsearch/rjc.log

2、安装配置logstash(测试检测messages+secure)

[root@localhost ELK]# yum -y install logstash-6.6.0.rpm 
[root@localhost ELK]# cd /etc/logstash/conf.d/
[root@localhost conf.d]# vim messages.conf

#input日志输入模块:日志的获取方式和路径input
input {
	file {
		path => "/var/log/messages"
		type => "messages-log"
                start_position => "beginning"
	}
}
#output日志的输出模块:导出你的数据
output {
	elasticsearch{
		hosts => "192.168.159.130:9200"
		index => "messages_log-%{+YYYY.MM.dd}"
	}
}

[root@localhost conf.d]# vim secure.conf 

input {
	file {
		path => "/var/log/secure"
		type => "secure-log"
                start_position => "beginning"
	}
}

output {
	elasticsearch{
		hosts => "192.168.159.130:9200"
		index => "secure_log-%{+YYYY.MM.dd}"
	}
}

[root@localhost conf.d]# cd /etc/logstash/
[root@localhost logstash]# vim pipelines.yml
- pipeline.id: message
  path.config: "/etc/logstash/conf.d/message.conf"
- pipeline.id: secure
  path.config: "/etc/logstash/conf.d/secure.conf"
[root@localhost logstash]# chmod -R 777 /var/log/
[root@localhost logstash]# systemctl start logstash
[root@localhost logstash]# tailf /var/log/logstash/logstash-plain.log
#全部为info则视为成功进行下一步。
#如果logstash 无法启动报错:

在这里插入图片描述
在这里插入图片描述

3、安装kibana

[root@localhost logstash]# cd 
[root@localhost ~]# cd ELK
[root@localhost ELK]# scp kibana-6.6.2-x86_64.rpm root@服务端ip:/root/
切换到服务端
[root@localhost ~]# yum -y install kibana-6.6.2-x86_64.rpm 
[root@localhost ~]# vim /etc/kibana/kibana.yml 
[root@localhost ~]# cat /etc/kibana/kibana.yml | grep -v "^#" | sed '/^$/d'
server.port: 5601
server.host: "192.168.159.132"
elasticsearch.hosts: ["http://192.168.159.130:9200"]
[root@localhost ~]# systemctl enable kibana
[root@localhost ~]# systemctl start kibana
[root@localhost ~]# yum -y install net-tools
[root@localhost ~]# netstat -anpt |grep 5601
tcp        0      0 192.168.159.132:5601    0.0.0.0:*               LISTEN      9740/node           
[root@localhost ~]# 

效果

效果
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值