包含标签的读取首选项的mongoexport

时间:2017-10-01 10:27:20

标签: mongodb replicaset mongoexport

我正在尝试从MongoDB导出一个集合,但我希望导出是使用读取首选项中的标记从特定的辅助服务器。 我的MongoDB包含一个副本集:primary-secondary-secondary。 一个辅助标记为“tgg”:“tgg1”,第二个标记为“tgg”:“tgg2”

此副本集配置为单个分片。 mongos客户端在端口localhost:47010上运行。

我正在使用mongoexport 3.4

我正在运行的mongoexport命令:

mongoexport --port 47010 --db test --collection test_collection --out ~/tmp/mongo/test.json --readPreference '{"mode":"secondary", "tags":[{"tgg":"tgg2"}]}' --verbose

我收到以下错误:

失败:无法在replset1中调用say,没有好的节点

但是,如果我没有指定标签,只是模式是“辅助”,那么一切正常。

我在这里错过了什么吗?

修改

所以我发现了什么问题,我不得不在github上找到他们的源代码,但仍然如此。我必须说错误消息是不够的。 看来我提供了一个标签列表而不仅仅是一个Json对象。 所以以下命令有效:

mongoexport --port 47010 --db test --collection test_collection --out ~/tmp/mongo/test.json --readPreference '{mode:"secondary", tags:{"tgg":"tgg2"}}' --verbose

1 个答案:

答案 0 :(得分:0)

尝试使用import time print ("This is a simple login") while True: enter = raw_input("Enter the password for this computer: ") if enter == "Reagan": time.sleep(1) print ("Your Login is successful") else: print ("Password didn't match! ") 命令本身中的--host参数连接到所需的辅助节点:

mongoexport