我有一个由3台服务器组成的MongoDB副本集(1台主服务器、1台辅助服务器、1台仲裁器;这是Google Cloud 1-click install创建的默认副本集).主服务器和辅助服务器的2个配置文件(mongod.conf)已更改,添加了security.authorization: enabled
个.
使用以下MongoDB shell命令添加Root用户:
use admin
db.createUser({user:"root",pwd:"root",roles:["root"]})
在使用"sudo service mongod restart"在主服务器和辅助服务器上重新启动MongoDB服务后,与副本集的连接变得不稳定.
r.status()有时会给出如下结果:
- 1个主要的,1个无法到达的,1个仲裁人
- 1个二级、1个二级、1个仲裁员
- 1个二级,1个无法访问,1个仲裁人
How to setup basic password authentication (not using keyfile) for MongoDB replica set the correct way?