开启认证功能之后,出现了不能关闭数据库的现象,报错如下:
-
Error: assert failed : unexpected error: Error: shutdownServer failed: not authorized on admin to execute command { shutdown: 1.0 }
开启的操作是在/etc/mongo.conf,添加如下设置:
-
security:
-
authorization: enabled
从报错内容上看是权限不够,但不明了为什么,因为已经使用的超级用户权限:
-
{
-
"_id" : "admin.myUserAdmin",
-
"user" : "myUserAdmin",
-
"db" : "admin",
-
"roles" : [
-
{
-
"role" : "userAdminAnyDatabase",
-
"db" : "admin"
-
},
-
{
-
"role" : "dbOwner",
-
"db" : "admin"
-
}
-
]
-
}
经过查询错误解决办法,了解到是集群管理权限不够,添加相应权限之后就可以解决问题,变更用户权限如下:
-
> db.updateUser(
-
... "myUserAdmin",
-
... {
-
... roles : [
-
... {"role" : "userAdminAnyDatabase","db" : "admin"},
-
... {"role" : "dbOwner","db" : "admin"},
-
... {"role" : "clusterAdmin", "db": "admin"}
-
... ]
-
... }
-
... )
成功关闭数据库系统:
-
> db.shutdownServer({shutdown: 1, force: true})
-
2015-12-31T11:19:35.461+0800 I NETWORK DBClientCursor::init call() failed
-
server should be down...
-
2015-12-31T11:19:35.463+0800 I NETWORK trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
-
2015-12-31T11:19:35.464+0800 I NETWORK reconnect 127.0.0.1:27017 (127.0.0.1) ok
-
2015-12-31T11:19:35.467+0800 I NETWORK Socket recv() errno:104 Connection reset by peer 127.0.0.1:27017
-
2015-12-31T11:19:35.467+0800 I NETWORK SocketException: remote: 127.0.0.1:27017 error: 9001 socket exception [RECV_ERROR] server [127.0.0.1:27017]
-
2015-12-31T11:19:35.467+0800 I NETWORK DBClientCursor::init call() failed
-
> exit
-
bye
参考链接:
用户权限更新:
mongodb副本配置:
mongodb user roles:
报错解决办法:
阅读(3438) | 评论(0) | 转发(0) |