The reason for this is that many desktops (hosts) in our project are put on site as collection servers, and the database used is Mongodb. Moreover, we bought a cloud host (slave) in Aliyun. The desktop on site guarantees the integrity of data collection on site, and Aliyun host (slave) guarantees the backup of site data and in case of site disconnection, customers can read the old data through Aliyun.
This idea is very reasonable.
As @ Evian said, the primary and secondary in replica set are not fixed, but election, so the failover before the machine was realized. However, like the subject, if you want a machine to be more likely to be primary, set its priority higher than your machine in Arroyo.Priority’s documentation,How to operate. Note that there must be at least 3 machines (including arbitor) before replica set is meaningful.
In this way, your machines at the scene have a high priority. As long as it is alive, the data will become primary if it is not too old. At the beginning, everyone has no data, and the machines at the scene will naturally become primary because of the high priority. If the machines at the scene hang up, the other two machines at Aliyun, as the majority, will automatically choose a new primary and continue to work happily. Of course, there is no problem reading the data. At this time, if the machine on the scene is alive or the net is ready, ariyun’s machine finds that the machine on the scene is more suitable to be the primary and takes the initiative to step down. the machine on the scene automatically becomes the primary, and everything seems to have never happened … seePriority’s documentation.