elasticsearch-jdbc安装

github地址:https://github.com/jprante/elasticsearch-jdbc

1、下载

$ wget http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/2.3.1.0/elasticsearch-jdbc-2.3.1.0-dist.zip 

2、解压

unzip elasticsearch-jdbc-2.3.1.0-dist.zip

3、将mysql-connector-java-5.1.38.jar导入到lib目录下

4、创建执行脚本

bin=/opt/app/elasticsearch-2.3.3/elasticsearch-jdbc-2.3.3.0/bin
lib=/opt/app/elasticsearch-2.3.3/elasticsearch-jdbc-2.3.3.0/lib
echo '{
    "type" : "jdbc",
    "jdbc" : {
        "url" : "jdbc:mysql://10.255.33.15:3306/hammurabi",
        "user" : "root",
        "password" : "root",
        "sql" : [
            {
                "statement" : "select * from tb_template"
            },
            {
                "statement" : "select * from tb_template_copy"
            }
        ],
    "index" : "hammurabi",
    "type" : "tb_template",
    "elasticsearch.cluster":"es-oasis",
    "elasticsearch.host" : "10.255.33.15"

    }
}' | java \
       -cp "${lib}/*" \
       -Dlog4j.configurationFile=${bin}/log4j2.xml \
       org.xbib.tools.Runner \
       org.xbib.tools.JDBCImporter


5、查看日志

/opt/app/elasticsearch-2.3.3/elasticsearch-jdbc-2.3.3.0/bin/logs

 

posted on 2016-07-15 18:39  hi_rain  阅读(513)  评论(0)    收藏  举报