ELK日志分析系统

标题1、ELK的作用和特点

1)ELK的作用 
	集中化管理日志
	对日志配置群集避免单节点故障,日志丢失
2)ELK特点 
	开源 
	不支持日志分析
	支持集中化管理

标题2、ELK组成

1)elasticsearch
	开源的日志搜索和存储引擎
	采用分布式设计
	自动配置日志群集
	支持零配置负载均衡功能
2)logstash
	负责日志采集
	对客户端日志进行采集、格式化、输出到elasticsearch存储
	安装在客户端上
3)kibana
	支持图形化界面查看日志
	兼容强
	安装在服务器端

标题3、logstash组成

1)shipper
	日志采集
	实时监控日志变化
	将日志格式化上传到elasticsearch
2)indexer
	日志存储
	创建索引 
3)broker
	接收多个shipper采集的日志
4)search and stroage
	允许用户搜索和存储日志信息
5)web interface
	支持kibana访问平台中的数据
	支持WEB页面查看日志

配置ELK

解压node

[root@centos01 ~]# tar zxvf /mnt/node-v8.2.1.tar.gz -C /usr/src/

指定安装位置

[root@centos01 ~]# mv /usr/src/node-v8.2.1/ /usr/local/node

编译安装
【时间略长,耐心等待】

[root@centos01 ~]# ./configure && make && make install

安装 Elasticsearch

[root@centos01 ~]# rpm -ivh /mnt/elasticsearch-5.5.0.rpm 

在这里插入图片描述
修改配置文件

[root@centos01 ~]# vim /etc/elasticsearch/elasticsearch.yml

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
启动服务设置开机自动启动

[root@centos01 ~]# systemctl daemon-reload
[root@centos01 ~]# systemctl start elasticsearch
[root@centos01 ~]# systemctl enable elasticsearch

在这里插入图片描述
修改hosts文件

[root@centos01 ~]# vim /etc/hosts

在这里插入图片描述
安装依赖node

[root@centos01 ~]# tar zxvf /mnt/node-v8.2.1.tar.gz -C/usr/src/

指定安装位置

[root@centos01 ~]# mv /usr/src/node-v8.2.1/ /usr/local/node

编译安装

[root@centos02 node]# ./configure && make && make install

安装phantomjs

[root@centos01 bin]# cp phantomjs /usr/local/bin/
[root@centos01 bin]# chmod +x /usr/local/bin/phantomjs 

在这里插入图片描述
移动elasticsearch-head

[root@centos01 ~]# tar zxvf /mnt/elasticsearch-head.tar.gz -C /usr/src/
[root@centos01 ~]# mv /usr/src/elasticsearch-head/ /usr/local/
[root@centos01 ~]# cd /usr/local/elasticsearch-head/
[root@centos01 elasticsearch-head]# npm install

在这里插入图片描述
修改elasticsearch跨域访问

[root@centos01 ~]# vim /etc/elasticsearch/elasticsearch.yml
[root@centos01 ~]# /etc/init.d/elasticsearch restart

在这里插入图片描述
修改修改elasticsearch-head配置文件监听9100端口

[root@centos01 ~]# vim /usr/local/elasticsearch-head/Gruntfile.js

在这里插入图片描述
启动服务

[root@centos01 ~]# cd /usr/local/elasticsearch-head/
[root@centos01 elasticsearch-head]# npm run start&

监听9100端口

[root@centos01 ~]# netstat -anptu | grep 9100

在这里插入图片描述
访问在这里插入图片描述
在这里插入图片描述
安装http

[root@centos03 ~]# yum -y install httpd
[root@centos03 ~]# echo "www.benet.com" > /var/www/html/index.html
[root@centos03 ~]# systemctl start httpd
[root@centos03 ~]# systemctl enable httpd

安装logstash

[root@centos03 ~]# rpm -ivh logstash-5.5.1.rpm

在这里插入图片描述
优化命令

[root@centos03 ~]# ln -s /usr/share/logstash/bin/logstash /usr/local/bin/

启动服务设置开机自动启动

[root@centos03 ~]# systemctl start logstash
[root@centos03 ~]# systemctl enable logstas

在这里插入图片描述
插入测试数据

[root@centos03 ~]# logstash -e 'input { stdin{}} output { stdout{}}'

在这里插入图片描述
提交数据

[root@centos03 ~]# logstash -e 'input { stdin{}} output { stdout{ codec=>rubydebug}}'

在这里插入图片描述
[root@centos03 ~]# logstash -e ‘input { stdin{}} output { elasticsearch{hosts => [“192.168.100.10:9200”]}}’
在这里插入图片描述
在这里插入图片描述
设置允许日志读取

[root@centos03 ~]# chmod o+r /var/log/httpd/access_log

创建采集日志文件

[root@centos03 ~]# touch /etc/logstash/conf.d/apache.conf
[root@centos03 ~]# chmod +x /etc/logstash/conf.d/apache.conf
[root@centos03 ~]# vim /etc/logstash/conf.d/apache.conf

在这里插入图片描述
检查日志采集文件是否有问题

[root@centos03 ~]# logstash -f /etc/logstash/conf.d/apache.conf

重新启动logstash

[root@centos03 ~]# systemctl restart logstash.service

安装

[root@centos01 ~]# rpm -ivh /mnt/kibana-5.5.1-x86_64.rpm

在这里插入图片描述
修改主配置文件

[root@centos01 ~]# vim /etc/kibana/kibana.yml 

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
启动服务

[root@centos01 ~]# systemctl start kibana
[root@centos01 ~]# systemctl enable kibana

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值