本篇为此系列的第一篇,能写多少看状态~~!mysql
很少说,开篇上网址:https://github.com/jprante/elasticsearch-jdbc里面教程讲的比较清楚,可是在同步mysql的时候的过程当中出现了诸多问题(我用的是jdk1.7.0 ES1.5.2),不是ClassNotFound,就是各类Invokexxx之类的错误(修复后,就没图了。。。)折腾了很久,发现是mysql-jdbc的版本问题。git
按教程中给的http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/1.5.2.0/elasticsearch-jdbc-1.5.2.0-dist.zip库始终报错,不知为什么,还请大神指点。github
解决方法以下:下载http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/1.5.0.5/elasticsearch-river-jdbc-1.5.0.5.jar并拷贝到$ES_HOME/lib下便解决了。 sql
而后是建立river,以下mongodb
curl -XPUT 'localhost:9200/_river/[type_name]/_meta' -d '{ "type" : "jdbc", "jdbc" : { "url" : "jdbc:mysql://[IP]:[port]/[database]", "user" : "root", "password" : "123456", "sql" : "select * from [table_name]", "index" : "[index_in_ES]", "type" : "[type_in_ES]" } }'
惯例:https://github.com/richardwilly98/elasticsearch-river-mongodbshell
mongodb要搭成集群模式curl
创建river以下elasticsearch
curl -XPUT "192.68.3.130:9200/_river/river_name/_meta" -d ' { "type": "mongodb", "mongodb": { "servers": [ { "host": "192.168.1.111", "port": 888 }, { "host": "192.168.1.112", "port": 889 } ], "options": { "secondary_read_preference" : true }, "credentials": [ { "db": "admin", "user": [user_name], "password": [password] } ], "db": "test", "collection": "testES" }, "index": { "name": "testes_index", "type": "type_index" } }'
目前ES已经升级到了2.1.0,悲剧的是官方已经发布公告,不支持river迁移数据了!!!url