我已经设置了一个带有 3 个节点(虚拟机运行 CentOS)的 MongoDB 副本集。一个节点成为主节点,其他 2 个节点卡在启动中。当这 2 个节点将其状态从启动更改为辅助时。
aryabhata:PRIMARY> rs.status()
{
"set" : "aryabhata",
"date" : ISODate("2016-04-30T08:10:45.173Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "localhost.localdomain:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 69091,
"optime" : Timestamp(1461935462, 1),
"optimeDate" : ISODate("2016-04-29T13:11:02Z"),
"electionTime" : Timestamp(1461934754, 1),
"electionDate" : ISODate("2016-04-29T12:59:14Z"),
"configVersion" : 459192,
"self" : true
},
{
"_id" : 1,
"name" : "repset1.com:27017",
"health" : 1,
"state" : 0,
"stateStr" : …Run Code Online (Sandbox Code Playgroud) 我在谷歌云计算引擎中使用版本为3.4的mongoDB群集,实际上过去一周我的数据库被黑客攻击了,这就是为什么我考虑使用授权以便我可以避免这些类型的攻击.我们添加授权,我看到这篇文章如何对创建-MongoDB的复制集群,现在我已经加入了keyfile与chmod 0600对我的每一个集群节点的,但现在,当我试图加我的第一次admin user我收到以下错误我
use admin
switched to db admin
rs0:PRIMARY> db.createUser({user: "RootAdmin", pwd: "password123", roles: [ { role: "root", db: "admin" } ]});
2017-01-21T18:19:09.814+0000 E QUERY [main] Error: couldn't add user: not authorized on admin to execute comm
and { createUser: "RootAdmin", pwd: "xxx", roles: [ { role: "root", db: "admin" } ], digestPassword: false, writ
eConcern: { w: "majority", wtimeout: 300000.0 } } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1290:15
@(shell):1:1
Run Code Online (Sandbox Code Playgroud)
我到处搜索但是没有找到任何关于我为什么会收到此错误的信息.
谁能帮助我,我怎么能解决这个错误.
更新 我的配置文件在下面给出了每个实例 …