为MongoDb replicaset创建ElasticSearch河

时间:2013-10-17 02:17:23

标签: mongodb elasticsearch

我有3个节点的ElasticSearch集群和3个节点的MongoDb ReplicaSet。我正试图用这个配置设置河流:

curl -XPUT "elasticsearch1:9200/_river/mongodb/_meta" -d '{
  "type": "mongodb",
 "servers":
    [
      { "host": "mongodb-serv1", "port": 27017 },
      { "host": "mongodb-serv2", "port": 27017 },
      { "host": "mongodb-serv3", "port": 27017 }
    ],
    "mongodb": {
       "db": "db_name", 
       "collection": "collection_name",
       "gridfs": false
    },
    "index": {
      "name": "index_name", 
      "type": "type_name"
    }
}'

此命令运行正常,但ElasticSearch不会尝试从MongoDb获取数据。我更新了记录,但没有帮助。

是否有特殊配置连接到副本集?我在单个ES和单个MongoDb上尝试过这种配置,并且工作正常。

1 个答案:

答案 0 :(得分:1)

刚刚搜索过,发现我的配置错误了。在我问问题之前花了更多时间......

“servers”必须在“mongodb”部分内。

curl -XPUT "elasticsearch1:9200/_river/mongodb/_meta" -d '{
  "type": "mongodb",
    "mongodb": {
         "servers": [
               { "host": "mongodb-serv1", "port": 27017 },
               { "host": "mongodb-serv2", "port": 27017 },
               { "host": "mongodb-serv3", "port": 27017 }
         ],
       "db": "db_name", 
       "collection": "collection_name",
       "gridfs": false
    },
    "index": {
      "name": "index_name", 
      "type": "type_name"
    }
}'