MongoDB High-availability cluster switching
- MongoDB's simplest cluster mode is the three-node replica set (replica set), which ensures that after a node failure, the remaining nodes can continue to provide services.
- In the MongoDB cluster, there is also the role of the primary node and the standby node, such as the main node problem, will be elected in the standby node to generate a new master node, its primary standby node automatically to the new master node synchronization.
- After switching between the old and new master nodes, it is almost transparent to the front-end application because of the special connection string configuration of MongoDB:
mongodb://[username:[email protected]]host1[:port1][,host2[:port2],…[,hostN[:portN]]][/[database][?options]]
At last
- In the above configuration, you can configure multiple MongoDB Host,mongodb will automatically detect the primary node in the replica set, and make connections, such as the primary node hangs, when the switchover process is not completed, the front-end application will error, until the switch is complete, the new connection will be connected to the new primary node to continue to provide services.
- This special connection string implementation, no longer for MongoDB to build the VIP auto-switch, such as LVS, the default is to support high-availability failover.
MongoDB High-availability switch