使用mongo-connector连接mongodb和elasticsearch

时间:2016-11-21 08:43:57

标签: mongodb elasticsearch elasticsearch-plugin elasticsearch-river database

我是弹性搜索的新手,我试图将它与mongodb连接起来。 我试着用mongo-connector做到这一点。 所以我正在运行mongod,这是我得到的输出:

  

2016-11-21T10:03:24.213+0200 I CONTROL  [initandlisten] MongoDB starting : pid=7244 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-7QLMJRC
2016-11-21T10:03:24.215+0200 I CONTROL  [initandlisten] targetMinOS: Windows Vista/Windows Server 2008
2016-11-21T10:03:24.216+0200 I CONTROL  [initandlisten] db version v3.2.4
2016-11-21T10:03:24.216+0200 I CONTROL  [initandlisten] git version: e2ee9ffcf9f5a94fad76802e28cc978718bb7a30
2016-11-21T10:03:24.217+0200 I CONTROL  [initandlisten] allocator: tcmalloc
2016-11-21T10:03:24.217+0200 I CONTROL  [initandlisten] modules: none
2016-11-21T10:03:24.217+0200 I CONTROL  [initandlisten] build environment:
2016-11-21T10:03:24.217+0200 I CONTROL  [initandlisten]     distarch: x86_64
2016-11-21T10:03:24.217+0200 I CONTROL  [initandlisten]     target_arch: x86_64
2016-11-21T10:03:24.218+0200 I CONTROL  [initandlisten] options: {}
2016-11-21T10:03:24.220+0200 I -        [initandlisten] Detected data files in C:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-11-21T10:03:24.223+0200 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=8G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-11-21T10:03:24.886+0200 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-11-21T10:03:24.886+0200 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2016-11-21T10:03:24.891+0200 I NETWORK  [initandlisten] waiting for connections on port 27017

然后我运行elasticsearch,这是我得到的输出:

>

[2016-11-21T10:07:33,859][INFO ][o.e.n.Node               ] [] initializing ...
[2016-11-21T10:07:33,945][INFO ][o.e.e.NodeEnvironment    ] [YzvQTk1] using [1] data paths, mounts [[(C:)]], net usable_space [66.7gb], net total_space [223.1gb], spins? [unknown], types [NTFS]
[2016-11-21T10:07:33,946][INFO ][o.e.e.NodeEnvironment    ] [YzvQTk1] heap size [1.9gb], compressed ordinary object pointers [true]
[2016-11-21T10:07:33,947][INFO ][o.e.n.Node               ] [YzvQTk1] node name [YzvQTk1] derived from node ID; set [node.name] to override
[2016-11-21T10:07:33,954][INFO ][o.e.n.Node               ] [YzvQTk1] version[5.0.1], pid[6968], build[080bb47/2016-11-11T22:08:49.812Z], OS[Windows 10/10.0/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_111/25.111-b14]
[2016-11-21T10:07:35,406][INFO ][o.e.p.PluginsService     ] [YzvQTk1] loaded module [aggs-matrix-stats]
[2016-11-21T10:07:35,407][INFO ][o.e.p.PluginsService     ] [YzvQTk1] loaded module [ingest-common]
[2016-11-21T10:07:35,407][INFO ][o.e.p.PluginsService     ] [YzvQTk1] loaded module [lang-expression]
[2016-11-21T10:07:35,407][INFO ][o.e.p.PluginsService     ] [YzvQTk1] loaded module [lang-groovy]
[2016-11-21T10:07:35,407][INFO ][o.e.p.PluginsService     ] [YzvQTk1] loaded module [lang-mustache]
[2016-11-21T10:07:35,407][INFO ][o.e.p.PluginsService     ] [YzvQTk1] loaded module [lang-painless]
[2016-11-21T10:07:35,407][INFO ][o.e.p.PluginsService     ] [YzvQTk1] loaded module [percolator]
[2016-11-21T10:07:35,407][INFO ][o.e.p.PluginsService     ] [YzvQTk1] loaded module [reindex]
[2016-11-21T10:07:35,407][INFO ][o.e.p.PluginsService     ] [YzvQTk1] loaded module [transport-netty3]
[2016-11-21T10:07:35,408][INFO ][o.e.p.PluginsService     ] [YzvQTk1] loaded module [transport-netty4]
[2016-11-21T10:07:35,408][INFO ][o.e.p.PluginsService     ] [YzvQTk1] no plugins loaded
[2016-11-21T10:07:39,324][INFO ][o.e.n.Node               ] [YzvQTk1] initialized
[2016-11-21T10:07:39,325][INFO ][o.e.n.Node               ] [YzvQTk1] starting ...
[2016-11-21T10:07:39,924][INFO ][o.e.t.TransportService   ] [YzvQTk1] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300}
[2016-11-21T10:07:44,059][INFO ][o.e.c.s.ClusterService   ] [YzvQTk1] new_master {YzvQTk1}{YzvQTk1WT_asjjzSFEeaOw}{DhwO889xQDGHqsQuKBkq4Q}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2016-11-21T10:07:44,145][INFO ][o.e.g.GatewayService     ] [YzvQTk1] recovered [0] indices into cluster_state
[2016-11-21T10:07:44,577][INFO ][o.e.h.HttpServer         ] [YzvQTk1] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200}
[2016-11-21T10:07:44,577][INFO ][o.e.n.Node               ] [YzvQTk1] started

然后我运行mongo-connector将它们连接到这个命令:  “mongo-connector -m localhost:27017 -t localhost:9200 -d elastic_doc_manager”

输出是:  Logging to mongo-connector.log.

所以似乎每件事情都有效,但当我转到这个链接时http://localhost:9200/foo/_search?pretty=true&q={'matchAll':{''}}

我得到的输出是:

"error" : {
"root_cause" : [
  {
    "type" : "index_not_found_exception",
    "reason" : "no such index",
    "resource.type" : "index_or_alias",
    "resource.id" : "foo",
    "index_uuid" : "_na_",
    "index" : "foo"
  }
],
"type" : "index_not_found_exception",
"reason" : "no such index",
"resource.type" : "index_or_alias",
"resource.id" : "foo",
"index_uuid" : "_na_",
"index" : "foo"

},   “身份”:404 }

所以连接失败了,但我不知道为什么。

我的弹性搜索中没有插件,我读了一些关于副本集的内容,但我不确定我知道它是什么,也许这就是problam。 我的mongo数据库位于我的内部存储中。

请帮帮我!我做错了什么,或者我应该怎么做才能在mongo和elasticsearch之间同步数据。 我已经阅读过关于河流插件的内容,但是我没有安装它,所以如果有答案请告诉我如何在Windows上安装它,我找到的所有教程都在linux上。

我真的需要一些帮助,因为我已经停留太长时间了。

1 个答案:

答案 0 :(得分:0)

提到的查询是尝试访问ElasticSearch中的 foo 索引。错误是由于索引不存在于同一个。

P.S。
查询:http:// localhost:9200 / foo / _search?pretty = true& q = {'matchAll':{''}}