標籤:elasticsearch river-mongodb
安裝Elasticsearch
1. 下載elasticsearch安裝包。 https://www.elastic.co/downloads/elasticsearch
2. 解壓elasticsearch包到安裝目錄。如D:\Elasticsearch,並將D:\Elasticsearch\bin添加到系統path
安裝JDK
1. 下載JDK,最低版本jdk update u55。 http://www.oracle.com/technetwork/java/javase/overview/index.html
2. 配置JAVA_HOME環境變數。指向JDK的安裝目錄,如D:\Java\jdk\
安裝maven
1. 下載maven安裝包。 http://maven.apache.org/download.cgi
2. 解壓maven包到安裝目錄。如D:\Maven,並將D:\Maven\bin添加到系統path
3. 配置maven本地倉儲位置。開啟D:\Maven\Config\setting.xml,添加<localRepository>D:\Maven\m2\repository</localRepository>
註:(1) 步驟3可以跳過;(2) 如果不想從源碼安裝river-mongodb外掛程式,可以不用安裝maven
安裝river-mongodb外掛程式
1. 下載elasticsearch-river-mongodb外掛程式最新源碼包。 https://github.com/richardwilly98/elasticsearch-river-mongodb
2. 解壓源碼包,並編譯。命令列進入elasticsearch-river-mongodb-master目錄,並執行命令mvn package -Dmaven.test.skip=true
3. 編譯過程比較慢,需要耐心等待。編譯產生的外掛程式在elasticsearch-river-mongodb-master\target\releases目錄下,檔案名稱形如elasticsearch-river-mongodb-2.0.6-SNAPSHOT.zip
4. 安裝編譯產生的外掛程式。直接解壓到elasticsearch安裝目錄下的plugins\river-mongodb目錄,或者命令列運行命令plugin -i river-mongodb -u file:/E:\Documents\編程\Elasticsearch\install\elasticsearch-river-mongodb-master\target\releases\elasticsearch-river-mongodb-2.0.6-SNAPSHOT.zip
註:如果不想從源碼安裝river-mongodb外掛程式,可以直接在命令列運行plugin -i com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/2.0.6(這裡2.0.6為版本號碼)
安裝curl工具
1. 下載curl工具。 http://curl.haxx.se/dlwiz/?type=bin
2. 傻瓜式安裝即可
配置mongodb river
1. 下載curl工具。 http://curl.haxx.se/dlwiz/?type=bin1. 運行elasticsearch。運行elasticsearch安裝目錄下bin\elasticsearch.bat即可
2. 命令列運行curl -XPUT "http://127.0.0.1:9200/_river/icssa/_meta?pretty" -d "{\"type\": \"mongodb\", \"mongodb\": {\"host\":\"127.0.0.1\", \"port\": \"27017\", \"credentials\": [{\"db\": \"admin\", \"user\": \"admin\", \"password\": \"12345\"}], \"db\": \"icssa\", \"collection\": \"equipment\"}, \"index\": {\"name\": \"icssa\", \"type\": \"equipment\"}}"
註:(1) mongodb必須配置為複製叢集;(2) 我的mongodb的路由進程的連接埠改為了27017
查看同步結果
1. 瀏覽器開啟http://localhost:9200/_plugin/head/,前提是你已經為elasticsearch安裝了head外掛程式
2. 同步結果形如:
注意
elasticsearch、river-mongodb外掛程式、mongodb三者的版本必須要匹配
在windows上配置elasticsearch和river-mongodb外掛程式