mongodb.conf

mongodb.conf

当主副本关闭时,我收到以下错误

ConnectionPool::PoolShuttingDownError (ConnectionPool::PoolShuttingDownError):
Moped::Errors::ConnectionFailure (Could not connect to a primary node for replica set #<Moped::Cluster:70117691586500 @seeds=[<Moped::Node resolved_address="0.0.0.0:27017">]>

我有 3 个 mongoDB 副本。

看起来主副本是 172.19.16.109:27017

我不明白为什么我关闭了机器172.19.16.109

剩余 2 个副本无法从其数据库加载数据。

这对副本来说难道没有意义吗?一旦主服务器关闭,其他服务器也将不可用。

我希望即使任何一个副本发生故障,其他副本也能够正常工作。

我的配置如下。

vvtk_dqa:PRIMARY> rs.conf()
{
    "_id" : "vvtk_dqa",
    "version" : 4,
    "members" : [
        {
            "_id" : 1,
            "host" : "172.19.16.109:27017"
        },
        {
            "_id" : 2,
            "host" : "172.19.16.104:27017"
        },
        {
            "_id" : 3,
            "host" : "192.168.14.7:27017"
        }
    ]
}

mongodb.conf

# Where to store the data.
dbpath=/var/lib/mongodb

#where to log
logpath=/var/log/mongodb/mongodb.log

logappend=true

bind_ip = 0.0.0.0
#port = 27017

# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
journal=true

replSet=vvtk_dqa

是大师

vvtk_dqa:PRIMARY> rs.isMaster()
{
    "setName" : "vvtk_dqa",
    "setVersion" : 4,
    "ismaster" : true,
    "secondary" : false,
    "hosts" : [
        "172.19.16.109:27017",
        "192.168.14.7:27017",
        "172.19.16.104:27017"
    ],
    "primary" : "172.19.16.109:27017",
    "me" : "172.19.16.109:27017",
    "maxBsonObjectSize" : 16777216,
    "maxMessageSizeBytes" : 48000000,
    "maxWriteBatchSize" : 1000,
    "localTime" : ISODate("2015-02-11T02:05:12.021Z"),
    "maxWireVersion" : 2,
    "minWireVersion" : 0,
    "ok" : 1
}

答案1

添加

gem 'moped', '2.0.4', github: 'wandenberg/moped', branch: 'operation_timeout'

Gemfile 帮助了我。更多信息:https://github.com/mongoid/moped/issues/348

相关内容