# MongoDB Validation Support Tools
* [Pre-requisites](#pre-requisites)
* [Remediation Steps](#remediation-steps)
* [Checking for Local Inconsistencies](#checking-for-local-inconsistencies)
* [Checking for Replica Set Inconsistencies](#checking-for-replica-set-inconsistencies)
## Warning
The scripts provided here are best run by those experienced with MongoDB, ideally with guidance from MongoDB Technical Support. They are provided without warranty or guarantee of any kind (see disclaimer below). If you do not have access to MongoDB Technical Support, consider reaching out to our community at [community.mongodb.com](community.mongodb.com) to ask questions.
Some adaptation of these scripts may be required for your use-case.
If you are using these scripts on your own, we strongly recommend:
* reading all instructions before attempting any action, and ensuring you are prepared for all steps.
* taking regular backups of the [dbpaths](https://docs.mongodb.com/manual/core/backups/#back-up-by-copying-underlying-data-files) of each node, and working off of backups as much as possible.
* reviewing the scripts themselves to understand their behavior.
* testing this process and all scripts on a copy of the environment it is to be run.
* for sharded clusters, disabling the balancer.
# Summary
This process provides for identifying and resolving data inconsistencies between MongoDB replica set members, above and beyond what is currently supported by existing and documented `validate` and `dbHash` commands.
The primary use-cases for this process are when:
* a MongoDB replica set running on system architectures with weak memory ordering (ARM64 and POWER) is affected by [WT-10461](https://jira.mongodb.org/browse/WT-10461) which can cause affected nodes to store documents or index entries out of order, leading to inconsistencies and improperly sorted or incomplete query results on versions 4.2.0-4.2.23, 4.4.0-4.4.18, 5.0.0-5.0.14, 6.0.0-6.0.4 or rapid release versions 6.1.0-6.2.0.
* a MongoDB replica set has undergone an unsafe upgrade path identified by [WT-8395](https://jira.mongodb.org/browse/WT-8395), a defect which can introduce data inconsistencies when upgrading from versions 4.4.3-4.4.4 directly to 4.4.8-4.4.10 or 5.0.2-5.0.5.
* all nodes of a MongoDB replica set have been separately impacted by [WT-7995](https://jira.mongodb.org/browse/WT-7995), [WT-7984](https://jira.mongodb.org/browse/WT-7984) on versions 4.4.2-4.4.8 and 5.0.0-5.0.2, and validate() output alone is not sufficient to rule out document-level inconsistencies between nodes.
**Warning**: Use this process with care and perform backups before proceeding. Be certain about what bug you are responding to, and be familiar with the details of that bug. This process involves scripts which cause load on and perform writes to your cluster. In particular, `repair_checked_documents.py` issues delete operations against user collections, depending on options provided when it is run.
## Remediation components
The overall remediation process relies on a combination of `mongod` database commands and scripts in this directory.
* The [validate database command](https://docs.mongodb.com/manual/reference/method/db.collection.validate/), optionally scripted for all databases/collections in `validate.js`.
* The [dbCheck database command](https://github.com/mongodb/mongo/blob/master/src/mongo/db/repl/dbcheck.idl), optionally scripted for all databases/collections in `dbcheck.js`:
* a new server command, run per collection.
* on each replica set node, generates hashes at points in time for ranges of documents.
* outputs results to a non-replicated collection on each node (in each node's `local` database).
* secondaries report inconsistencies with the primary.
* The `scan_checked_replset.js` javascript script for the legacy mongo shell ("mongo"):
* consumes dbCheck output on each node.
* uses specific ranges of inconsistencies reported by dbCheck on secondaries to identify specific differing documents.
* writes results to new databases/collections in the cluster.
* each collection on each node includes that node's version of the differing document (or no document, if that node is missing a document).
* The `repair_checked_documents.py` python3 script:
* consumes scan_checked_replset.js script output.
* resolves inconsistencies by overwriting documents according to a consensus between replica set nodes, depending on the strategy specified.
* **Importantly**: `repair_checked_documents.py` restores the state of inconsistent documents as of the time they were backed up by `scan_checked_replset.js`. If the system is receiving writes, between the start of `scan_checked_replset.js` and `repair_checked_documents.py` those writes could be undone when `repair_checked_documents.py` remediates based on the state of the document at the time it was archived during `scan_checked_replset.js`.
## Pre-requisites
To perform this process, you will need to:
* Upgrade your cluster to MongoDB 4.4.11+ or 5.0.6+.
* Create on your cluster a database user that can:
* read and write to any database
* read the 'local.system.healthlog' collection
* read and write to the '__corruption_repair.unhealthyRanges' collection
* issue the following commands:
* applyOps
* listDatabases
* listCollections
* validate
* dbCheck
* Note that additional explicit privileges to read and write to system collections may be needed
* Prepare a machine for script execution with:
* The (legacy) mongo shell
* python3
* the (latest) pymongo MongoDB driver
* Network access to all members of the replica set being remediated
```
db.adminCommand({
createRole: "remediationAdmin",
roles: [ "clusterManager", "clusterMonitor", "readWriteAnyDatabase"],
privileges: [
{ resource: {cluster: true},
actions: ["applyOps", "listDatabases", "serverStatus"] },
{ resource: {db: "local", collection: "system.healthlog"},
actions: ["find"] },
{ resource: {db: "__corruption_repair", collection: "unhealthyRanges"},
actions: ["find", "insert", "update", "remove", "createCollection", "dropCollection", "createIndex", "dropIndex"]
},
{ resource: { anyResource: true },
actions: ["listCollections", "validate"] },
]
});
db.getSiblingDB("admin").createUser({user: "remediate", pwd: "<password>", roles: [{role: "remediationAdmin", db: "admin"}]})
```
## Important notes:
False positives (inconsistencies that are not a concern) can occur on collections with TTL indexes, because MongoDB does not synchronize the removal of TTL documents between nodes.
# Remediation Steps
The overall high level process is:
1. Use a combination of the `validate` command and the `reIndex` command to ensure the `_id` index is consistent in all collections on all nodes.
1. For each collection in the cluster:
1. Run `dbCheck` to generate initial inconsistency information.
1. Stop writes to the collection.
1. Run `scan_checked_replset.js` to generate specific inconsistency information.
1. Run `repair_checked_documents.py` to resolve the identified inconsistencies, or resolve them manually.
1. Optionally, re-run `dbCheck` to confirm consistency
1. Resume writes to the collection.
## Checking for Local Inconsistencies
Note: The [db.collection.validate()](https://www.mongodb.com/docs/manual/reference/method/db.collection.validate/) method is potentially resource intensive and may impact the performance of your MongoDB instance, particularly on larger data sets. Please review performance considerations [here](https://www.mongodb.com/docs/manual/reference/method/db.collection.validate/#performance) before proceeding.
For each node, run `validate` on all collections on all nodes. [`validate.js`](https://github.com/mongodb/support-tools/blob/master/replset-consistency/validate.js) runs validate on every collection of a given node.
On each node with validation issues, any “m
没有合适的资源?快使用搜索试试~ 我知道了~
用于公开共享支持工具___下载.zip
共263个文件
go:201个
js:15个
md:12个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 86 浏览量
2023-04-19
00:54:05
上传
评论
收藏 730KB ZIP 举报
温馨提示
用于公开共享支持工具___下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
用于公开共享支持工具___下载.zip (263个子文件)
sasl_windows.c 4KB
sspi_windows.c 3KB
sasl.c 2KB
supervisord.conf 4KB
COPYING 10KB
COPYING 10KB
COPYING 10KB
COPYING 10KB
session.go 135KB
session_test.go 93KB
cluster_test.go 48KB
bson_test.go 48KB
play_livedb_test.go 37KB
decode_test.go 32KB
decode.go 31KB
encode.go 30KB
auth_test.go 30KB
mongoreplay_test.go 28KB
flusher.go 26KB
socket.go 26KB
assembly.go 25KB
bson.go 21KB
gridfs.go 20KB
options.go 20KB
cluster.go 18KB
scanner.go 18KB
decode.go 18KB
txn_test.go 17KB
txn.go 16KB
util.go 15KB
gridfs_test.go 15KB
connstring.go 14KB
stat_collector.go 13KB
auth.go 13KB
options_test.go 12KB
mongo_op_handler.go 12KB
recorded_op_generator_test.go 12KB
msg_op.go 11KB
cursors_test.go 11KB
encode.go 11KB
filter_test.go 11KB
server.go 11KB
cursors.go 11KB
bulk_test.go 10KB
encode_test.go 10KB
dbref_test.go 9KB
boolean_test.go 9KB
sim_test.go 9KB
mongo_extjson.go 9KB
execute.go 9KB
filter.go 8KB
db.go 8KB
bulk.go 8KB
play.go 7KB
scanner_test.go 7KB
pcap_test.go 7KB
regexp.go 7KB
command_op.go 7KB
scram.go 7KB
regexp_test.go 6KB
playbackfile.go 6KB
record.go 6KB
raw_op.go 6KB
monitor.go 6KB
openssl.go 6KB
stream.go 6KB
stat_format.go 6KB
config.go 6KB
command_reply.go 6KB
mongo.go 6KB
specdata_test.go 6KB
op.go 5KB
compress.go 5KB
number_test.go 5KB
new_test.go 5KB
dbserver.go 5KB
stream_test.go 5KB
suite_test.go 5KB
minkey_test.go 5KB
maxkey_test.go 5KB
query_op.go 5KB
bench_test.go 5KB
reply_op.go 5KB
single_quoted_test.go 4KB
json_format.go 4KB
decode_d_test.go 4KB
auth_test.go 4KB
number.go 4KB
packet_handler.go 4KB
parallel_file_read_manager.go 4KB
tlsgo.go 4KB
tool_logger_test.go 4KB
testserver.go 4KB
fold.go 4KB
iso_date_test.go 4KB
sasl_windows.go 4KB
mongo_test.go 4KB
update_op.go 3KB
unquoted_test.go 3KB
sasl.go 3KB
共 263 条
- 1
- 2
- 3
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9154
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Scopus Document Download Manager 插件
- 49065784447654二&驴(推荐).apk
- 探索微软新VLM Phi-3 Vision模型:详细分析与代码示例
- 前端开发美信射频前端开发板开发资料美信射频前端开发板开发资料
- 【mysql开发】使用ssm框架+mysql开发,这是一个J2ee项目
- 图像处理MATLAB图像处理,matlab图像处理的基本程序
- 专题讲解:信噪比和噪声系数
- 【matlab仿真】MATLAB入门仿真材料 MATLAB入门仿真材料
- Buffer of Thoughts: Thought-Augmented Reasoning with Large Langu
- 易语言抢购源码,京东抢购助手源码+模块打包
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功