elasticsearch+logstash记录日志

elasticsearch+logstash记录日志

记录一下一个记录日志的组合拳工具。

安装elasticsearch

1、下载elasticsearch

地址:https://github.com/elastic/elasticsearch/releases/tag/v7.16.3

2、解压之后将解压后的文件放到:/usr/local目录下

3、elasticsearch不能以root用户运行,添加一个用户:useradd esuser

4、给/usr/local/elasticsearch-7.16.2这个文件直接权力给esuser这个用户:chown elastic /usr/local/elasticsearch-7.16.2 -R

5、进入esuser角色:su esuser

6、进入到/usr/local/elasticsearch-7.16.2/bin运行elasticsearch:./elasticsearch -d运行

7、验证:浏览器输入IP:9200

安装elasticsearch-head

直接去谷歌上搜索这个名字的插件,安装最新版,安装完之后在浏览器最顶上输入你的服务地址,如:http://IP:9200/

安装logstash

1、下载logstash

地址:https://www.elastic.co/cn/downloads/past-releases/logstash-7-6-2

2、解压后进入修改config下的文件test.conf:

input {
  beats {
    port => 5044
  }
  file {
        path => "/root/xxx/log/INFO.log"  ##锁定哪个文件下的log文件
        type => "INFO"					##log类型
        start_position => "beginning"	 ##从文件的哪个位置开始记录
  }
    file {
        path => "/root/lixueming/log/ERROR.log"
        type => "ERROR"
        start_position => "beginning"
  }
}

output {
  elasticsearch {
    hosts => ["http://127.0.0.1:9200"] ##es的地址
    index => "sche1_log"			  ##索引名称
    #user => "esuser"
    #password => "changeme"
  }
}

3、进入bin目录下启动logstash:

命令:-f 指定config文件的地址

nohup ./logstash -f /root/logstash-7.16.2/config/logstash-test.conf --config.reload.automatic &
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值