ELK+filebeat采集java日志

前言

此文章是我在生产环境下搭建ELK日志系统的记录,该日志系统主要是采集Java日志,开发人员能通过kibanaWeb页面查找相关主机的指定日志;对于Java日志,filebeat已做多行合并、过滤行处理,更精准的获取需要的日志信息,关于ELK系统的介绍,这里不再赘述。

更多信息可以访问官方网站查询:
Elasticsearch:
https://www.elastic.co/cn/products/elasticsearch
Logstash:
https://www.elastic.co/cn/products/logstash
Kibana:
https://www.elastic.co/cn/products/kibana
Filebeat:
https://www.elastic.co/cn/products/beats/filebeat

环境

主机服务类型 主机名 内存 服务
es1 test-machine 32G elasticsearch、logstash、kibana
es2 926prod 8G elasticsearch
es3 replmysql 4G elasticsearch
web1 template-centos7 16G filebeat
web2 template-centos7 16G filebeat

ELK使用的版本均为6.4.3,在下面的搭建中提供了下载地址。三台elasticsearch搭建集群处理,可靠传输。logstash、kibana搭建在同一台服务器中,资源足够不影响服务。两台web服务器为生产环境下的主机,安装filebeat软件来采集日志数据,传输至logstash服务器。

步骤

1、设置hosts

[root@test-machine /root]#cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.146 testmachine
192.168.1.60 926prod
192.168.1.62 replmysql
[root@test-machine /root]#scp /etc/hosts 926prod:/etc/hosts
[root@test-machine /root]#scp /etc/hosts replmysql:/etc/hosts

2、安装javaJDK

jdk版本需要时1.8及以上

[root@test-machine /root]#yum -y install java
[root@test-machine /root]#java -version
openjdk version "1.8.0_191"

[root@926prod /root]#yum -y install java
[root@926prod /root]#java -version
openjdk version "1.8.0_191"

[root@replmysql /root]#yum -y install java
[root@replmysql /root]#java -version
openjdk version "1.8.0_191"

3、安装elasticsearch(三台机器相同操作)

下载——安装——启动服务

[root@test-machine ~]#curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.3.tar.gz
[root@test-machine ~]#tar -xvf elasticsearch-6.4.3.tar.gz
[root@test-machine ~]#mv elasticsearch-6.4.3 /usr/local/
[root@test-machine ~]#useradd elasticsearch
[root@test-machine ~]#cd /usr/local/elasticsearch-6.4.3/
[root@test-machine bin]#chown -R elasticsearch:elasticsearch /usr/local/elasticsearch-6.4.3/

修改配置文件:

[root@test-machine /root]#grep -v "^#" /etc/elasticsearch/elasticsearch.yml
cluster.name: sunaw-cluster
node.name: test-machine
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 192.168.1.146
discovery.zen.ping.unicast.hosts: ["testmachine", "replmysql", "926prod"]
http.enabled: true
http.cors.enabled: true
http.cors.allow-origin: "*"
# 注意node.name、network.host字段,三台机填入各自的名字和ip地址

启动服务:

[root@test-machine bin]#su elasticsearch
[elasticsearch@test-machine bin]$nohup ./elasticsearch &
[elasticsearch@
  • 1
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是ELK+filebeat+sentinl的源码安装步骤: 1. 安装Java ELK需要Java运行环境,所以首先需要安装Java。可以在Oracle官网上下载适合自己系统的Java安装包,然后按照提示进行安装。 2. 安装Elasticsearch 在Elasticsearch官网上下载对应系统的安装包,解压后进入bin目录,执行以下命令启动Elasticsearch: ``` ./elasticsearch ``` 3. 安装Kibana 在Kibana官网上下载对应系统的安装包,解压后进入bin目录,执行以下命令启动Kibana: ``` ./kibana ``` 4. 安装Logstash 在Logstash官网上下载对应系统的安装包,解压后进入bin目录,执行以下命令启动Logstash: ``` ./logstash -f logstash.conf ``` 其中,logstash.conf是Logstash的配置文件。 5. 安装FilebeatFilebeat官网上下载对应系统的安装包,解压后进入bin目录,编辑filebeat.yml配置文件,配置日志收集的路径和输出到Logstash的地址,然后执行以下命令启动Filebeat: ``` ./filebeat -e -c filebeat.yml ``` 6. 安装Sentinl Sentinl是一个基于Kibana的插件,用于实现告警功能。首先需要安装Kibana插件管理工具elasticsearch-plugin,执行以下命令进行安装: ``` ./kibana-plugin install elasticsearch-plugin ``` 然后再安装Sentinl插件,执行以下命令进行安装: ``` ./kibana-plugin install https://github.com/sirensolutions/sentinl/releases/download/tag-6.4.2-0/sentinl-v6.4.2.zip ``` 7. 配置Sentinl 编辑Kibana的配置文件kibana.yml,修改以下配置: ``` sentinl:admin_email: [email protected] ``` 其中,[email protected]是管理员邮箱。 8. 启动ELK+filebeat+sentinl 依次启动Elasticsearch、Kibana、Logstash和Filebeat。然后在Kibana中打开Sentinl插件,配置告警规则即可。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值