点击(此处)折叠或打开
- 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
参考链接:
用户权限更新:https://docs.mongodb.org/v3.0/reference/method/db.updateUser/
mongodb副本配置:http://www.linuser.com/thread-507-1-1.html
mongodb user roles:https://docs.mongodb.org/v3.0/reference/built-in-roles/
报错解决办法:http://stackoverflow.com/questions/13303685/stop-unknown-instance-mongodb-ubuntu