logstash快速安装插件并打离线包

一、背景


1. 生产环境是不能直接联网的

2. 要给 Logstash 安装上 logstash-input-jdbc 插件用来读取 Mysql 数据到 ES 进行全文检索

二、原生安装

# /usr/share/logstash/bin/logstash-plugin install logstash-input-jdbc
Validating logstash-input-jdbc
Installing logstash-input-jdbc
WARNING: can not set Session#timeout=(0) no session context

能看到输出的任一更新都需要非常久 - 一两个小时没反应,几乎不能完成任务。


三、改镜像源安装


办法:给 Ruby 加上国内的镜像站:https://gems.ruby-china.org/,替代https://rubygems.org。

可以直接跳到第5步操作。

1. 可选
发现 Elastic 官网 ping 不通,给加上。

# echo "54.235.82.130   artifacts.elastic.co" >> /etc/hosts

2. 安装Gem并更新

# yum install -y gem
# gem -v
2.0.14.1
# gem update --system
# gem -v
2.6.13

3. 检查并修改镜像源

# gem sources -l
*** CURRENT SOURCES ***
 
https://rubygems.org/
# gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
https://gems.ruby-china.org/ added to sources
https://rubygems.org/ removed from sources

4. 安装 bundle 并更改镜像源

# gem install bundler
# bundle config mirror.https://rubygems.org https://gems.ruby-china.org

上面的步骤方便以后安装更多插件的时候设置默认镜像源。
5. 修改 logstash的 gem 镜像源

# head /usr/share/logstash/Gemfile
 
# This is a Logstash generated Gemfile.
# If you modify this file manually all comments and formatting will be lost.
 
source "https://rubygems.org"
gem "logstash-core", :path => "./logstash-core"
......

更改默认的 https://rubygems.org 为https://gems.ruby-china.org
Gemfile.jruby-1.9.lock文件不用改,会自动更新。

6. 安装 logstash-input-jdbc

# /usr/share/logstash/bin/logstash-plugin install logstash-input-jdbc
Validating logstash-input-jdbc
Installing logstash-input-jdbc
Installation successful

终于正常的验证安装好了,保存在/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-jdbc-4.2.2。

四、打离线包

这里安装好了,那么就可以打个离线的 zip 包,方便生产环境直接安装。离线包将包含所有依赖的包。

# cd /usr/share/logstash/bin
# ./logstash-plugin prepare-offline-pack --overwrite --output logstash-input-jdbc-4.2.2.zip logstash-input-jdbc    
Offline package created at: logstash-input-jdbc-4.2.2.zip
 
You can install it with this command `bin/logstash-plugin install file:///usr/share/logstash/bin/logstash-input-jdbc-4.2.2.zip`

OK,zip 包搞定,传到生产上。

五、离线包安装

# ./logstash-plugin install file:///tmp/logstash-input-jdbc-4.2.2

# ./logstash-plugin list

参考链接:https://blog.csdn.net/evandeng2009/article/details/78036054

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值