logstash 主配文件
input {
jdbc {
#連接數據庫的驅動jar包位置
jdbc_driver_library => "./mysql-connector-java-5.1.45.jar"
#連接mysql必須配置
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string =>"*****"
jdbc_user => "name"
jdbc_password => "password"
#分頁配置 默認100000
jdbc_page_size => 100000
jdbc_paging_enabled => true
#連接數據庫的查詢語句
statement => "select * from dx_weak_bind"
#記錄位置
last_run_metadata_path => "./syncpoint_table4.log"
}
}
output {
elasticsearch {
# es 地址
hosts => "es.com:9200"
# 索引名稱
index => "dx_weak_bind"
# document_id 默認自己生成 可也有數據庫賦值
document_id => "%{id}"
manage_template => true
template_overwrite => true
# 模板名稱對應下面的模板文件名稱
template_name => "dx_weak_bind"
# 模板位置
template => "./config/template-mysql4.json"
}
}
{
#模板名稱
"template": "name",
"settings": {
# 設置分片數量
"index.number_of_shards": 3,
"number_of_replicas": 1,
# 設置查入響應時間
"index.refresh_interval": "60s"
},
"mappings": {
"doc": {
"properties": {
"itemid": {
"type": "integer"
},
"activity_itemid": {
"type": "keyword"
}
}
}
}
}