- 分片 >
- Sharded Cluster Administration >
- 将一个集群转化为复制集
将一个集群转化为复制集¶
On this page
这篇教程描述了将 sharded cluster 转化为未分片的 replica set 的方法.将复制集转化为集群的方法,可以参见 Convert a Replica Set to a Sharded Cluster. 关于集群的更多信息,可以参见 分片.
将只有一个分片的集群转化为复制集¶
在 sharded cluster 只有一个分片的情况下,使用以下的过程将其转化为未分片的 replica set:
Reconfigure the application to connect to the primary member of the replica set hosting the single shard that system will be the new replica set.
Remove the --shardsrv option from your mongod.
注意事项
Changing the --shardsrv option will change the port that mongod listens for incoming connections on.
The single-shard cluster is now a non-sharded replica set that will accept read and write operations on the data set.
你现在可以去掉集群中其他组件了.
将集群转化为复制集.¶
Use the following procedure to transition from a sharded cluster with more than one shard to an entirely new replica set.
With the sharded cluster running, deploy a new replica set in addition to your sharded cluster. The replica set must have sufficient capacity to hold all of the data files from all of the current shards combined. Do not configure the application to connect to the new replica set until the data transfer is complete.
Stop all writes to the sharded cluster. You may reconfigure your application or stop all mongos instances. If you stop all mongos instances, the applications will not be able to read from the database. If you stop all mongos instances, start a temporary mongos instance on that applications cannot access for the data migration procedure.
Use mongodump and mongorestore to migrate the data from the mongos instance to the new replica set.
注解
并不是所有的数据库都被分片,不要仅仅迁移分片的集合,要把所有的数据库和所有的集合都迁移完.
Reconfigure the application to use the non-sharded replica set instead of the mongos instance.
应用现在将会使用未分片的 replica set 用于读写。您现在就可以停止使用剩余未使用的分片集群架构。