使用 shuf 来打乱一个文件中的行或是选择文件中一个随机的行。

JDBC importer for Elasticsearch导入没有任何反应

Elasticsearch | 作者 rubynew | 发布于2016年03月12日 | 阅读数:5773

JDBC importer for Elasticsearch导入没有任何反应

测试环境 windows 8
elasticsearch-2.2.0
[url=http://localhost:9200/_plugin/head/]http://localhost:9200/_plugin/head/​[/url]  人工添加和查询 index products等数据都正常
 
https://github.com/jprante/elasticsearch-jdbc  下载JDBC importer for Elasticsearch
elasticsearch-jdbc-2.2.0.0\bin\mysql-simple-example.bat
修改如下 (密码和隐私数据已替换)
@echo off

set DIR=%~dp0
set LIB="%DIR%\..\lib\*"
set BIN="%DIR%\..\bin\*"

REM ???
echo {^
"type" : "jdbc",^
"jdbc" : {^
"url" : "jdbc:mysql://****.mysql.rds.aliyuncs.com:3306/products",^
"user" : "root",^
"password" : "password",^
"sql" : "select product_id as _id,title FROM products ORDER BY product_id DESC LIMIT 0,50",^
"treat_binary_as_string" : true,^
"elasticsearch" : {^
"cluster" : "elasticsearch",^
"host" : "localhost",^
"port" : 9300^
},^
"index" : "products"^
}^
}

"%JAVA_HOME%\bin\java" -cp "%LIB%" -Dlog4j.configurationFile="log4j2.xml" "org.xbib.tools.Runner" "org.xbib.tools.JDBCImporter"




在cmd下运行
出现
c:\elasticsearch-2.2.0\elasticsearch-jdbc-2.2.0.0\bin
λ caiji-mysql2.bat
{    "type" : "jdbc",    "jdbc" : {        "url" : "jdbc:****.mysql.rds.aliyuncs.com:3306/products",        "user" : "root",        "password" : "password",        "sql" :  "select product_id as _id,title FROM products ORDER BY product_id DESC  LIMIT 0,50",        "treat_binary_as_string" : true,
"elasticsearch" : {             "cluster" : "elasticsearch",             "host" : "localhost",             "port" : 9300        },        "index" : "products"        "type" : "product"      }}
 
 然后没有任何其他任何反应,就光标一闪一闪,到http://localhost:9200/_plugin/head/​  查询没有添加任何新数据
C:\elasticsearch-2.2.0\elasticsearch-jdbc-2.2.0.0\bin\logs\jdbc.txt 文件0kb,是空的
没有出错提示
已邀请:

Xargin

赞同来自:

没有导入成功的话一般是会有错误提示的
 
我在mac上试了一下,2.2可能你需要先手动建好索引,再试试
 
我一开始没手工建索引,报了下面这样的错误:
org.elasticsearch.index.IndexNotFoundException: no such index
 
顺便提醒LZ一句,这个es-jdbc的工具存在很多缺陷,而且不是很可靠,如果是比较大的公司的生产环境的话,最好考虑binlog-> kafka -> es的同步方式。
 
我之前被它坑惨了。

要回复问题请先登录注册