设为首页 收藏本站
查看: 1145|回复: 0

[经验分享] filebeat+kafka+ELK5.4安装与部署

[复制链接]

尚未签到

发表于 2019-1-28 09:22:50 | 显示全部楼层 |阅读模式
  用ELK打造强大的日志分析平台,具体拓扑结构如下:
  


  

  在这里我们将进行kafka+filebeat+ELK5.4的部署
  各软件版本
jdk-8u131-linux-i586.tar.gz
filebeat-5.4.0-linux-x86_64.tar.gz
elasticsearch-5.4.0.tar.gz
kibana-5.4.0-linux-x86_64.tar.gz
logstash-5.4.0.tar.gz
kafka_2.11-0.10.0.0.tgz  1、JDK安装配置(略过)
  

  2、ELK安装与配置
创建ELK用户,并进行文件解压
1.elasticsearch配置
[elk@localhost elasticsearch-5.4.0]$ vi config/elasticsearch.yml
.....
network.host: 192.168.12.109
#
# Set a custom port for HTTP:
#
http.port: 9200
..........
保存,启动
[elk@localhost elasticsearch-5.4.0]$ nohup bin/elasticsearch &
验证
#
[elk@localhost elasticsearch-5.4.0]$ curl http://192.168.12.109:9200
{
  "name" : "aCA2ApK",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "Ea4_9kXZSaeDL1fYt4lUUQ",
  "version" : {
    "number" : "5.4.0",
    "build_hash" : "780f8c4",
    "build_date" : "2017-04-28T17:43:27.229Z",
    "build_snapshot" : false,
    "lucene_version" : "6.5.0"
  },
  "tagline" : "You Know, for Search"
}
2、kibana安装与配置
[elk@localhost kibana-5.4.0-linux-x86_64]$ vi config/kibana.yml
## Kibana is served by a back end server. This setting specifies the port to use.
server.port: 5601
# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
server.host: "192.168.12.109"
..........
# The URL of the Elasticsearch instance to use for all your queries.
elasticsearch.url: "http://192.168.12.109:9200"
..........
[elk@localhost kibana-5.4.0-linux-x86_64]$ nohup bin/kibana &
在浏览器访问  能访问即可  

  3、kafka安装与配置
  这里我们只做单机192.168.12.105部署单节点《centos kafka单包单机部署
  

  4、logstah安装与配置
[elk@localhost logstash-5.4.0]$ vi nginx.conf    这里新生成一个配置文件
input {
       kafka  {
       codec => "json"
     topics_pattern => "logstash-.*"
     bootstrap_servers => "192.168.12.105:9092"
     auto_offset_reset => "latest"
     group_id => "logstash-g1"
  }

}
filter {
    if "nginx-accesslog" in [tags] {
        grok {
                match => { "message" => "%{IPORHOST:http_host} %{IPORHOST:clientip} - %{USERNAME:remote_user} \[%{HTTPDATE:timestamp}\] \"(?:%{WORD:http_verb} %{NOTSPACE:http_request}(?: HTTP/%{NUMBER:http_version})?|%{DATA:raw_http_request})\" %{NUMBER:response} (?:%{NUMBER:bytes_read}|-) %{QS:referrer} %{QS:agent} %{QS:xforwardedfor} %{NUMBER:request_time:float} %{GREEDYDATA:traceID}"}
        }
        mutate {
                convert => ["status","integer"]
                convert => ["body_bytes_sent","integer"]
                convert => ["request_time","float"]
        }
        geoip {
                source=>"remote_addr"
        }
        date {
                match => [ "timestamp","dd/MMM/YYYY:HH:mm:ss Z"]
        }
        useragent {
                source=>"http_user_agent"
        }
}

    if "tomcat-accesslog"  in [tags] {
        grok {
           match => { "message" => "%{IPORHOST:clientip} \[%{HTTPDATE:timestamp}\] \"(?:%{WORD:http_verb} %{NOTSPACE:http_request}(?: HTTP/%{NUMBER:http_version})?|%{DATA:raw_http_request})\" %{NUMBER:response} (?:%{NUMBER:bytes_read}|-) %{QS:referrer} %{NUMBER:request_time:float} %{GREEDYDATA:traceID}"}
            }
        date {
               match => [ "timestamp","dd/MMM/YYYY:HH:mm:ss Z"]
        }
}
}
output {
    elasticsearch {
      hosts => ["192.168.12.109:9200"]
        index => "logstash-%{type}-%{+YYYY.MM.dd}"
        document_type => "%{type}"
    }
#stdout { codec => rubydebug }
}
保存,并启动
[elk@localhost logstash-5.4.0]$ nohup bin/logstash -f nginx.conf &  5、filebeat安装与配置
  将filebeat分别拷贝到需要采集的服务器,进行解压,在这里我们分别采集Nginx,tomcat日志
  Nginx服务器
[user@localhost filebeat-5.4.0-linux-x86_64]$ vi filebeat.yml
filebeat.prospectors:
- input_type: log
  paths:
    - /data/programs/nginx/logs/access.log
  tags: ["nginx-accesslog"]
  document_type: nginxaccess
tags: ["nginx-test-194"]
output.kafka:
  enabled: true
  hosts: ["192.168.12.105:9092"]
  topic: logstash-%{[type]}

[user@localhost filebeat-5.4.0-linux-x86_64]$nohup filebeat -c filebeat.yml &  tomcat服务器
[user@localhost filebeat-5.4.0-linux-x86_64]$ vi filebeat.yml
filebeat.yml
filebeat.prospectors:
- input_type: log
  paths:
    - /data/tomcat/logs/localhost_access_log*
  tags: ["tomcat-accesslog"]
  document_type: tomcataccess
tags: ["tomcat103"]
output.kafka:
  enabled: true
  hosts: ["192.168.12.105:9092"]
  topic: logstash-%{[type]}
[user@localhost filebeat-5.4.0-linux-x86_64]$nohup filebeat -c filebeat.yml &  

  完成以上,我们的平台就搭建好了,接下来我们创建索引
  输入:logstash-nginxaccess*


  输入logstash-tomcataccess*

  

  数据通过filebeat到kafka、ELK成功展示出来

  

  来张炫图


  

  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-668525-1-1.html 上篇帖子: elk日志分析filebeat配置(filebeat + logstash) 下篇帖子: ELK 软件安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表