logstash5.x安装及简单运用
Logstash requires Java 8. Java 9 is not supported.
1、检测是否安装了java环境
[root@node3 ~]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
2、安装logstash,这里采用rpm安装
https://artifacts.elastic.co/downloads/logstash/logstash-5.6.1.rpm
yum install logstash
查看生成了哪些文件,查看logstash的执行文件位置:
/etc/logstash/conf.d
/etc/logstash/jvm.options
/etc/logstash/log4j2.properties
/etc/logstash/logstash.yml
/etc/logstash/startup.options
/usr/share/logstash/CHANGELOG.md
/usr/share/logstash/CONTRIBUTORS
/usr/share/logstash/Gemfile
/usr/share/logstash/Gemfile.jruby-1.9.lock
/usr/share/logstash/LICENSE
/usr/share/logstash/NOTICE.TXT
/usr/share/logstash/bin/cpdump
/usr/share/logstash/bin/ingest-convert.sh
/usr/share/logstash/bin/logstash
/usr/share/logstash/bin/logstash-plugin
/usr/share/logstash/bin/logstash-plugin.bat
/usr/share/logstash/bin/logstash.bat
/usr/share/logstash/bin/logstash.lib.sh
/usr/share/logstash/bin/ruby
/usr/share/logstash/bin/setup.bat
/usr/share/logstash/bin/system-install
/usr/share/logstash/data
配置文件:
1、配置jvm
[root@node3 conf.d]# /usr/share/logstash/bin/logstash -e 'input { stdin {} } output { stdout {} }'
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
Could not find log4j2 configuration at path //usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console
提示warning,解决办法:
mkdir -p /usr/share/logstash/config/
ln -s /etc/logstash/* /usr/share/logstash/config
chown -R logstash:logstash /usr/share/logstash/config/
bin/logstash -e 'input { stdin { } } output { stdout {} }'
如果logstash不适用命令行执行,而是作为一个服务:
[root@node3 conf.d]# cat file.conf
input {
file {
path => ["/var/log/messages"]
start_position => "beginning"
}
} output {
stdout {
codec => rubydebug
}
}
[root@node3 conf.d]# /usr/share/logstash/bin/logstash -f file.conf
2、多个log日志的输入、
[root@node3 conf.d]# cat file_more_choose.conf
input {
file {
path => ["/var/log/messages"]
start_position => "beginning"
}
file {
path => ["/var/log/elasticsearch/my-elastic.log"]
start_position => "beginning"
}
} output {
stdout {
codec => rubydebug
}
}
但是发现只打印出elastic的日志,message的日志没有stdout,收集的日志是增量的,之前收集的日志已经存在sincedb中了,所以会默认从之后开始存
Path of the sincedb database file (keeps track of the current position of monitored log files) that will be written to disk. The default will write sincedb files to <path.data>/plugins/inputs/file
NOTE: it must be a file path and not a directory path,这是一段sincedb_path的解释
-t, --config.test_and_exit Check configuration for valid syntax and then exit.
(default: false)
-r, --config.reload.automatic Monitor configuration changes and reload
whenever it is changed.
NOTE: use SIGHUP to manually reload the config
(default: false)
[root@node3 conf.d]# /usr/share/logstash/bin/logstash -f file.conf -t
Sending Logstash's logs to /var/log/logstash which is now configured via log4j2.properties
Configuration OK
3、以elasticsearch插件输出:
input {
file {
path => ["/var/log/logstash/logstash-plain.log"]
start_position => "beginning"
type => "logstash"
}
} output {
elasticsearch {
hosts => ["192.168.44.134:9200"]
index => "logstash-log"
codec => rubydebug
}
}
4、根据插件type来定义输出插件:
[root@node3 conf.d]# cat type.conf
input {
file {
path => ["/var/log/logstash/logstash-plain.log"]
start_position => "beginning"
type => "logstash_2"
}
file {
path => ["/var/log/messages"]
start_position => "beginning"
type => "system"
}
} output {
if [type] == "logstash_2" {
elasticsearch {
hosts => ["192.168.44.134:9200"]
index => "logstash_2"
codec => rubydebug
}
}
if [type] == "system" {
stdout {
codec => rubydebug
}
}
}
现在向messages日志中echo一段话:
echo "`date +%F`" >> /var/log/messages
然后开始执行:
[root@node3 conf.d]# /usr/share/logstash/bin/logstash -f type.conf
Sending Logstash's logs to /var/log/logstash which is now configured via log4j2.properties
{
"@version" => "1",
"host" => "node3",
"path" => "/var/log/messages",
"@timestamp" => 2017-09-20T08:19:05.782Z,
"message" => "2017-09-20", 这是刚刚echo新增的内容
"type" => "system"
}
查看es中的索引是否有生成:
logstash5.x安装及简单运用的更多相关文章
- (转)python requests的安装与简单运用
requests是python的一个HTTP客户端库,跟urllib,urllib2类似,那为什么要用requests而不用urllib2呢?官方文档中是这样说明的: python的标准库urllib ...
- MongoDB在Windows下安装、Shell客户端的使用、Bson扩充的数据类型、MongoVUE可视化工具安装和简单使用、Robomongo可视化工具(2)
一.Windows 下载安装 1.去http://www.mongodb.org/downloads下载,mongodb默认安装在C:\Program Files\MongoDB目录下,到F:\Off ...
- python requests的安装与简单运用
requests是python的一个HTTP客户端库,跟urllib,urllib2类似,那为什么要用requests而不用urllib2呢?官方文档中是这样说明的: python的标准库urllib ...
- memcache的windows下的安装和简单使用
原文:memcache的windows下的安装和简单使用 memcache是为了解决网站访问量大,数据库压力倍增的解决方案之一,由于其简单实用,很多站点现在都在使用memcache,但是memcach ...
- 【RabbitMQ】RabbitMQ在Windows的安装和简单的使用
版本说明 使用当前版本:3.5.4 安装与启动 在官网上下载其Server二进制安装包,在Windows上的安装时简单的,与一般软件没什么区别. 安装前会提示你,还需要安装Erlang,并打开下载页面 ...
- Thrift的安装和简单演示样例
本文仅仅是简单的解说Thrift开源框架的安装和简单使用演示样例.对于具体的解说,后面在进行阐述. Thrift简述 ...
- libmemcached安装及简单例子
libmemcached安装及简单例子 1.下载安装libmemcached $ wget http://launchpad.net/libmemcached/1.0/0.44/+download/ ...
- [hadoop系列]Pig的安装和简单演示样例
inkfish原创,请勿商业性质转载,转载请注明来源(http://blog.csdn.net/inkfish ).(来源:http://blog.csdn.net/inkfish) Pig是Yaho ...
- Redis 安装与简单示例
Redis 安装与简单示例 一.Redis的安装 Redis下载地址如下:https://github.com/dmajkic/redis/downloads 解压后根据自己机器的实际情况选择32位或 ...
随机推荐
- 一 Android Studio 打包Egret App
测试环境: Android Studio 2.3.2 Egret Engine 5.0.14 Egret Support5.0.12 官网教程:http://developer.egret.com/c ...
- 《从零开始学Swift》学习笔记(Day 69)——Swift与Objective-C混合编程之语言
原创文章,欢迎转载.转载请注明:关东升的博客 在Swift语言出现之前,开发iOS或OS X应用主要使用Objective-C语言,此外还可以使用C和C++语言,但是UI部分只能使用Objective ...
- 170426、centos6.5安装 Zookeeper注册中心
注册中心服务器(192.168.3.71)配置,安装 Zookeeper: 1. 修改操作系统的/etc/hosts 文件中添加: # zookeeper servers 192.168.3.71 r ...
- jQuery Mobile 总结
转载 孟祥月 博客 http://blog.cshttp://blog.csdn.net/mengxiangyue/article/category/1313478/2dn.http://blog. ...
- Googlebot (Google Web search)
w推测“域名解析过程中,Google crawlers中首先是Googlebo中的Google Web search上阵”. +-----+----------------+------------- ...
- [LeetCode] 1.Two Sum - Swift
1. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a ...
- [报错]Fast enumeration variables cannot be modified in ARC by default; declare the variable __strong to allow this
今天写了下面的快速枚举for循环代码,从按钮数组subButtons中取出button,然后修改button的样式,在添加到view中 for (UIButton *button in subButt ...
- 机房断电导致MySQL同步1594错误
1.错误信息 Last_IO_Error: Got fatal error from master when reading data from binary log: ' at 208645951. ...
- dos常用命令【总结】
win7下有很多有用的dos命令,现在总结如下: 延伸:Linux常用命令[总结] 命令 作用 其他 ping 检查和另一台主机的连通性 ping 127.0.0.1 telnet 检查连通性 ...
- 1.如何在虚拟机ubuntu上安装hadoop多节点分布式集群
要想深入的学习hadoop数据分析技术,首要的任务是必须要将hadoop集群环境搭建起来,可以将hadoop简化地想象成一个小软件,通过在各个物理节点上安装这个小软件,然后将其运行起来,就是一个had ...