栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

elasticsearch+logstash记录日志

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 &
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/710433.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号