Skip to Content
MongoDB权威指南(第3版)
book

MongoDB权威指南(第3版)

by Shannon Bradshaw, Eoin Brazil, Kristina Chodorow
November 2021
Intermediate to advanced
410 pages
12h 1m
Chinese
Posts & Telecom Press
Content preview from MongoDB权威指南(第3版)
366
23
2.
管理唯一索引带来的混乱
在任何集合中如果存在唯一索引(除了
"_id"
之外),则应该考虑使用
mongodump
mongorestore
之外的备份方式
。唯一索引要求数据在复制期间不会以违反唯一约束的方式
进行更改。确保这一点最安全的方法是先“冻结”数据,然后按照前面介绍过的方法进行
备份。
如果决定使用
mongodump
mongorestore
,那么在从备份恢复时可能需要对数据进行预处
理。
23.3
 副本集的特殊注意事项
在备份副本集时,除了所需数据之外,还需要获取副本集的状态,以确保生成整个部署集
群的准确时间点快照。
通常,应该对从节点进行备份:这可以减轻主节点的负载,并且锁定从节点不会影响应用
程序(只要应用程序不向从节点发送读请求)。可以使用前面介绍的
3
种方法中的任何一
种来备份副本集成员,但是建议使用文件系统快照或复制数据文件的方式。这两种技术在
应用到副本集从节点上时不需要做任何修改。
当启用了复制时,
mongodump
的使用就不那么简单了
。首先,如果使用了
mongodump
则必须使用
--oplog
选项进行备份,以获得某个时间点的快照,否则备份的状态会与集群
中任何其他成员的状态都不匹配。在从
mongodump
备份恢复时
,还必须创建一份
oplog
否则被恢复的成员就不知道它被同步到哪里了。
要从
mongodump
备份恢复副本集成员
,需要将目标副本集成员作为单机服务器启动,该
服务器上要有一个空的数据目录,并使用
--oplogReplay
选项在其上运行
mongorestore ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

大数据项目管理:从规划到实现

大数据项目管理:从规划到实现

Ted Malaska, Jonathan Seidman
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉
Spark快速大数据分析(第2版)

Spark快速大数据分析(第2版)

Jules S. Damji, Brooke Wenig, Tathagata Das, Denny Lee
Kafka权威指南(第2版)

Kafka权威指南(第2版)

Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty

Publisher Resources

ISBN: 9787115576538