日志分析系统

               日志分析系统

日志分析系统
Centos01:服务器
Centos02:服务器
Centos05:客户端
一.配置elk
1.elastic search(elk光盘,centos01,02)
安装
[root@centos ~]# rpm -ivh /mnt/elasticsearch-5.5.0.rpm
在这里插入图片描述

修改配置文件
[root@centos ~]# cp /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.bak
[root@centos ~]# vim /etc/elasticsearch/elasticsearch.yml
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

启动服务设置开机自动启动
[root@centos ~]# systemctl daemon-reload
[root@centos ~]# systemctl start elasticsearch.service
[root@centos ~]# systemctl enable elasticsearch.service
在这里插入图片描述

监听端口
[root@centos ~]# netstat -anptu | grep 9200
在这里插入图片描述

02配置文件:
[root@centos ~]# scp root@192.168.100.10:/etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/
在这里插入图片描述

[root@centos ~]# vim /etc/elasticsearch/elasticsearch.yml
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

修改hosts文件
[root@centos ~]# vim /etc/hosts
在这里插入图片描述
在这里插入图片描述

2.elastic sear-head(centos01,02)
安装依赖node
[root@centos ~]# tar zxvf /mnt/node-v8.2.1.tar.gz -C /usr/src/
在这里插入图片描述

[root@centos ~]# mv /usr/src/node-v8.2.1/ /usr/local/node
[root@centos ~]# cd /usr/local/node/
[root@centos node]# ./configure && make && make install
在这里插入图片描述

[root@centos ~]# tar jxvf /mnt/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/src/
在这里插入图片描述

安装phantomjs
[root@centos ~]# cd /usr/src/phantomjs-2.1.1-linux-x86_64/
[root@centos phantomjs-2.1.1-linux-x86_64]# cd bin/
[root@centos bin]# cp phantomjs /usr/local/bin/
[root@centos bin]# chmod +x /usr/local/bin/phantomjs
在这里插入图片描述

移动Elasticsearch-head
[root@centos ~]# tar zxvf /mnt/elasticsearch-head.tar.gz -C /usr/src/
在这里插入图片描述

[root@centos ~]# mv /usr/src/elasticsearch-head/ /usr/local/
在这里插入图片描述

[root@centos ~]# cd /usr/local/elasticsearch-head/
[root@centos elasticsearch-head]# npm install
在这里插入图片描述

修改elasticsearch跨域访问
[root@centos ~]# vim /etc/elasticsearch/elasticsearch.yml
在这里插入图片描述
在这里插入图片描述

[root@centos ~]# /etc/init.d/elasticsearch restart
在这里插入图片描述

监听端口
[root@centos ~]# netstat -anptu | grep 9200
在这里插入图片描述

修改elasticsearch-head配置文件监听9200
[root@centos ~]# vim /usr/local/elasticsearch-head/_site/app.js
在这里插入图片描述

搜索9200
在这里插入图片描述
在这里插入图片描述

修改elasticsearch-head配置文件监听9100端口
[root@centos ~]# vim /usr/local/elasticsearch-head/Gruntfile.js
在这里插入图片描述

搜索9100
在这里插入图片描述在这里插入图片描述

启动服务
[root@centos ~]# cd /usr/local/elasticsearch-head/
[root@centos elasticsearch-head]# npm run start&
在这里插入图片描述

监听9100端口
[root@centos ~]# netstat -anptu | grep 9100
在这里插入图片描述

验证:火狐浏览器
在这里插入图片描述
在这里插入图片描述

3.安装配置logstash(centos05,系统盘)
安装http
[root@centos05 ~]# yum -y install httpd
在这里插入图片描述

[root@centos05 ~]# echo “www.benet.com” > /var/www/html/index.html
[root@centos05 ~]# systemctl start httpd
[root@centos05 ~]# systemctl enable httpd
在这里插入图片描述

安装logstash
02拷贝文件
[root@centos ~]# scp /mnt/logstash-5.5.1.rpm root@192.168.100.50:/root/
在这里插入图片描述

[root@centos05 ~]# rpm -ivh logstash-5.5.1.rpm
在这里插入图片描述

优化命令
[root@centos05 ~]# ln -s /usr/share/logstash/bin/logstash /usr/local/bin/
在这里插入图片描述

启动服务设置开机自动启动
[root@centos05 ~]# systemctl start logstash
[root@centos05 ~]# systemctl enable logstash
在这里插入图片描述

插入测试数据
[root@centos05 ~]# logstash -e ‘input { stdin{}} output { stdout{}}’
在这里插入图片描述
在这里插入图片描述

[root@centos05 ~]# logstash -e ‘input { stdin{}} output { stdout{ codec=>rubydebug}}’
在这里插入图片描述
在这里插入图片描述

[root@centos05 ~]# logstash -e ‘input { stdin{}} output { elasticsearch{hosts => [“192.168.100.10:9200”]}}’
在这里插入图片描述
在这里插入图片描述

验证:
在这里插入图片描述

4.采集apache成功日志(centos05)
设置允许日志读取
[root@centos05 ~]# chmod o+r /var/log/httpd/access_log
在这里插入图片描述

创建采集日志文件
[root@centos05 ~]# touch /etc/logstash/conf.d/apache.conf
[root@centos05 ~]# chmod +x /etc/logstash/conf.d/apache.conf
在这里插入图片描述

查看日志所在位置
[root@centos05 ~]# ls -ld /var/log/httpd/access_log
在这里插入图片描述

input {
file {
path => “/var/log/httpd/access_log”
type => “access”
start_position => “beginning”
}
}
output {

    if[type] == "access" {
            elasticsearch {
                    hosts => ["192.168.100.10:9200"]
                    index => "access-%{+YYYY.MM.dd}"
            }
    }

}
在这里插入图片描述

检查日志采集文件是否有问题
[root@centos05 ~]# logstash -f /etc/logstash/conf.d/apache.conf
在这里插入图片描述

注:系统日志文件位置
[root@centos05 ~]# ls -ld /var/log/httpd/access_log
在这里插入图片描述

重新启动logstash
[root@centos05 ~]# systemctl restart logstash.service
在这里插入图片描述

验证:
在这里插入图片描述
在这里插入图片描述

5.安装配置kibana(centos01)
安装
[root@centos ~]# rpm -ivh /mnt/kibana-5.5.1-x86_64.rpm
在这里插入图片描述

修改主配置文件
[root@centos ~]# vim /etc/kibana/kibana.yml

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

启动服务
[root@centos ~]# systemctl start kibana
[root@centos ~]# systemctl enable kibana
在这里插入图片描述

验证:
在这里插入图片描述
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值