Client Connections

<p>This article describes how to install MongDB client in ECS and access DDS instance through MongDB client as a replica set.</p> <p><strong><span style="font-size:18px">Prerequisites</span></strong></p> <p>1. You have successfully bound account and database. For more information, see <a href="http://pinganyun.com/ssr/help/database/mongodb/Start.Binding_Account" target="_blank">Account Authorization and Database Permissions</a>.</p> <p>2. You have successfully created ECS. For more information, see <a href="http://pinganyun.com/ssr/help/database/mongodb/Start.Create_ECS" target="_blank">Create ECS</a>, The instance is running.</p> <p>3. You have successfully enabled a whitelist. For more information, see <a href="http://pinganyun.com/ssr/help/database/mongodb/Start.Create_Whitelist" target="_blank">Create a Whitelist</a>.</p> <p><strong><span style="font-size:18px">Procedures</span></strong></p> <p>1. Log in to a Linux ECS instance. For more information, see <a href="http://pinganyun.com/ssr/help/compute/ecs/Quick_Start.Linux_Quick_Start.Login_Instance" target="_blank">Log In to Instance</a>.</p> <p>2. Run the following command to open the xxx.repo file.</p> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20202408102433-10f1cab794f8.png" style="height:20px; margin:0px; width:80px" />: The <em>xxx </em>parameter specifies a user-customized file name.</p> <pre> <code>cd /etc/yum.repos.d vim xxx.repo</code></pre> <p>3. Add the following contents in the <em>xxx</em>.repo file.</p> <pre> <code>[dds] //Customize the name based on your need. name=MongoDB Repository baseurl=http://yum.cloud.papub/mongodb/yum/el7-3.4/ gpgcheck=0 enabled=1</code></pre> <p>4. Run the following command to upgrade yum source.</p> <pre> <code>yum clean all &amp;&amp; yum makecache</code></pre> <p>5. Run the following command to install MongoDB client.</p> <pre> <code>yum install mongodb-org-shell</code></pre> <p>6. Run the following command to connect to the DDS instance.</p> <pre> <code>mongo "mongodb://&lt;Host-name&gt;:&lt;Port&gt;/&lt;Databases-name&gt;?replicaSet=&lt;ReplicaSet-name&gt;" -u&lt;User-name&gt; -p</code></pre> <p><img src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20202408102433-10f1cab794f8.png" style="height:20px; margin:0px; width:80px" />:</p> <ul> <li>&lt;<em>Host-name</em>&gt;: Domain name of DDS instance. For more information, see <a href="http://pinganyun.com/ssr/help/database/mongodb/Manual.Instance_Management.View_Instance.View_Common_Instance" target="_blank">View Basic Information of Instance</a>.</li> <li>&lt;<em>Port</em>&gt;: Port connection of DDS instance. For more information, see <a href="http://pinganyun.com/ssr/help/database/mongodb/Manual.Instance_Management.View_Instance.View_Common_Instance" target="_blank">View Basic Information of Instance</a>.</li> <li>&lt;<em>Databases-name</em>&gt;: Connect to Authentication Database of DDS instance. For more information, see <a href="http://pinganyun.com/ssr/help/database/mongodb/Manual.Account.Create_Account" target="_blank">Create an Account</a>.</li> <li>&lt;<em>ReplicaSet-name</em>&gt;: Name of DDS cluster. For more information, see <a href="http://pinganyun.com/ssr/help/database/mongodb/Manual.Instance_Management.View_Instance.View_Common_Instance" target="_blank">View Basic Information of Instance</a>.</li> <li>&lt;<em>User-name</em>&gt;: Account of DDS instance. For more information, see&nbsp;<a href="http://pinganyun.com/ssr/help/database/mongodb/Manual.Account.Create_Account" target="_blank">Create an Account</a>.</li> </ul> <p>7. Enter the password you set for your account.</p> <p><strong><span style="font-size:18px">Result</span></strong></p> <p>You has successfully connected to DDS Primary node&nbsp;by default.&nbsp;</p> <p>&nbsp;</p>
Did the above content solve your problem? Yes No
Please complete information!

Call us

400-151-8800

Email us

cloud@pingan.com

Online customer service

Instant reply

Technical Support

cloud products