gpt4 book ai didi

MongoDB 独立与副本集以及如何将数据从独立迁移到副本集

转载 作者:行者123 更新时间:2023-12-03 01:45:46 26 4
gpt4 key购买 nike

我有一些关于 MongoDB 独立版和副本集的问题,我不太明白。

  • 我什么时候应该使用它们中的任何一个
  • 为什么所有副本集教程都显示 3 个连接,有原因吗?
  • 我可以仅为 1 个实例创建副本集吗?在这种情况下,它与独立的 mongodb 实例有何不同?
  • 如何将数据从独立实例迁移到副本集?

我问所有这些问题是因为最近我试图实现事务和 session 只能在“副本集”上启动,我根本不明白其中的区别。

最佳答案

  • 我什么时候应该使用它们中的任何一个?

Replication is the process of synchronizing data across multiple servers. Replication provides redundancy and increases data availability with multiple copies of data on different database servers. Replication protects a database from the loss of a single server. Replication also allows you to recover from hardware failure and service interruptions. With additional copies of the data, you can dedicate one to disaster recovery, reporting, or backup.

  • To keep your data safe
  • High (24*7) availability of data
  • Disaster recovery
  • No downtime for maintenance (like backups, index rebuilds, compaction) Read scaling (extra copies to read from)
  • Replica set is transparent to the application
  • 为什么所有副本集教程都显示 3 个连接,有原因吗?

The basic implementation to take full advantage of replication specifies youshould have at least one primary node with two secondary nodes. So theexamples are always with 3 nodes. Not only this if from 3 thePrimary node goes down you still have 2 nodes (mongoDB will assignusing arbiter rule) and one primary and one secondary for high availability

  • 我可以仅为 1 个实例创建副本集吗?在这种情况下,它与独立的 mongodb 实例有何不同?

It does not make sense to have single instance with mongo replication.

  • 如何将数据从独立实例迁移到副本集?

Convert a Standalone to a Replica Set . Your existing data will be migrated to all replication instances once they are up and running when converted to replication sets from standalone.

关于MongoDB 独立与副本集以及如何将数据从独立迁移到副本集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55510453/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com