出现以下错误:13279:配置副本集时无法在replset配置中找到self

时间:2013-10-14 20:37:43

标签: linux mongodb

我正在linux上配置3节点mongodb副本集。我使用以下配置

fork = true
bind_ip = 127.0.0.1
port = 27017
verbose = true
dbpath =  /opt/mongoDB/data/db
logpath = /opt/mongoDB/log/mongod.log
logappend = true
journal = true
replSet = rs1
keyFile = /opt/mongoDB/mongodb/bin/conf/keyfile

启动服务器。我启动了服务器,当我使用mongo命令行工具连接到服务器时。

当我rs.initiate()时,我得到了

{
    "info2" : "no configuration explicitly specified -- making one",
    "me" : "host-ip:27017",
    "ok" : 0,
    "errmsg" : "couldn't initiate : can't find self in the replset config"
}

我尝试将cfg提供给initiate(),但仍然会收到相同的错误。

这是日志文件中显示的内容。

Mon Oct 14 13:27:33.218 [rsStart] replSet info no seed hosts were specified on the --replSet command line
Mon Oct 14 13:27:34.118 [conn1] run command admin.$cmd { replSetInitiate: { _id: "rs1", members: [ { _id: 0.0, host: "host-ip:27017" } ] } }
Mon Oct 14 13:27:34.118 [conn1] replSet replSetInitiate admin command received from client
Mon Oct 14 13:27:34.118 [conn1] replSet replSetInitiate config object parses ok, 1 members specified
Mon Oct 14 13:27:34.118 [conn1] getallIPs("host-ip"): [ip address]
Mon Oct 14 13:27:34.118 BackgroundJob starting: ConnectBG
Mon Oct 14 13:27:34.118 [conn1] User Assertion: 13279:can't find self in the replset config
Mon Oct 14 13:27:34.119 [conn1] replSet replSetInitiate exception: can't find self in the replset config
Mon Oct 14 13:27:34.119 [conn1] command admin.$cmd command: { replSetInitiate: { _id: "rs1", members: [ { _id: 0.0, host: "host-ip:27017" } ] } } ntoreturn:1 keyUpdates:0 locks(micros) W:230 reslen:107 1ms

我应该何时解决此错误?

2 个答案:

答案 0 :(得分:21)

我无法在CentOS计算机上启动MongoDB的副本集。

http://docs.mongodb.org/manual/tutorial/deploy-replica-set

mongodb replset

rs.initiate()


{
    "errmsg":"couldn't initiate : can't find self in the replset config on port 27011"
}

然后我只使用JSON对象参数rs.initiate(rsconfig)

var rsconfig = {"_id":"rs1","members":[{"_id":1,"host":"127.0.0.1:27011"}]}

然后是rs.add(..)或者只是一次性

var rsconfig = {"_id":"rs1","members":[{"_id":1,"host":"127.0.0.1:27011"},{"_id":2,"host":"127.0.0.1:27012"},{"_id":3,"host":"127.0.0.1:27013"}]}

检查print(JSON.stringify(rsconfig))然后

rs.initiate(rsconfig)

几秒后检查

rs.status()

enter image description here

答案 1 :(得分:11)

请勿将127.0.0.1设置为bind_ip,将bind_ip更改为计算机的名称或IP地址(例如192.168.0.1)。