MongoDB Setup Overview
- Create 3 databases, each configured to use unique paths and ports (ports: 37017, 37018, 37019)
- Connect to the "soon-to-be" primary database (port 37017) and configure the replica set.
- Add second (port 37018) and third (port 37019) databases to the replica set.
- Installed a demo database using JSON import
- Started a Configuration Server (port 37020)
- Started mongos, pointing at Configuration Server and listening on port 37021
- Connected to mongos (port 37021)
- Added replica set to Shard
- Enabled Sharding on our demodb
- Enabled Sharding on the collection (aka table)
A special thanks to the following website for providing some demo database data and a nice presentation on MongoDB and Ruby apps. Also thanks to the MongoDB docs for creating a cluster.
You may ask, why 3 databases, aren't 2 enough? This is because the recommended MINIMUM number of databases for a Replica Set is 3. If your setup only has 2 databases, Application Insight will flag the Global MongoDB Status as a Warning.
Replica Set is named "rs1".
Download MongoDB (we used 64-bit Linux) from here.
Untar file. Location of files will be referred to as $MEDIA
The remaining commands assume the $MEDIA/bin directory are in your path.
mkdir -p /srv/mongodb/rs1-0 /srv/mongodb/rs1-1 /srv/mongodb/rs1-2
# Start up 3 databases
# Connect to to-be-primary
#Give Primary a configuration for a replication set
#Initiates the replica set
#Displays Replication set
#Add 2nd db - NOTE: you might need to wait for prompt to change to PRIMARY before continuing.
#Add 3rd db
#Display Replication set, confirm three are listed
#Start a config server
#Start mongos pointing at config server
#Connect to mongos
#Add replica set to shard
#Shows replica set and other stats
#Connect to mongos
#Enable sharding for the DB
#Set index for sharding
#Setup sharding of the collection (table)
MongoDB Agent Setup
mongodb-agent.sh config pulse21
Application Insight Screenshots
Anthony Segelhorst and Jamie Carl