百度智能云

All Product Document

          Cloud Database MONGODB

          Set Master-Slave Switch of Replica Cluster Instance

          The MongoDB replica cluster instance contains three nodes by default, the Primary node and the Secondary node provide external access addresses, and the Hidden node serves as a daily standby node to ensure high availability. When the master node fails, the high-availability system of the cloud database triggers the switch automatically to ensure the overall availability. Also, the cloud database MongoDB provides a master-slave switch feature for users to trigger the switch in such scenarios as routine disaster recovery drills.

          Background Information

          After the master-slave switch is done through the console or API, the system implements the role exchange of the Primary node and the Secondary node in the replica set instance.

          Descriptions:

          • The master-slave switch is only possible for the replica cluster instances and sharded cluster instances. The single-node instances do not support the master-slave switch due to architectural factors.
          • After triggering the master-slave switch, the connection is off within 30 seconds. Make sure that the application keeps connection continuity.
          • The master-slave switch cannot be done unless the instance is in the running state.

          Operating Steps

          1. Log in to the MongoDB Management Console.
          2. In the upper left corner of the page, select the region where the instance resides.
            In the left navigation bar, click Replica Cluster Instance List.
            Find the target instance, and click the Instance ID to enter the Instance Details page.
          3. In the connection information area, click the Master-slave switch, as shown in the figure below:

          replica-switchHA.png

          1. In the pop-up Master-slave switch dialog box, click OK.
          2. The instance status changes to the status of master-slave switch in progress. After the successful switch, the instance status changes to running.
            In approx. 1 minute, the instance status resumes normal, and the master-slave switch is complete.

          Descriptions:
          If the instance is connected directly through the connection address of the Primary node, the connection is actually at the Secondary node (without write permission) because the master-slave relationship has changed. You need to connect to the instance using the new Primary node connection address. For details, see Instance Linking.

          Relevant APIs

          [Master-Slave Switch of Replica Cluster Instance](MONGODB/API Reference/Instance Related Interfaces/Master-slave Switch between Sharded Cluster Instance Nodes.md)

          Previous
          Instance Management
          Next
          Set Master-Slave Switch of Sharded Cluster Instance