mongodb 安装问题

1. mongodb启动时显示 Illegal instruction (core dumped)

mongodb 5.0之后(包括5.0) 开始使用需要使用 AVX 指令集

2.启动时报错 ERROR: child process failed, exited with 1

通过指令 bin/mongod --repair 或 ./bin/mongod -f configs/mongodb.conf --repair 查看报错信息

根据报错信息进行修改

3. 配置服务器添加节点时报错

复制代码
Reconfig attempted to install a config that would change the implicit defaul... Use the setDefaultRWConcern command to set a cluster-wide write concern and try the reconfig again

解决方法,修改默认读写关注配置
官网修改地址

复制代码
db.adminCommand({
  "setDefaultRWConcern" : 1,
  "defaultWriteConcern" : {
    "w" : 2
  }
})

选项信息

"w" : 1 只要主节点写入成功,就直接返回成功的响应,而不管副节点的同步情况

"w" : majority 超过节点半数【(节点数+1)/2】写入成功,才返回成功响应

"w" : 0 不等待任何节点确认写操作,只需写入到内存就返回成功,这是最低级别的写安全级别,这个配置可以提供写入性能,但也有一定的风险

"w" : 等待指定数量的节点确认写成功

其他注意: 配置服务器不能有裁决节点(7.0.8版本测试所得)

路由添加分片集群时报错

复制代码
Cannot add ***/***  as a shard since the implicit default write concern on this shard is set to {w : 1}, because number of arbiters in the shard's configuration caused the number of writable voting members not to be strictly more than the voting majority. Change the shard configuration or set the cluster-wide write concern using the setDefaultRWConcern command and try again.

在 mongos 实例中 我们使用命令 db.adminCommand({ "getDefaultRWConcern": 1 }) 可以查看到当前mongos 默认设置的写入安全机制defaultWriteConcern,默认是 majority (多数确认),这是mongodb5.0后开始的默认设置 ,这意味着当进行写操作时,至少要有超过大多数的数据节点确认写操作成功,才会返回成功的响应,目前我们是3个节点,mongo系统定义的一半节点数是 (3+1)/2=2,需要超过2,也就是至少要有3个节点写入成功才行,但是我们设置了一个 仲裁节点,导致3个shard节点中,只有2个可写数据的节点,怎么也不会写成功了,所以导致失败

解决方法,将写入安全级别调低,在路由上使用以下命令

复制代码
db.adminCommand({  "setDefaultRWConcern" : 1,  "defaultWriteConcern" : {    "w" : 1  }})

4. 节点异常关闭后无法重启

  1. 删除data/db下的mongod.lock文件,再启动

  2. 如果还是启动失败

    An incomplete repair has been detected! This is likely because a repair operation unexpectedly failed before completing. MongoDB will not start up again without --repair.

    //修复数据
    mongod --dbpath db目录 --repair

    尝试删除storage.bson文件

    复制代码
    //删除db目录里面的storage.bson 
    rm -rf db目录/storage.bson
相关推荐
码爸38 分钟前
多源异构数据库实时同步至 Doris
数据库·flink·scala
王大傻092842 分钟前
堆叠注入(Stacked Queries Injection)详解:原理、利用与防御
服务器·网络·数据库·web安全·网络安全
ClouGence1 小时前
数据库迁移工具 CloudCanal v6.5.0.0 发布:新增 TDSQL PostgreSQL 多条链路,支持 MongoDB 双向同步
数据库·mysql·mongodb
AIGS0011 小时前
从814张表到250个本体:本体建模在做什么
数据库·excel·erp·数据中台·智能问数·本体语义·企业大脑
fengkai45452 小时前
十二、Redis -1
运维·数据库·redis
这个DBA有点耶2 小时前
Change Buffer深入:二级索引写入的隐形加速器与它的代价
数据库·mysql·代码规范
for_ever_love__2 小时前
MySQL 事务隔离级别讲透:MVCC、幻读与四个级别怎么选
java·数据库·mysql·事务·mvcc·不可重复读·幻读
Knight_AL3 小时前
PostgreSQL Docker 数据库备份:pg_dump 与 SQL 格式备份的区别
数据库·docker·postgresql
写后端的胖头鱼3 小时前
Redis 的 RDB 和 AOF
java·数据库·redis
杨云龙UP3 小时前
Oracle 19c ADG 实时同步故障排查与修复:Standby Redo Log(SRL)文件缺失导致备库仅在主库归档后同步
数据库·oracle·adg·data guard·srl·ora-00313·ora-27037