When mongo is built with replica set cluster.
If you log into one of the SECONDARY nodes and execute the command show dbs, you will get an error:
2022-08-16T15:20:00.606+0800 E QUERY [js] uncaught exception: Error: listDatabases failed:{ "operationTime" : Timestamp(1660634399, 2), "ok" : 0, "errmsg" : "not master and slaveOk=false", "code" : 13435, "codeName" : "NotMasterNoSlaveOk", "$clusterTime" : { "clusterTime" : Timestamp(1660634399, 2), "signature" : { "hash" : BinData(0,"NPF356c5NKl0PqHLlmiQ9vey9e4="), "keyId" : NumberLong("7101680539345616897") } } } : _getErrorWithCode@src/mongo/shell/utils.js:25:13 Mongo.prototype.getDBs/<@src/mongo/shell/mongo.js:147:19 Mongo.prototype.getDBs@src/mongo/shell/mongo.js:99:12 shellHelper.show@src/mongo/shell/utils.js:906:13 shellHelper@src/mongo/shell/utils.js:790:15 @(shellhelp2):1:1
This is because the SECONDARY node does not have the permission to execute the show dbs command.
In this case, there are two solutions
1. Login to the PRIMARY node
2. Use the cluster connection method
mongo –host testmongo/ip:port,ip:port,ip:port -uusername -p’passwd’ –authenticationDatabase admin
In this case, there are two solutions
1. Login to the PRIMARY node
2. Use the cluster connection method
mongo –host testmongo/ip:port,ip:port,ip:port -uusername -p’passwd’ –authenticationDatabase admin
Read More:
- CSS text more than 2 lines hidden and show ellipsis
- [Solved] Uncaught DOMException: Failed to execute ‘readAsDataURL‘ on ‘FileReader‘: The object is already busy
- [Solved] Uncaught (in promise) DOMException: Failed to load because no supported source was found.
- [Solved] Echarts Error: Uncaught (in promise) Error: Initialize failed: invalid dom.
- [Solved] echarts Draw Errror: echarts-d9fd185e.js:31447 Uncaught (in promise) Error: Initialize failed: invalid dom.
- [Solved] Uncaught (in promise) Error: Avoided redundant navigation to current location:
- Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to crrent location: “/home“
- [Solved] Uncaught SyntaxError: Unexpected token ‘<‘
- request.js?b775:101 Uncaught (in promise) Error: Failed to convert value of type ‘java.lang.String’ to required type ‘java.lang.Long’;
- [Web Browser] “Uncaught TypeError: object is not a function“
- [Solved] Uni.createintersectionobserver Error: Uncaught TypeError: Cannot read property ‘bottom’ of null
- [Solved] Uncaught SyntaxError: Invalid Unicode escape sequence
- Uncaught URIError: URI malformed [How to Solve]
- [Solved] Uncaught SyntaxError: The requested module does not provide an export named
- JS bug Log Uncaught TypeError: Cannot read property ‘previoustSibling‘ of null
- [Solved] Uncaught SyntaxError: Cannot use import statement outside a module
- [Solved] Uncaught ReferenceError: axios is not defined
- How to Solve Uncaught (in promise) Error (Two Solutions)
- Method to solve uncaught typeerror: cannot set property ‘onclick’ of null error
- [Solved] Uncaught Error: Provide the “history“ option when calling “createRouter()“