这篇文章主要介绍了mongodbroot用户创建数据库提示notmaster的解决方案,具有很好的参考价值,希望对大家有所帮助。
mongodb root用户创建数据库提示not master
问题如题
问题也比较简单, 就是master挂了
mongodb的集群似乎和mysql,redis的不太一样,这个我也不太清楚
总之单机不会出现这种情况,集群会出现
解决方法
就是将master重启就可以了
mongodb "errmsg" : "not master and slaveOk=false"的解决
是正常的,因为SECONDARY是不允许读写的,如果非要解决执行 rs.slaveOk() 这句命令就可以了
[yukw@mongodb4 data]$ ./mongo -port 20000
MongoDB shell version v3.4.4
connecting to: mongodb://127.0.0.1:20000/
MongoDB server version: 3.4.4
Server has startup warnings:
2019-07-31T17:06:43.397+0800 I CONTROL [initandlisten]
2019-07-31T17:06:43.397+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-07-31T17:06:43.398+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-07-31T17:06:43.398+0800 I CONTROL [initandlisten]
2019-07-31T17:06:43.398+0800 I CONTROL [initandlisten]
2019-07-31T17:06:43.398+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-07-31T17:06:43.398+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2019-07-31T17:06:43.398+0800 I CONTROL [initandlisten]
2019-07-31T17:06:43.398+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-07-31T17:06:43.398+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2019-07-31T17:06:43.398+0800 I CONTROL [initandlisten]> show users
2019-07-31T17:07:33.469+0800 E QUERY [thread1] Error: not master and slaveOk=false :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.getUsers@src/mongo/shell/db.js:1537:1
shellHelper.show@src/mongo/shell/utils.js:752:9
shellHelper@src/mongo/shell/utils.js:659:15
@(shellhelp2):1:1
> show dbs
2019-07-31T17:07:39.126+0800 E QUERY [thread1] Error: listDatabases failed:{
"ok" : 0,
"errmsg" : "not master and slaveOk=false", ##报错提示
"code" : 13435,
"codeName" : "NotMasterNoSlaveOk"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
Mongo.prototype.getDBs@src/mongo/shell/mongo.js:62:1
shellHelper.show@src/mongo/shell/utils.js:769:19
shellHelper@src/mongo/shell/utils.js:659:15
@(shellhelp2):1:1
> rs.slaveOk(); ##执行命令
> show dbs
local 0.000GB
> show users
>
好了,这就是解决not master and slaveOk=false的方法了
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程学习网。
本文标题为:mongodb root用户创建数据库提示not master的解决
- Numpy中如何创建矩阵并等间隔抽取数据 2023-07-28
- redis清除数据 2023-09-13
- SQLSERVER调用C#的代码实现 2023-07-29
- 基于Python制作一个简单的文章搜索工具 2023-07-28
- SQL Server 2022 AlwaysOn新特性之包含可用性组详解 2023-07-29
- 在阿里云CentOS 6.8上安装Redis 2023-09-12
- 搭建单机Redis缓存服务的实现 2023-07-13
- Oracle 删除大量表记录操作分析总结 2023-07-23
- MySQL8.0.28安装教程详细图解(windows 64位) 2023-07-26
- Mongodb启动报错完美解决方案:about to fork child process,waiting until server is ready for connections. 2023-07-16