mongoDB的db.shutdownServer()報錯的解決方法
> use admin
switched to db admin
> db.auth('root','root');
1
> show dbs
admin 0.078GB
local 0.06GB
test 0.03GB
>
>
> db.shutdownServer();
assert failed : unexpected error: Error: shutdownServer failed: not authorized on admin to execute command { shutdown: 1.0 }
Error: assert failed : unexpected error: Error: shutdownServer failed: not authorized on admin to execute command { shutdown: 1.0 }
at Error (<anonymous>)
at doassert (src/mongo/shell/assert.js:11:14)
at assert (src/mongo/shell/assert.js:20:5)
at DB.shutdownServer (src/mongo/shell/db.js:212:9)
at (shell):1:4
.......................................
最後檢查發現是缺少hostManger的這個角色,這個角色具有shutdown的許可權。
clusterAdmin 角色:clusterManager, clusterMonitor, hostManager
clusterManager AddShard,ApplicationMessage,CleanupOrphaned,FlushRouterConfig,
ListShards,RemoveShard,ReplSetConfigure,ReplSetGetStatus,
ReplSetStateChange,Resync,
Cluster Administration Roles clusterMonitor connPoolStats,cursorInfo,getCmdLineOpts,getLog,getParameter,
getShardMap,hostInfo,inprog,listDatabases,listShards,netstat,
replSetGetStatus,serverStatus,shardingState,top
collStats,dbStats,getShardVersion
hostManager applicationMessage,closeAllDatabases,connPoolSync,cpuProfiler,
diagLogging,flushRouterConfig,fsync,invalidateUserCache,killop,
logRotate,resync,setParameter,shutdown,touch,unlock
賦予hostManager許可權:
> db.grantRolesToUser( "admin" , [ { role: "hostManager", db: "admin" } ])
> db.getName()
admin
> show tables;
system.indexes
system.users
system.version
> db.system.users.find()
{ "_id" : "admin.admin", "user" : "admin", "db" : "admin", "credentials" : { "MONGODB-CR" : "9f3121efccbe3fef09a799d5e63077c2" }, "roles" : [ { "role" : "readWriteAnyDatabase", "db" : "admin" }, { "role" : "readAnyDatabase", "db" : "admin" }, { "role" : "hostManager", "db" : "admin" }, { "role" : "userAdminAnyDatabase", "db" : "admin" } ] }
{ "_id" : "test.test", "user" : "test", "db" : "test", "credentials" : { "MONGODB-CR" : "e78333b96cbdc20a67432095f4741222" }, "roles" : [ { "role" : "dbOwner", "db" : "test" } ] }
> db.shutdownServer()
2016-01-26T10:18:30.064+0800 DBClientCursor::init call() failed
server should be down...
2016-01-26T10:18:30.066+0800 trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2016-01-26T10:18:30.067+0800 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-01-26T10:18:30.067+0800 reconnect 127.0.0.1:27017 (127.0.0.1) failed failed couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
switched to db admin
> db.auth('root','root');
1
> show dbs
admin 0.078GB
local 0.06GB
test 0.03GB
>
>
> db.shutdownServer();
assert failed : unexpected error: Error: shutdownServer failed: not authorized on admin to execute command { shutdown: 1.0 }
Error: assert failed : unexpected error: Error: shutdownServer failed: not authorized on admin to execute command { shutdown: 1.0 }
at Error (<anonymous>)
at doassert (src/mongo/shell/assert.js:11:14)
at assert (src/mongo/shell/assert.js:20:5)
at DB.shutdownServer (src/mongo/shell/db.js:212:9)
at (shell):1:4
.......................................
最後檢查發現是缺少hostManger的這個角色,這個角色具有shutdown的許可權。
clusterAdmin 角色:clusterManager, clusterMonitor, hostManager
clusterManager AddShard,ApplicationMessage,CleanupOrphaned,FlushRouterConfig,
ListShards,RemoveShard,ReplSetConfigure,ReplSetGetStatus,
ReplSetStateChange,Resync,
Cluster Administration Roles clusterMonitor connPoolStats,cursorInfo,getCmdLineOpts,getLog,getParameter,
getShardMap,hostInfo,inprog,listDatabases,listShards,netstat,
replSetGetStatus,serverStatus,shardingState,top
collStats,dbStats,getShardVersion
hostManager applicationMessage,closeAllDatabases,connPoolSync,cpuProfiler,
diagLogging,flushRouterConfig,fsync,invalidateUserCache,killop,
logRotate,resync,setParameter,shutdown,touch,unlock
賦予hostManager許可權:
> db.grantRolesToUser( "admin" , [ { role: "hostManager", db: "admin" } ])
> db.getName()
admin
> show tables;
system.indexes
system.users
system.version
> db.system.users.find()
{ "_id" : "admin.admin", "user" : "admin", "db" : "admin", "credentials" : { "MONGODB-CR" : "9f3121efccbe3fef09a799d5e63077c2" }, "roles" : [ { "role" : "readWriteAnyDatabase", "db" : "admin" }, { "role" : "readAnyDatabase", "db" : "admin" }, { "role" : "hostManager", "db" : "admin" }, { "role" : "userAdminAnyDatabase", "db" : "admin" } ] }
{ "_id" : "test.test", "user" : "test", "db" : "test", "credentials" : { "MONGODB-CR" : "e78333b96cbdc20a67432095f4741222" }, "roles" : [ { "role" : "dbOwner", "db" : "test" } ] }
> db.shutdownServer()
2016-01-26T10:18:30.064+0800 DBClientCursor::init call() failed
server should be down...
2016-01-26T10:18:30.066+0800 trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2016-01-26T10:18:30.067+0800 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-01-26T10:18:30.067+0800 reconnect 127.0.0.1:27017 (127.0.0.1) failed failed couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2062668/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MongoDB報錯Insufficient free space for journal files的解決方法MongoDB
- mongodb find報錯怎麼解決MongoDB
- 幾個報錯的解決方法
- ***XAMPP:報錯Unabletoloaddynamiclibrary的解決方法
- hive使用報錯解決方法Hive
- 安裝psutil模組報錯的解決方法
- HBase刪除列族報錯的解決方法
- SS報錯的解決
- dbfread報錯ValueError錯誤解決方法Error
- mongodb密碼特殊字元的解決方法MongoDB密碼字元
- kaldi的編譯安裝與報錯解決方法編譯
- Nginx報504 gateway timeout錯誤的解決方法NginxGateway
- R語言的各種報錯及其解決方法R語言
- Nginx 報錯 504 Gateway Time-out 的解決方法NginxGateway
- ceph叢集安裝報錯解決方法
- RAC: SRVCTL and VIPCA 命令報錯解決方法PCA
- MRTG生成首頁報錯解決方法
- DBMS_METADATA報錯解決方法
- docker pull下載映象時的報錯及其解決方法Docker
- 下載HuggingFace模型的方法以及報錯解決模型
- windows update更新失敗報錯解決方法Windows
- JDeveloper啟動時老是報錯-解決方法Developer
- undefined reference to錯誤的解決方法Undefined
- PHP錯誤“Thisfilehasexpired”的解決方法PHP
- imagick使用readImage報錯 Failed to read the file 或者沒有報錯內容的解決方法AI
- Qt報Multiple definition錯誤的解決QT
- ora-27140報錯的解決
- git報錯400的解決辦法Git
- MongoDB報錯"not authorized on root to execute command"問題解決一例MongoDBZed
- sudo rosdep init 和 rosdep update 報錯的解決方法(簡單有效!)ROS
- mysql登入報錯提示:ERROR 1045 (28000)的解決方法MySqlError
- svn“Previous operation has not finished; run ‘cleanup‘ if it was interrupted“報錯的解決方法
- sun.misc.BASE64Encoder 報錯!找不到解決的方法
- MySQL 5.7 Invalid default value for 'CREATE_TIME'報錯的解決方法MySql
- Oracle10g 報錯'java.lang.Exception: No such metric'的解決方法OracleJavaException
- mybatis報錯解決MyBatis
- 國內electron-vue build報錯解決方法VueUI
- Django2.2 報錯:UnicodeDecodeError 解決方法DjangoUnicodeError