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版)
创建副本集
201
"host" : "localhost:27019"
}
]
}
有人在添加成员
0
时不小心使用了
IP
地址而不是其主机名。如需更改这一设置,首先要将
当前配置加载到
shell
中,然后修改相关的字段:
> var config = rs.config()
> config.members[0].host = "localhost:27017"
现在配置文档修改正确了,需要使用
rs.reconfig()
辅助函数将其发送到数据库:
> rs.reconfig(config)
对于复杂的操作,比如更改成员配置或者一次性添加
/
删除多个成员,
rs.reconfig()
常比
rs.add()
rs.remove()
更有用。可以使用这个命令来进行所需的任何合法的配置更
改:只需简单地创建代表所需配置的配置文档,然后将其传递给
rs.reconfig()
10.8
 如何设计副本集
设计自己的副本集之前,必须先熟悉一些概念。第
11
章会对此进行更详细的说明,这里
先了解一下副本集中最重要的概念,即“大多数”(
majority
:选取主节点时需要由大多
数决定,主节点只有在得到大多数支持时才能继续作为主节点,写操作被复制到大多数
成员时就是安全的写操作。这里的大多数定义为“副本集中一半以上的成员”,如表
10-1
所示。
10-1:什么是大多数
副本集中的成员总数 副本集中的大多数
1 1
2 2
3 2
4 3
5 3
6 4
7 4
注意,副本集中有些成员停止运行或者不可用时,并不会影响“大多数”。大多数是基于
副本集的配置来计算的。 ...
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