"$err" : "not master and slaveok=false", "code" : 13435

monbodb安装完之后, 启动准备添加用户报错.

> use admin
switched to db admin
> db.addUser("admin","admin",false);
Wed Apr 24 14:17:26 uncaught exception: error { "$err" : "not master and slaveok=false", "code" : 13435 }
>

 

去check下 install 以及start 过程

/usr/local/mongodb/bin/mongod  -f  /etc/mongodb/37017.conf

 

有启动参数在 /etc/mongodb/37017.conf 配置文件里面

[root@mongo ~]# more /etc/mongodb/37017.conf
dbpath = /db/db1
port = 37017
rest = true
fork = true
logpath = /etc/mongodb/mongodb.log
logappend = true
replSet = sso-rest

 

我这台mongodb是单机,所以这个参数估计不合理,也许是这里报错, 注释掉

#replSet = sso-rest

 

重新启动mongodb:

/usr/local/mongodb/bin/mongod  -f  /etc/mongodb/37017.conf

 

再登陆重新执行db.addUser("admin","admin",false);

OK !

你可能感兴趣的:("$err" : "not master and slaveok=false", "code" : 13435)