初学ELK - elk部署

一、简介

ELK是3个开源软件组合,分别是 Elasticsearch ,Logstash,Kibana

Elasticsearch :是个开源分布式搜索引擎,提供搜集、分析、存储数据三大功能。它的特点有:分布式,零配置,自动发现,索引自动分片,索引副本机制,restful风格接口,多数据源,自动搜索负载等。主要负责将日志索引并存储起来,方便业务方检索查询。

Logstash : 主要是用来日志的搜集、分析、过滤日志的工具,支持大量的数据获取方式。一般工作方式为c/s架构,client端安装在需要收集日志的主机上,server端负责将收到的各节点日志进行过滤、修改等操作在一并发往elasticsearch上去。是一个日志收集、过滤、转发的中间件,主要负责将各条业务线的各类日志统一收集、过滤后,转发给 Elasticsearch 进行下一步处理。

Kibana :Kibana可以为 Logstash 和 ElasticSearch 提供的日志分析友好的 Web 界面,可以帮助汇总、分析和搜索重要数据日志。

二、部署

主机环境:

系统:CentOS Linux release 7.9.2009 (Core)

地址:192.168.92.42

本次是单机部署所有软件,确保主机配置不少于2c4g

软件包均为rpm包

  1. 软件包下载地址

    Elasticsearchhttps://www.elastic.co/cn/downloads/elasticsearch
    Logstashhttps://www.elastic.co/cn/downloads/logstash
    Kibanahttps://www.elastic.co/cn/downloads/kibana

  2. 主机环境配置

bash 复制代码
# 关闭防火墙
systemctl disable firewalld --now
# 关闭selinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# 关闭swap分区 注释掉/etc/fstab和swap分区有关的信息
swapoff -a
# 	设置主机名
hostnamectl set-hostname elk
su
# 下载相关软件
yum -y install lrzsz vim net-tools zip unzip bzip2 wget
  1. 安装Elasticsearch

Elasticsearch 依赖JDK8环境,所以在安装前需要安装jdk1.8,Centos可以直接使用yum安装:
yum -y install java-1.8.0-openjdk-devel

下载软件包:

复制代码
cd /opt
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.13.1-x86_64.rpm

安装

复制代码
 rpm -ivh elasticsearch-8.13.1-x86_64.rpm

修改配置文件

bash 复制代码
[root@elk opt]# vim /etc/elasticsearch/elasticsearch.yml
# 集群名称
cluster.name: ELK
# 当前节点名称
node.name: elk
# 对外通信地址 
network.host: 192.168.92.42
# web端口,默认9200
http.port: 9200
# 安全
xpack.security.enabled: false
# 开启跨域
http.cors.enabled: true                                                 
http.cors.allow-origin: "*"

启动Elasticsearch

复制代码
systemctl enable elasticsearch --now

访问测试

安装elasticsearch-head插件

elasticsearch-head这个插件是es提供的一个用于图形化界面查看的一个插件工具,可以安装上这个插件之后,通过这个插件来实现我们通过浏览器查看es当中的数据

下载地址:https://github.com/mobz/elasticsearch-head,如果能克隆下来,就克隆下来,前期是需要安装git, 不能克隆就下载下来上传到服务器上。

上传到/opt目录,并解压

配置node环境

powershell 复制代码
cd /opt
wget https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.gz
tar -zcvf node-v12.13.1-linux-x64.tar.gz
mv node-v12.13.1-linux-x64  node
# 配置环境变量
echo 'export NODE_HOME=/usr/local/node' >> /etc/profile
echo 'export PATH=$NODE_HOME/bin:$PATH' >> /etc/profile
source /etc/profile
# 查看版本
node -v
npm -v

进入到 /opt/elasticsearch-head-master 目录进行构建

复制代码
cd /opt/elasticsearch-head-master
npm install
powershell 复制代码
npm WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: 
npm WARN notice [SECURITY] debug has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=debug&version=0.7.4 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm ERR! Unexpected end of input at 1:2096
npm ERR! 7c1a1bc21c976bb49f3ea","tarball":"https://registry.npmjs.org/safer-bu
npm ERR!                                                                      ^
npm ERR! A complete log of this run can be found in:
npm ERR!     /opt/bigdata/soft/.npm/_logs/2020-11-27T14_35_39_453Z-debug.log

以上错误可以忽略

修改配置文件(注意自己的目录)

复制代码
cd /opt/elasticsearch-head-master/node_modules/grunt/bin
powershell 复制代码
# 启动
[root@elk bin]# ./grunt server
>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?

Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://192.168.92.42:9100

后台运行 nohup ./grunt server &> /dev/null &

访问测试

由于我没有搭建集群所以,集群健康值是灰色的

相关推荐
一点事12 小时前
windows:ELK搭建(单机)
windows·elk·jenkins
没有bug.的程序员2 天前
Spring Boot 日志管理:从 Logback 深度配置到 ELK 万亿级日志中枢实战
java·spring boot·elk·logback·日志·管理
橙露4 天前
日志分析与监控:ELK栈(Elasticsearch+Logstash+Kibana)搭建全流程指南
大数据·elk·elasticsearch
信创天地5 天前
国产化数据库深度运维:性能调优与故障排查实战指南
运维·数据库·安全·elk·自动化·rabbitmq
yangminlei8 天前
Elasticsearch 全面解析:从原理到实战的分布式搜索引擎指南
java·elk
我爱娃哈哈8 天前
SpringBoot + ELK + MDC:分布式系统日志追踪,快速定位跨服务调用链问题
spring boot·后端·elk
信创天地11 天前
信创环境下数据库与中间件监控实战:指标采集、工具应用与告警体系构建
java·运维·数据库·安全·elk·华为·中间件
信创天地11 天前
信创日志全流程管控:ELK国产化版本与华为日志服务实战应用
运维·安全·elk·华为·rabbitmq·dubbo
三不原则15 天前
实战:ELK 分析 AI 系统日志,快速定位接口报错问题
人工智能·elk
BullSmall15 天前
ELK 单机版日志系统【一键自动化部署脚本 + 完整配套配置】
运维·elk·自动化