November 21, 2017

MongoDB 3.4 Replica Set – Installation Instructions

https://aws.amazon.com/marketplace/pp/B07CL8YW27/ref=_ptnr_floatingcloud_ste_mongoswarm

MongoDb 3.4 Replica Set

Replicated MongoDB from Floating can be in 3 different Regions or in a single region. Replication allows your data to be secure and fast in different regions. You can write to the Primary instance and read from the replicas. This is great for faster games and apps. Secondaries can also be used for reports.

MongoDB Replica set access instructions are below.

MongoDB is the fastest growing NoSql solution. Replicated MongoDB can be deployed 3 different Regions or in a single region. Replication allows your data to be secure in different regions. You can write to the Primary and read from the replicas. This is great for faster games and apps. Secondaries can also be used for reports.

Watch the video about how easy it is to install a MongoDB replica set from Floating Cloud.

A Manager server builds and monitors the 3 MongoDB instances. When deployed in a single region the Manager also serves as a proxy. This installation uses Docker and Docker-Machine facilitate the easy installation.

This refers to https://aws.amazon.com/marketplace/pp/B07CL8YW27/ in the Aws Marketplace

This set has a very simple pricing structure. No matter how large your database is, up to 16 TB, the price for the installation stays the same. This also includes Floating Tech Support via email, chat or even by phone. We are happy to guide Floating Cloud Subscribers through any issues they have.

You can read all about the development of this great product set at: Running-a-mongodb-replica-set-on-docker-1-12-swarm-mode-step-by-step/

The MongoDB Containers and servers are configured with best practices such as using an external volume which is formatted using XFS. If the instances gets damaged the data should be protected on the separate EBS Volume that is not deleted on termination.

Yearly Price gives a free month.

Access Instructions to MongoDB Replica Set

Once you have subscribed and confirmed your subscription you can run the CloudFormation template. It asks a few questions with drop down menus. Allow a half hour for the script to run, then read the access instructions.

Replicated MongoDB Template

Acccess via CLI.

You need to have mongo client installed on the computer that you use to access your Replicated MongoDB from Floating Cloud or to use your API driver.

Each server has a different port opened to access the Database.

mongo mongodb://PublicDNS-Ofcfloating0:27017/test

You can now start building your database. All changes are immediately written to the replicas.

Secondary Replicas can be accessed from a CLI as follows:

mongo mongodb://PublicDNS-floating1:27018/test

mongo mongodb://PublicDNS-floating2:27019/test

In the above command, “test” is the DB name. The remote connection URL below has the DB name test at the end. Use a different db name to connect to one that you created.

From the Mongo Shell you can see installed DB’s type”show dbs”

From here you can build, develop and learn,

You can download MongoDB drivers from https://docs.mongodb.com/ecosystem/drivers/

Warning: Security for your This MongoDB Replica set is your RESPONSIBILITY! No Password or encryption has been set.

You can Connect your app remotely.

In order to connect to the MongoDB set and its manager you need to ssh to the manager. The manager is a Docker Swarm Manager, it stores the keys to each server, so that you can control and login to the servers.

Access the Manager EC2 like you would any other Ubuntu Linux EC2 Server. Follow the instructions from the EC2 Panel, in the Region that you ran the Cloudformation.

Once you have a bash prompt, you can access each container that stores the MongoDB engine

There are 2 ways to access the Docker containers

do eval `docker-machine env charming0`

Change the number to 1 or 2 to access the Secondary Replicas.

From here you can run docker exec to access the container or the MongoDB running in the container.

To access the Database run:

docker exec  -it $(docker ps -q) mongo

To access the container (which is like a mini-linux) run:

docker exec -it $(docker ps -q) bash

You can ssh into the Floating Cloud EC2 instances (to the real Linux prompt). You might want to do this in order to update the Ubuntu server instance

From the manager EC2 instance you, run:

docker-machine ssh charming0

Change the number to 1 or 2 to access the Secondary Replicas.

The keys for each of the MongoDB set are stored in the Swarm Manager. Ssh has been limited by security groups only from the Swarm Manager.

The following is the same as the above Docker connection method that uses eval.

To access the Database run:

docker exec  -it $(docker ps -q) mongo

To access the container (which is like a mini-linux) run:

docker exec -it $(docker ps -q) bash

Important! The Data is stored on a separate EBS Volume which is mounted as /mnt/charming. This is formatted as XFS like MongoDB prefers If the Replica set is damaged your data should be safe. You can find each EBS Volume in the EC2 Panel, they are named charming with a number after them from 0 through 2.

Backups can be done by doing Snapshots of either the Primary or the secondaries, or through a dump. See https://docs.mongodb.com/manual/tutorial/backup-and-restore-tools/ 

 

  • Important this set is NOT highly available. When one of the servers is turned off it is really hard to  recover. The Swarm Manager contains all of the SSH keys to the other instances, so if that dies you will lose access, but not your data. The data is pretty safe as it is replicated and never automatically removed.

Uninstall Replicated MongoDB

The Swarm Manager has termination protection, This is to remind you that you should first delete the MongoDB Instances.

The MongoDB was created by Docker Machine and Docker Swarm, so in order to un-install you first need to run our Un-install script.

From the Linux Shell enter:

uninstall-mongo-swarm.sh

This removes the Replicated MongoDB Servers as well as IAM rules and roles that were created by Docker-Machine.

This Script does NOT remove the Docker-Machine security group nor does it remove the XFS Volumes that have your precious data. You can delete these from the EC2 panel.

In Order to remove the Swarm Manager Instance and it’s IAM roles you need to first remove termination protection in the EC2 panel. Right Click on the instance and select settings and change termination protection. After removing Termination Protection you can go into the CloudFormation panel in the AWS Console and delete the Stack.

Select delete to delete the keys

ADD remove roles and policies.

See the discussion of how this works at:

http://floatingcloud.io/running-a-mongodb-replica-set-on-docker-1-12-swarm-mode-step-by-step/

An average cost prediction using regions around the world for all 4 instances should cost about $94.  Click the calculator link to figure exactly what your configuration will cost.

https://calculator.s3.amazonaws.com/index.html#key=calc-3EA8DF24-334B-40B9-9DAB-F750B3980E87

https://aws.amazon.com/marketplace/pp/B07CL8YW27/ref=_ptnr_floatingcloud_ste_mongoswarmhttps://aws.amazon.com/marketplace/pp/B07CL8YW27/ref=_ptnr_floatingcloud_ste_mongoswarm

https://aws.amazon.com/marketplace/pp/B07CL8YW27/ref=_ptnr_floatingcloud_ste_mongoswarm

Hits: 3218