本篇爲此係列的第一篇,能寫多少看狀態~~!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