Skip to content

ldtalent/olumuyiwaa-How-to-setup-an-optimized-HA-mongodb-replicaset-on-AWS-EC2

Repository files navigation

OlumuyiwaA-How-to-setup-an-optimized-HA-mongodb-replicaset-on-AWS-EC2

Important Notes before you start:

env and .env

  • in production, .env file will not be required. the ROLE_ARN variable will be provided by the IAM Instance Profile value

index.js

  • NB: Do NOT deploy this file and package*.json on the same level with the replica set code, these files are in this repo for ease of reference, they should be installed locally for testing the replica set only
  • this is the app used to test the deployed replica set
  • change the URI to the value for your deployed replica set
  • if you change the value of the test database when configuring the replica set, then dbname must bechanged also. This also applies to the test collection collectionName

example-queries.js

  • this is a set of example queries used to demonstrate proper data modeling for mongodb
  • NB: Do NOT deploy this file with the replica set code, these files are in this repo for ease of reference only

connection.js

  • this file demonstrates a best practice method for connecting to mongodb
  • NB: Do NOT deploy this file with the replica set code, these files are in this repo for ease of reference only

user data

  • there are 2 versions, one for the data nodes, the other for the hidden node
  • replace the placeholders for the github credentials with your values
  • ensure the S3 Backup bucket variable is replaced with your value, this applies to the user-data for both types of nodes

sample.conf

  • this is the production config file for mongodb. it will replace the default mongodb.conf file.
  • replace the replSetName variable with your chosen replica set name

sample-keyfile

  • this is the SSH keyfile used by replica set members for secure communication
  • do not use this file as is, rather generate your own e.g.
openssl rand -base64 756 > <path-to-keyfile>

restore.sh $ backup.sh

  • these arethe bash script which restores replica set databases saved to S3 onto a fresh node
  • insert your values for the auth creds for the database which will be restored to the replica set

provisioning.yml

  • this is the ansible playbook which provisions primary/secondary members of the replica set
  • replace mongodb_dbase_backup with your chosen filename for the mongodb database zip archive saved on AWS S3. Do NOT add the .gz extension
  • repeat the previous step here also

initiate-replicaset and add-replicaset-members

  • these files provide instruction on initiating the replica set and adding member nodes after provisioning completes
  • NB: Do NOT deploy this file with the replica set code, these files are in this repo for ease of reference only

hugepages-fix

  • this file is a systemd service file to tune the EC2 instance for mongodb in production

hidden-node.yml

  • this is the ansible playbook which provisions hidden-node of the replica set
  • replace mongodb_dbase_backup with your chosen filename for the mongodb database zip archive saved on AWS S3. Do NOT add the .gz extension
  • repeat the previous step here
  • and here

notifiers

  • there are 4 versions, backup, restore and data/hidden node. these notifiers send an email to the database admin to inform of lifecycle events
  • replace the authorized sender/receiver variables with your AWS SES values
  • replace the authorized aws region variables with your AWS Region value

models/

  • these are a collection of data models used to illustrate proper data modeling for mongodb
  • NB: Do NOT deploy this directory with the replica set code, these files are in this repo for ease of reference only

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published