search

Home  >  Q&A  >  body text

c# - Mongodb中,是否存在多主一从的解决方案?

原因是这样的,我们项目有很多台式机(主机)是放到现场作为采集服务器用的,使用的数据库是Mongodb.且,我们在阿里云购买了个云主机(从机),现场的台式机是保证对现场数据采集的完整性,阿里云主机(从机)保证现场数据的备份和万一现场断网,客户都可以通过阿里云读到以前的旧数据.

伊谢尔伦伊谢尔伦2800 days ago618

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-04-21 11:20:08

    This idea is very reasonable.

    As @Evian said, the primary and secondary in the replica set are not fixed, but come from the election, so the previous failover of the machine can be realized. However, like the questioner, if you hope that a certain machine is more likely to become the primary, then set its priority to be higher than your machine in Alibaba Cloud. The Priority document explains how to operate. Note that there must be at least 3 machines (including arbitor) for replica set to be meaningful.

    In this way, your on-site machine has a high priority. As long as it is alive and the data is not too old, it will become the primary. In the beginning, no one has data, and the on-site machine will naturally become the primary because of its high priority. . If the on-site machine hangs up, the other two machines in Alibaba Cloud will automatically select a new primary as the majority and continue to work happily. Of course, there will be no problem reading data. At this time, if the on-site machine comes back to life, or the network is restored, and Alibaba Cloud's machine finds that the on-site machine is more suitable to be the primary, it will actively step down, and the on-site machine will automatically become the primary, as if nothing has happened... …See Priority’s documentation.

    reply
    0
  • Cancelreply