我正在尝试在mongodb中创建一个副本。我使用以下命令制作副本。我得到了以下输出。
cfg = { _id : "mySet", members : [ { _id : 0, host : "localhost:27017"
} ] }
rs.initiate(cfg)
输出:
{
"ok" : 0,
"errmsg" : "Attempting to initiate a replica set with name mySet, but command line reports 0; rejecting",
"code" : 93,
"codeName" : "InvalidReplicaSetConfig"
}
我得到以下输出:
017-09-22T14:22:22.093+0530 E QUERY [thread1] ReferenceError: conf is not defined :
@(shell):1:1
当我运行show dbs和rs.config()时,我收到以下错误:
show dbs
2017-09-22T14:23:56.234+0530 E QUERY [thread1] Error: listDatabases
failed:{
"ok" : 0,
"errmsg" : "not master and slaveOk=false",
"code" : 13435,
"codeName" : "NotMasterNoSlaveOk"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13 .
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:62:1
shellHelper.show@src/mongo/shell/utils.js:769:19
shellHelper@src/mongo/shell/utils.js:659:15 .
@(shellhelp2):1:1
> rs.config()
2017-09-22T14:24:23.718+0530 E QUERY [thread1] Error: Could not
retrieve replica set config: {
"info" : "run rs.initiate(...) if not yet done for the set",
"ok" : 0,
"errmsg" : "no replset config has been received",
"code" : 94,
"codeName" : "NotYetInitialized"
} :
rs.conf@src/mongo/shell/utils.js:1276:11
@(shell):1:1
答案 0 :(得分:0)
删除所有复制和oplog。
use local
db.dropDatabase()
重启mongo
config = {_id: "repl1", members:[
{_id: 0, host: 'localhost:15000'},
{_id: 1, host: '192.168.2.100:15000'}]
}
rs.initiate(config);