【问题标题】:Redirecting all queries to secondary in sharded cluster in mongodb将所有查询重定向到 mongodb 分片集群中的辅助节点
【发布时间】:2016-03-17 17:29:58
【问题描述】:

如何将所有查询重定向到分片集群中的辅助节点,而不是在连接到 mongo 路由器时设置 readpreference 变量。简而言之,mongo 路由器将所有读取查询重定向到默认情况下为主的辅助。

【问题讨论】:

标签: mongodb


【解决方案1】:

您可以使用 readPreference 连接字符串选项或查询选项(如果您的驱动程序支持)来执行此操作。 A connection to the mongos router with a readPreference set gets honoured, when selecting which member of each shard's replicaset gets queried, just like if there was no mongos router in the way.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-09
    • 2016-03-05
    • 1970-01-01
    • 2017-03-31
    • 2014-02-28
    相关资源
    最近更新 更多