On this page本页内容
This tutorial describes the process for converting a sharded cluster to a non-sharded replica set. 本教程介绍将分片集群转换为非分片副本集的过程。To convert a replica set into a sharded cluster Convert a Replica Set to a Sharded Cluster. 要将副本集转换为分片群集,请将副本集转化为分片群集。See the Sharding documentation for more information on sharded clusters.有关分片集群的更多信息,请参阅分片文档。
In the case of a sharded cluster with only one shard, that shard contains the full data set. 对于只有一个分片的分片集群,该分片包含完整的数据集。Use the following procedure to convert that cluster into a non-sharded replica set:使用以下过程将该群集转换为非分片副本集:
Remove the 从--shardsvr
option from your mongod
.mongod
中删除--shardsvr
选项。
Changing the 更改--shardsvr
option will change the port that mongod
listens for incoming connections on.--shardsvr
选项将更改mongod
侦听传入连接的端口。
The single-shard cluster is now a non-sharded replica set that will accept read and write operations on the data set.单分片集群现在是一个非分片副本集,将接受对数据集的读写操作。
You may now decommission the remaining sharding infrastructure.您现在可以停止使用剩余的分片基础设施。
Use the following procedure to transition from a sharded cluster with more than one shard to an entirely new replica set.使用以下过程从具有多个分片的分片集群过渡到全新的副本集。
mongos
instances. mongos
实例。mongos
instances, the applications will not be able to read from the database. mongos
实例,应用程序将无法读取数据库。mongos
instances, start a temporary mongos
instance on that applications cannot access for the data migration procedure.mongos
实例,请在应用程序无法访问的数据迁移过程上启动一个临时mongos
示例。Use mongodump and mongorestore to migrate the data from the 使用mongos
instance to the new replica set.mongodump
和mongorestore
将数据从mongos
实例迁移到新的副本集。
Not all collections on all databases are necessarily sharded. 并非所有数据库上的所有集合都必须进行分片。Do not solely migrate the sharded collections. 不要只迁移分片集合。Ensure that all databases and all collections migrate correctly.确保所有数据库和所有集合正确迁移。
mongos
instance.mongos
实例。The application will now use the un-sharded replica set for reads and writes. 应用程序现在将使用未分片副本集进行读取和写入。You may now decommission the remaining unused sharded cluster infrastructure.您现在可以停用剩余的未使用的分片群集基础结构。