下载最新版logstash
https://www.elastic.co/cn/downloads/logstash
解压缩
tar zxvf logstash-7.12.1-linux-x86_64.tar.gz
下载jdk1.8
tar zxvf jdk-8u291-linux-x64.tar.gz
编辑启动文件logstash、logstash.lib.sh、logstash-plugin
在首行添加
export JAVA_CMD="/usr/java/jdk1.8.0_291/bin/"
export JAVA_HOME="/usr/java/jdk1.8.0_291/"
安装jdbc插件
生产环境不能联网;虽然logstash是开箱即用,即解压后就能使用,但是对于logstash-input-jdbc插件来说,一般是在线安装的(./logstash-plugin install logstash-input-jdbc)
就算你是在github上https://github.com/logstash-plugins/logstash-input-jdbc/下载源码,修改Gemfile,也要联网来安装。所以对于不能联网的机子来说必须使用
./logstash-plugin install file:///path/to/logstash-input-jdbc.zip
这种方式来安装。但是官方并没有提供像x-pack一样的离线安装包。那么我们就需要在一台能联网的机子上先在线安装好logstash-input-jdbc
插件,然后使用logstash-plugin命令里面的打包离线安装包命令将插件打包为离线的,再传送到生产环境就可以了
一个能联网的机子上解压logstash后,在线安装jdbc插件:
# ./logstash-plugin install logstash-input-jdbc
Validating logstash-input-jdbc
Installing logstash-input-jdbc
Installed successfulllogstash根目录下的以下目录查看对应的插件版本:
以下命令查看logstash-plugin的离线打包命令[root@YK2T-TYSFW017 logstash-7.12.1]# cd bin
[root@YK2T-TYSFW017 bin]# ./logstash-plugin -h
Using JAVA_HOME defined java: /usr/java/jdk1.8.0_291/
WARNING, using JAVA_HOME while Logstash distribution comes with a bundled JDK
Usage:bin/logstash-plugin [OPTIONS] SUBCOMMAND [ARG] ...Parameters:SUBCOMMAND subcommand[ARG] ... subcommand argumentsSubcommands:list List all installed Logstash pluginsinstall Install a Logstash pluginremove Remove a Logstash pluginupdate Update a pluginpack Package currently installed plugins, Deprecated: Please use prepare-offline-pack insteadunpack Unpack packaged plugins, Deprecated: Please use prepare-offline-pack insteadgenerate Create the foundation for a new pluginuninstall Uninstall a plugin. Deprecated: Please use remove insteadprepare-offline-pack Create an archive of specified plugins to use for offline installationOptions:-h, --help print help
[root@YK2T-TYSFW017 bin]# 开始打包,打包时不需要联网
./logstash-plugin prepare-offline-pack --overwrite --output logstash-output-jdbc.zip logstash-output-jdbc# ./logstash-plugin prepare-offline-pack --overwrite --output logstash-input-jdbc.zip logstash-input-jdbc
Offline package created at: logstash-input-jdbc.zipYou can install it with this command `bin/logstash-plugin install file:///usr/share/logstash/bin/logstash-input-jdbc.zip`将此zip文件上传至不能联网服务器的目录,使用上述命令安装即可
./bin/logstash-plugin install --no-verify file:///logstash-output-jdbc.zip
更改配置文件,启动即可
/app/logstash-7.12.1/bin/logstash -f /app/logstash-7.12.1/config/logstashserver-redis-rds.conf -t