ELK-Kibana 部署

目录

[一、在 node1 节点上操作](#一、在 node1 节点上操作)

[1.1.安装 Kibana](#1.1.安装 Kibana)

[1.2.设置 Kibana 的主配置文件](#1.2.设置 Kibana 的主配置文件)

[1.3.启动 Kibana 服务](#1.3.启动 Kibana 服务)

[1.4.验证 Kibana](#1.4.验证 Kibana)

[1.5.将 Apache 服务器的日志(访问的、错误的)添加到 ES 并通过 Kibana 显示](#1.5.将 Apache 服务器的日志(访问的、错误的)添加到 ES 并通过 Kibana 显示)

[1.6. 浏览器访问](#1.6. 浏览器访问)

二、部署Filebeat+ELK(ELFK)

[2.1.安装 Filebeat](#2.1.安装 Filebeat)

[2.2.设置 Kibana 的主配置文件](#2.2.设置 Kibana 的主配置文件)


一、在 node1 节点上操作

1.1.安装 Kibana

css 复制代码
[root@node1 elasticsearch-head]# cd /opt
[root@node1 opt]# rz -E		#上传软件包 kibana-5.5.1-x86_64.rpm
[root@node1 opt]# rpm -ivh kibana-5.5.1-x86_64.rpm

1.2.设置 Kibana 的主配置文件

css 复制代码
[root@node1 opt]# vim /etc/kibana/kibana.yml
##2行,取消注释,kibana服务的默认监听端口为5601
server.port: 5601
##7行,取消注释,设置kibana的监听地址,0.0.0.0代表所有地址
server.host: "0.0.0.0"
##21行,取消注释,设置和ES建立连接的地址和端口
elasticsearch.url: "http://192.168.190.101:9200"
##30行,取消注释,设置在ES中添加.kibana索引
kibana.index: ".kibana"

1.3.启动 Kibana 服务

css 复制代码
[root@node1 opt]# systemctl start kibana.service 
[root@node1 opt]# systemctl enable kibana.service 
[root@node1 opt]# netstat -natp | grep 5601
tcp        0      0 0.0.0.0:5601            0.0.0.0:*               LISTEN      82765/node     

1.4.验证 Kibana

浏览器访问 http://192.168.190.101:5601

第一次登录需要添加一个 ES 索引

点击 create 创建

索引添加完成后,点击 Discover 按钮可查看图表信息及日志信息

1.5.将 Apache 服务器的日志(访问的、错误的)添加到 ES 并通过 Kibana 显示

apache 服务器

css 复制代码
 
[root@apache opt]# vim /etc/logstash/conf.d/apache_log.conf
 
input {
    file{
        path => "/etc/httpd/logs/access_log"
        type => "access"
        start_position => "beginning"
    }
    file{
        path => "/etc/httpd/logs/error_log"
        type => "error"
        start_position => "beginning"
    }
}
output {
    if [type] == "access" {
        elasticsearch {
            hosts => ["192.168.190.101:9200"]
            index => "apache_access-%{+YYYY.MM.dd}"
        }
    }
	if [type] == "error" {
        elasticsearch {
            hosts => ["192.168.190.101:9200"]
            index => "apache_error-%{+YYYY.MM.dd}"
        }
    }
}
[root@apache opt]# cd /etc/logstash/conf.d
[root@apache conf.d]# /usr/share/logstash/bin/logstash -f apache_log.conf
······
23:42:13.199 [Api Webserver] INFO  logstash.agent - Successfully started Logstash API endpoint {:port=>9601}

1.6. 浏览器访问

浏览器访问 http://192.168.190.101:9100 查看索引是否创建

可能你只看到了 apache-error,那是因为 access 需要访问 httpd 页面才能生成

浏览器访问 http://192.168.190.101:5601 登录 kibana,添加 apache_access-* 和 apache_error-* 索引,查看日志信息

二、部署Filebeat+ELK(ELFK)

2.1.安装 Filebeat

css 复制代码
#上传软件包 filebeat-6.2.4-linux-x86_64.tar.gz 到/opt目录
cd /opt
rz -E
tar zxvf filebeat-6.6.0-linux-x86_64.tar.gz
mv filebeat-6.6.0-linux-x86_64 /usr/local/filebeat
 

2.2.设置 Kibana 的主配置文件

css 复制代码
[root@filebeat opt]# cd /usr/local/filebeat/
[root@filebeat filebeat]# cp filebeat.yml filebeat.yml.bak
[root@filebeat filebeat]# vim filebeat.yml
 
filebeat.prospectors:
##21行,指定log类型,从日志文件中读取消息
- type: log
##24行,开启日志收集功能,默认为false
  enabled: true
##28行,指定监控的日志文件
    - /var/log/*.log
##29行,添加收集/var/log/messages
    - /var/log/messages
##31行,添加以下内容,注意格式
  fields: 
    service_name: filebeat
    log_type: log
    service_id: 192.168.190.105
#-------------------------- Elasticsearch output ------------------------------
该区域内容全部注释
#----------------------------- Logstash output --------------------------------
##157行,取消注释
output.logstash:
##159行,取消注释,指定logstash的IP和端口号
  hosts: ["192.168.190.101:5044"]
 
[root@filebeat filebeat]# ./filebeat -e -c filebeat.yml
#启动filebeat,-e记录到stderr并禁用syslog /文件输出,-c指定配置文件

css 复制代码
[root@apache ~]# cd /etc/logstash/conf.d/
[root@apache conf.d]# vim logstash.conf
 
input {
    beats {
        port => "5044"
    }
}
output {
    elasticsearch {
        hosts => ["192.168.190.101:9200"]
        index => "%{[fields][service_name]}-%{+YYYY.MM.dd}"
    }
    stdout {
        codec => rubydebug
    }
}
 
[root@apache conf.d]# /usr/share/logstash/bin/logstash -f apache_log.conf 

浏览器验证

css 复制代码
浏览器访问,登录 Kibana 测试,
浏览器访问 http://192.168.190.101:5601 登录 Kibana

单击"Create Index Pattern"按钮添加索引"filebeat-*"

单击 "create" 按钮创建,单击 "Discover" 按钮可查看图表信息及日志信息。

相关推荐
wydxry41 分钟前
在断网情况下,网线直接连接 Windows 笔记本和 Ubuntu 服务器进行数据传输
运维·docker·容器
智象科技44 分钟前
智象科技赋能金融、证券行业 IT 运维
大数据·运维·网络·数据库·科技·金融·智能运维
King's King1 小时前
自动化立体仓库设计PPT
运维·自动化
Learn-Share_HY1 小时前
[Linux]如何設置靜態IP位址?
linux·运维·tcp/ip·ubuntu·static ip
Everbrilliant892 小时前
Ubuntu系统下交叉编译Android的X265库
linux·运维·ubuntu·x265交叉编译·android x265·ffmpeg x265
我不要放纵2 小时前
LVS集群搭建
linux·服务器·lvs
阿巴~阿巴~2 小时前
自主Shell命令行解释器
linux·运维·服务器
许白掰2 小时前
Linux入门篇学习——借助 U 盘或 TF 卡拷贝程序到开发板上
linux·学习·借助 u 盘拷贝程序到开发板上·借助 tf卡拷贝程序到开发板上
小周学学学2 小时前
docker安装与简单项目上手
运维·docker·容器
枷锁—sha3 小时前
跨站请求伪造漏洞(CSRF)详解
运维·服务器·前端·web安全·网络安全·csrf