Memungkinkan kamu untuk membuat set replika yang dapat diandalkan untuk database kamu dalam satu kali klik.
Dewacloud memungkinkan kamu untuk membuat sebuah set replika yang dapat diandalkan untuk MongoDB kamu dalam satu kali klik. Solusi yang diimplementasikan memberikan satu set keuntungan, diantaranya:
Keseluruhan proses dari pembuatan MongoDB auto-cluster bisa dilakukan dengan beberapa klik saja.
Open the topology wizard with the New Environment button at the top-left corner of the dashboard, choose MongoDB database, and activate Auto-Clustering via the appropriate switcher.
Tip: Some of the topology specifics of the MongoDB cluster are listed below:
Configure other parameters up to your needs (Public IPs, Region, etc.) and click Create
Wait a minute for the platform to configure the cluster for you.
After successful installation, you’ll receive an email about successful replica set configuration:
You can use these credentials to access the admin panel or to establish connections from your applications to the primary node of the replica set.
Tip: As it is mentioned, any secondary node may become primary in case one fails. Another election will happen if cluster will be restarted and consequently it is quite possible that new primary node will arise.
So, the application connection string becomes invalid. To avoid any of these issues the connection string should contain all of the replica set member hostnames, replica set name and read preferences if necessary to unload the primary node to handle the reads or to ensure cluster high availability and failover.
Here is the connection string example in case of node.js application:
client = new MongoClient(“mongodb://admin:[email protected]:27017,node254968-mongo-cluster.jelastic.com:27017,node254969-mongo-cluster.jelastic.com:27017/admin”, {useUnifiedTopology: true, readPreference:’primaryPreferred’,replicaSet:’rs0′});
Where:
useUnifiedTopology: true
Forces mongodb to use the new Server Discover and Monitoring engine
readPreference:’primaryPreferred’ – Mostly, operations read from the primary but if it is unavailable, operations read from secondary members.
replicaSet:’rs0′ – by default the replica set name is rs0 in Jelastic. You may observe the replica set name at any cluster node in mongod.conf file or in mongo shell prompt.
The outlined above application connection is considered to be established within one hosting platform. But if required, you can make an external application connection to the replica set through SLB. In this case you have to maintain connection to the primary node only for read/writes via Dewacloud Endpoints.
If you need to read from the secondaries you have to customize your application code to perform reading from secondaries in a separate thread as you do it for primary. Anyway, for such cases, you have to remove replicaSet parameter from the connection string so it can look according to email above:
client = new MongoClient( “mongodb://admin:[email protected]:11035/admin”, { useUnifiedTopology: true });
By default, the auto-cluster utilizes the Mongo Express administration panel that provides support for the replica sets.
Also, you can connect to your database via the mongo shell directly in your terminal (for example, using the built-in Web SSH option).
mongo -u {user} -p {password} {DB_name}
Where:
You can check the replica set status with the appropriate command:
rs.status()
As you can see, the replica set (with the default rs0 name) is up and running. Other replica set commands can be found at the official documentation.
For example, use the rs.conf() operation if you want to see replica set configs.
Dewacloud menyediakan MongoDB yang bisa di-install dengan cepat dan mudah. Gratis untuk 30 hari, setelah itu biaya hosting aplikasi cloud WordPress dihitung per-jam berdasarkan pemakaian resources, mulai dari Rp. 39 per jam atau Rp. 28.000 per bulan.
or
Copyright @ 2024 Dewacloud. All rights reserved.