elk日志分析

elk是由三个软件组成接下来我们将一 一介绍

一、ELK日志分析
1、elk的作用和特点
1】elk作用
集中化日志存储管理和分析
2】elk的特点
开源
方便配置日志高可用
方便集中化管理日志
放改变惊醒日志分析

2、ELK三个组件
1】elasticsearch
开源日志搜索引擎
采用分布式设计
需要配置群集保证可靠性
零配置自动实现负载均衡和故障转移

2】logstash
日志采集
安装在客户端上
将日志上传到elasticsearch
3】kibana
支持图形化读取elasticsearch日志
通过浏览器访问
兼容性强

3、logstash组件类型
1】shipper
日志采集
实时监控客户端日志变化
搜索并格式化日志传输到elasticsearch
2】lndexer
存储
搜索的日志保存到slasticsearch服务器
3】broker
接受多个shipper传输的日志 上传到elasticsearch
4】search and storage
允许刻画端读取或者存储数据
5】web interface
访问日志服务器的入口
支持web页面查看日志

接下来我们开启三台服务器进行实验
二、配置elk
1、安装elasticsarche

1】安装
[root@centos01 ~]# rpm -ivh /mnt/elasticsearch-5.5.0.rpm 
2】修改elasticsarcher
[root@centos01 ~]# vim /etc/elasticsearch/elasticsearch.yml 
	17 cluster.name: my-elk	群集名字
 	23 node.name: centos01	第一个节点计算机名字
	43 bootstrap.memory_lock: false	不锁定内存
   	network.host: 192.168.100.20		监听ip
 	59 http.port: 9200		监听端口
 	68 discovery.zen.ping.unicast.hosts: ["centos01", "centos02"]
			将两个节点添加到群集中
3】启动elasticsearch服务
[root@centos01 ~]# systemctl daemon-reload 
[root@centos01 ~]# sudo systemctl enable elasticsearch.service 
[root@centos01 ~]# systemctl start elasticsearch.service 

(这里我们需要修改hosts文件添加两台节点的ip)

2、配置图形化管理elasticserch

1】移动安装位置elasticsearch
[root@centos01 src]# mv elasticsearch-head/ /usr/local/
2】安装依赖程序node
[root@centos src]# mv node-v8.2.1/ /usr/local/
[root@centos01 node-v8.2.1]# ./configure && make && make install
3】安装依赖程序phantomjs
[root@centos bin]# mv phantomjs /usr/local/bin/
4】安装npm
[root@centos01 bin]# cd /usr/local/elasticsearch-head/
[root@centos01 elasticsearch-head]# npm install
(有一次没安装也起来了)

5】修改elasticsearch配置文件
[root@centos01 ~]# vim /etc/elasticsearch/elasticsearch.yml 
	http.cors.enabled: true
	http.cors.allow-origin: "*"

7】修改elasticsearch-head配置文件
[root@centos01 ~]# vim /usr/local/elasticsearch-head/_site/app.js 
4329                         this.base_uri = this.config.base_uri || this.prefs.
     get("app-base_uri") || "http://192.168.100.10:9200";

8】修改elasticsearch-head监听端口
[root@centos ~]# vim /usr/local/elasticsearch-head/Gruntfile.js 
 options: {
                                        hostname:'192.168.100.20',
                                        port: 9100,
                                        base: '.',
                                        keepalive: true



9】开启服务器
[root@centos ~]# cd  /usr/local/elasticsearch-head/
[root@centos ~]# npm run start &

以上配置在第二台服务器上进行重复配置

3、客户端配置安装logstash

1】安装logstash
[root@centos01 ~]# rpm -ivh /mnt/logstash-5.5.1.rpm 
2】优化命令
[root@centos01 ~]# ln -s /usr/share/locale/bin/* /usr/local/bin/
3】编写采集apache日志
[root@centos05 ~]# vim /etc/logstash/conf.d/apache_log.conf 
input {
        file {
                path => "/var/log/httpd/access_log"
                type => "access"
                start_position => "beginning"
        }
output {
        if [type] = = "access" {
                elsticsearch {
                        hosts => ["192.168.100.10:9200"]
                        index => "apache_access-%{+YYYY.MM.dd}"
        }
}
6】添加执行权限
[root@centos05 ~]# chmod +x /etc/logstash/conf.d/apache_log.conf 
7】采集日志
[root@centos05 ~]# logstash -f /etc/logstash/conf.d/apache_log.conf
8】启动服务
[root@centos05 ~]# systemctl start logstash

4、部署kibana(在一台日志服务器上安装就行)

1】安装
[root@centos01 ~]# rpm -ivh /mnt/kibana-5.5.1-x86_64.rpm 
2】启动服务器
[root@centos01 ~]# systemctl start kibana
3】修改配置文件
[root@centos01 ~]# vim /etc/kibana/kibana.yml
server.port: 5601
server.host: "192.168.100.10"
elasticsearch.url: "http://192.168.100.10:9200"

验证
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值