https://github.com/jprante/elasticsearch-jdbc/
# elastic_search_learning
how to use elastic search
# 安装elasticserach-jdbc做增量同步
wget http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/<version>/elasticsearch-jdbc-<version>-dist.zip
* version=2.3.4.0
unzip elasticsearch-jdbc-<version>-dist.zip
cd elasticsearch-jdbc-<version>
cd bin
test.sh:
bin=/Users/jesusslim/Downloads/elasticsearch-jdbc-2.3.4.0/bin
lib=/Users/jesusslim/Downloads/elasticsearch-jdbc-2.3.4.0/lib
echo '{
"type" : "jdbc",
"statefile" : "statefile.json",
"jdbc": {
"url" : "jdbc:mysql://ip:port/db_name?user=test&password=password",
"user" : "test",
"password" : "password",
"type" : "allocate_record",
"index": "crm",
"schedule" : "0 * * * * ?",
"metrics" : {
"enabled" : true
},
"sql" : [
{
"statement" : "select id as _id,id,last_remark_time,last_remark from ebk_allocate_record where adv_group = 1 and last_remark_time > UNIX_TIMESTAMP(?)",
"parameter" : [ "$metrics.lastexecutionstart" ]
}
]
}
}' | java \
-cp "${lib}/*" \
-Dlog4j.configurationFile=${bin}/log4j2.xml \
org.xbib.tools.Runner \
org.xbib.tools.JDBCImporter
需要java v1.8
其他配置如外网访问等需配置elasticsearch/config/的yml