下载
https://artifacts.elastic.co/downloads/logstash/logstash-6.7.1.tar.gz
安装
上传下载过后的压缩包到自己的服务器目录
1 2 3 4 5
| # 进入目录 cd /opt/software
# 解压到指定目录 tar -zxvf logstash-6.7.1.tar.gz -C /usr/local
|
配置
新建配置文件
1 2 3 4 5 6 7 8
| cp logstash-sample.conf logstash-test.conf
# 进入logstash数据目录 cd /usr/local/logstash-6.7.1/data # 新建结果保存目录 mkdir metadata # 新建抽取脚本目录 mkdir sql
|
修改配置文件
jdbc_driver_library: 数据库驱动存放位置
statement_filepath:抽取脚本存放位置
last_run_metadata_path:运行结果保存位置
部分配置文件
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
input { jdbc { jdbc_driver_library => "/home/xis/ojdbc8-12.2.0.1.jar" jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver" jdbc_connection_string => "jdbc:oracle:thin:@192.168.40.104:1521:hczz" jdbc_user => zdkz jdbc_password => zdkz statement_filepath => "/usr/local/logstash-6.7.1/data/sql/shxx.sql" use_column_value => true tracking_column_type => "timestamp" tracking_column => "modify_date" record_last_run => true last_run_metadata_path => "/usr/local/logstash-6.7.1/data/metadata/shxx" lowercase_column_names => true clean_run => false schedule => "* * * * *" type => "shxx" } jdbc { jdbc_driver_library => "/home/xis/ojdbc8-12.2.0.1.jar" jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver" jdbc_connection_string => "jdbc:oracle:thin:@192.168.40.104:1521:hczz" jdbc_user => zdkz jdbc_password => zdkz statement_filepath => "/usr/local/logstash-6.7.1/data/sql/zdxx.sql" use_column_value => true tracking_column_type => "timestamp" tracking_column => "modify_date" record_last_run => true last_run_metadata_path => "/usr/local/logstash-6.7.1/data/metadata/zdxx" lowercase_column_names => true clean_run => false schedule => "* * * * *" type => "zdxx" } }
filter { ruby { code => "event.set('timestamp', event.get('@timestamp').time.localtime + 8*60*60)" } ruby { code => "event.set('@timestamp',event.get('timestamp'))" } mutate { remove_field => ["timestamp"] } }
output { if[type] == "shxx"{ elasticsearch { hosts => ["localhost:9200"] index => "tb_yw_shxx" document_type => "doc" document_id => "%{id}" } } if[type] == "zdxx"{ elasticsearch { hosts => ["localhost:9200"] index => "tb_yw_zdxx" document_type => "doc" document_id => "%{id}" } } }
|
启动
1 2 3 4 5
| # 进入logstash安装目录 cd /usr/local/logstash-6.7.1/bin
# 启动 logstash -f ../config/logstash-test.conf
|
后台启动
1
| nohup logstash -f ../config/logstash-test.conf
|
停止
查看进程号 ps -ef|grep logstash
杀掉进程 kill -9 #logstash进程号