gpt4 book ai didi

linux - 不能在 vagrant 上使用 mongoimport

转载 作者:太空宇宙 更新时间:2023-11-04 12:56:22 24 4
gpt4 key购买 nike

以下是我的 mongo.conf:

# mongod.conf

# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true

systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log

net:
port: 27017
# bindIp: 127.0.0.1

replication:
replSetName: rs0
oplogSizeMB: 250

我尝试导入给定的数据 here在 guest linux 上使用

wget https://raw.githubusercontent.com/mongodb/docs-assets/primer-dataset/dataset.json
mongoimport --host=127.0.0.1 --port=27017 --db test --collection dataset --file dataset.json

也在主机(mac)上试过:

mongoimport --host=127.0.0.1 --port=27071 --db test --collection dataset --file dataset.json

在这两种情况下,我都会得到以下输出:

2016-02-25T11:01:56.280-0500    connected to: 127.0.0.1:27071
2016-02-25T11:01:59.278-0500 [........................] test.dataset 0.0 B/11.3 MB (0.0%)
2016-02-25T11:01:59.309-0500 [........................] test.dataset 0.0 B/11.3 MB (0.0%)
2016-02-25T11:01:59.309-0500 Failed: error checking connected node type: no reachable servers
2016-02-25T11:01:59.309-0500 imported 0 documents

我对主机系统上的端口 27071 发出的所有请求都转发到 linux 客户机上的 27017 端口。没有连接问题,因为 curl localhost:27071 给出了 看起来您正在尝试通过 native 驱动程序端口上的 HTTP 访问 MongoDB

更新:

mongo的日志如下:

2016-02-25T18:33:23.938+0000 I CONTROL  ***** SERVER RESTARTED *****
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] MongoDB starting : pid=4810 port=27017 dbpath=/var/lib/mongodb 64-bit host=vagrant-ubuntu-trusty-64
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] db version v3.0.9
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] git version: 20d60d3491908f1ae252fe452300de3978a040c7
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] build info: Linux ip-10-732-9-221 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-02-25T18:33:23.941+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "0.0.0.0", port: 27017 }, replication: { oplogSizeMB: 250, replSetName: "rs0" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-02-25T18:33:23.969+0000 I JOURNAL [initandlisten] journal dir=/var/lib/mongodb/journal
2016-02-25T18:33:23.969+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2016-02-25T18:33:24.006+0000 I JOURNAL [durability] Durability thread started
2016-02-25T18:33:24.006+0000 I JOURNAL [journal writer] Journal writer thread started
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten]
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten]
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-02-25T18:33:24.007+0000 I CONTROL [initandlisten]
2016-02-25T18:33:24.010+0000 I REPL [initandlisten] Did not find local replica set configuration document at startup; NoMatchingDocument Did not find replica set configuration document in local.system.replset
2016-02-25T18:33:24.011+0000 I NETWORK [initandlisten] waiting for connections on port 27017

如果我尝试从主机系统执行 mongoimport --host=0.0.0.0 --port=27071 --db test --collection dataset --file dataset.json,添加以下内容到日志:

2016-02-25T18:36:03.443+0000 I NETWORK  [initandlisten] connection accepted from 10.0.2.2:51277 #1 (1 connection now open)
2016-02-25T18:36:06.479+0000 I NETWORK [conn1] end connection 10.0.2.2:51277 (0 connections now open)

当我从 guest linux 尝试同样的命令时,我得到:

2016-02-25T18:38:29.982+0000 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:59910 #2 (1 connection now open)
2016-02-25T18:38:32.994+0000 I NETWORK [conn2] end connection 127.0.0.1:59910 (0 connections now open)

最佳答案

尝试将您的 bindIp 参数设置为 0.0.0.0,然后重新启动服务。

关于linux - 不能在 vagrant 上使用 mongoimport,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35632446/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com