zl程序教程

您现在的位置是:首页 >  IT要闻

当前栏目

【ES三周年】ELK日志分析平台 | 记一次基于鲲鹏麒麟操作系统分析平台搭建过程

2023-03-07 09:42:55 时间

引入

鲲鹏认证-Kylin麒麟操作系统-ELK日志分析平台

开篇

想必大家都有一个疑问?何为ELK Stack?它又能够给我们带来什么?

综述

ELK为三个开源项目的首字母缩写,分别对应是:Elasticsearch、Logstash、Kibana,由这三个软件及其相关的组件可以打造大规模日志实时处理系统。

实战

go...

硬件

操作系统

配置编译环境

首先,将jdk安装包传输到ARM服务器/usr/local/java 目录下

在文件末尾加入

使用命令更新配置的文件

source /etc/profile

测试安装配置成功

安装elasticsearch

获取安装文件到 /usr/local/ 

创建用户及用户组

验证elasticsearch是否配置正确

在浏览器访问:http://ip:9200/

或在终端输入命令:

curl ip:9200

监控elasticsearch集群状态:http://ip:9200/_cluster/health?pretty=true

若status为green,表示在正常运行,若status为yellow,表示副本分片丢失,若status为red,表示主分片丢失。

常见问题FAQ

安装logstash

获取安装文件

cd ../
rm -rf jruby-complete-9.2.11.1

运行测试

新建配置文件,读取指定日志文件,发送到elasticsearch

vim /etc/logs/system-log.conf
input {
    file {
        path => "/var/log/messages"           
        type => "systemlog"
        start_position => "beginning"  
        stat_interval => "2"   
    }
}
output {
    elasticsearch {
        hosts => ["ip:9200"]            
        index => "logstash-%{type}-%{+YYYY.MM.dd}"
    }
}

指定文件启动logstash

./logstash-7.8.0/bin/logstash -f /etc/logs/system-log.conf

安装kibana

获取安装文件

cd /usr/local
wget https://mirrors.huaweicloud.com/kibana/7.8.0/kibana-7.8.0-linux-x86_64.tar.gz
tar -zxvf kibana-7.8.0-linux-x86_64.tar.gz    #解压
server.host: "ip"    #监听地址
server.port: 5601    #监听端口
elasticsearch.hosts: ["http://ip:9200"]    #elasticsearch服务器地址 i18n.locale: "zh-CN"    #修改为中文

日志收集

通过logstash收集系统message日志

在 /usr/local/logstash-7.8.0/config 下创建随意名称的 logstash 配置文件 example.conf

需要注意的问题是:通过logstash收集别的日志文件,前提需要logstash用户对被收集的日志文件有读的权限并对要写入的文件有写的权限......