Logstash安装logstash-integration-jdbc
1.版本说明
- logstash7.10.1
2.前置条件
- logstash-integration-jdbc是使用ruby语言开发的,因此需安装gem,gem是Ruby的一个包管理器
3.替换国内镜像
gem source --remove https://rubygems.org/
gem source --add https://gems.ruby-china.com/
**注:**网上主要说替换为https://ruby.taobao.org/和https://gems.ruby-china.org/,会出现Error fetching http://gems.ruby-china.org/的问题。taobao的ruby仓库镜像不可用了,而ruby-china.org由于备案问题需改成.com进行访问。
# 查看镜像
gem sources -l
# 替换后的结果如下
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
4.修改Gemfile数据源地址
进入logstash,修改Gemfile
sudo vim Gemfile
将Gemfile的source换成https://gems.ruby-china.com/
source "https://gems.ruby-china.com/"
修改Gemfile.lock文件,将GEM remote修改为https://gems.ruby-china.com/
# 我的在33行左右
GEM
remote: https://gems.ruby-china.com/
5.安装logstash-integration-jdbc
- 老版本使用的是logstash-input-jdbc,安装时报如下错
plugin 'logstash-input-jdbc' is already provided by 'logstash-integration-jdbc'
所以我们直接安装logstash-integration-jdbc即可
# 进入logstash的bin目录
./logstash-plugin install logstash-integration-jdbc
# 显示如下信息即安装成功
Validating logstash-integration-jdbc
Installing logstash-integration-jdbc
Installation successful
6.运行时可能会报错Pipelines YAML文件为空
运行时,报如下错误
Pipelines YAML file is empty.
在config目录下修改pipelines.yml,将一下内容的注释去掉
- pipeline.id: test
pipeline.workers: 1
pipeline.batch.size: 1
config.string: "input { generator {} } filter { sleep { time => 1 } } out put { stdout { codec => dots } }"
- pipeline.id: another_test
queue.type: persisted
path.config: "/tmp/logstash/*.config"
重新跑自己写好的文件即可
./logstash -f ../config/test.conf