Connecting to Replica Set Instance (v 4.0)

Last updated: 2021-05-31 17:42:58

    The connection method for MongoDB replica set instances (v4.0) is different from that of other versions. 3 IPs are provided on v4.0 for access, corresponding to 3 nodes in a replica set. When connecting your business in a production environment, you are recommended to configure 3 IPs in the connection string to make the connection more secure and efficient.


    If only the IP of the master node is configured in the connection string, your business may face a read-only connection risk when a master/slave switchover occurs in the instance.

    Getting Connection String

    1. Log in to the TencentDB for MongoDB Console, purchase a replica set instance (v4.0), and perform initialization.
    2. In the instance list, click an instance name to enter the instance details page, click Copy connection string in the private address section to get the connection string of the instance for connecting to the replica set instance.
      Below is a sample connection string:
    3. For more information on how to connect to a replica set instance in different connection methods, please see Connecting to Instances.