查看是否已安装gem:gem -v
如未安装,请安装:yum install gem
安装完成查看一下版本号:gem -v
查看当前镜像源:gem sources -l
显示https://rubygems.org/时,请更改镜像源,更改之前需要删除该源:gem sources --remove https://rubygems.org/
添加可以使用的镜像源:gem sources -a https://gems.ruby-china.com (当前可以使用该源)
查看更改镜像源是否成功:gem sources -l
成功时候,可以进行一下操作,安装logstash-jdbc
在logstatsh的安装目录下的bin目录中:./logstash-plugin list --verbose 查看当前安装的logstash可以使用的logstash-jdbc的版本号
在该目录下执行安装:./logstash-plugin install logstash-input-jdbc
等待安装,该过程有些缓慢。
测试:
需要有MySQL驱动包(mysql-connector-java)版本不限。放在logstash安装根目录下即可
编写测试文件:在logstash根目录下/config-mysql/logstash-jdbc-mysql.conf
内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42input { stdin { } jdbc { # 数据库 jdbc_connection_string => "jdbc:mysql://localhost:3306/test" # 用户名密码 jdbc_user => "root" jdbc_password => "123456" # jar包的位置 jdbc_driver_library => "/home/elasticsearch/logstash/mysql-connector-java-5.1.30.jar" # mysql的Driver jdbc_driver_class => "com.mysql.jdbc.Driver" jdbc_paging_enabled => "true" jdbc_page_size => "50000" #statement_filepath => "config-mysql/test02.sql" statement => "select * from test" schedule => "* * * * *" #索引的类型 type => "id" } } filter { json { source => "message" remove_field => ["message"] } } output { elasticsearch { hosts => "elasticsearch服务器IP:9200" # index名 index => "id" # 需要关联的数据库中有有一个id字段,对应索引的id号 document_id => "%{id}" } stdout { codec => json_lines } }
进行测试:./bin/logstash -f config-mysql/logstash-jdbc-mysql.conf
等待数据库中的数据被读取出来,然后加载进索引。
最后
以上就是俊秀酒窝最近收集整理的关于安装logstash-jdbc的全部内容,更多相关安装logstash-jdbc内容请搜索靠谱客的其他文章。
发表评论 取消回复