This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html class="no-js" lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>{{mainTitle}}</title> | |
<link rel="stylesheet" href="assets/css/foundation.css" /> | |
<script src="assets/js/vendor/modernizr.js"></script> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Host Recovery -> Triggered when any hosts are in "Recovering" state | |
2. Replication Lag | |
3. Connections: | |
- Normal state: Look at the graphs over time to determine what is the number of normal connections. | |
- Worrying: It is not good to see if the number of connections are increased by 3x or more than the normal numbers. | |
- Critical: There is absolute limit of connections number that can be handled by hosts. We need to put an alert for this situation since 1 opened Connection eats 1 MB. Example: critical alert should be triggered if there are 24k connection opened on our Mongos host since it would eat Mongos Host's 24 gigs of RAM. Below are the normal average numbers of opened connection per sec for several types of hosts: Primary Node -> 10k connections per sec. Secondary Node -> 500 connections per sec. Mongos node -> 200 connections per sec. | |
4. Lock Percentage -> Global Lock %. Generally, we only want to watch this Global Lock % contentions on Primary Host. Generally, 60-70% is acceptable numb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. opcounter, locks% (e.g. Bulk operations would results in high Locks % but low opcounter) | |
2. Lock%, journal stats%, flush average | |
3. Non-mapped virtual memory, connections | |
4. Cursors, connection. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Display the list of ports used by running mongod through running this command: | |
ps aux | grep mongod | |
2. Make notes the port number of mongod process for each replica set's node. | |
3. Open the mongod's process limits file using text editor like cat or vim as shown in this following command: | |
vim /proc/<the mongod's port number noted in pror step>/limits | |
4. Notice 'Max processes' & 'Max open files' entries in the file. Their values should like 1024. At next step, we are going to increase those values. We could also check current limits settings through running this comand: ulimit -a | |
5. Open /etc/security/limits.conf file using text editor apps as root and add these following entries in the file then save the changes: | |
* hard nofile 64000 | |
* soft nofile 64000 | |
6. Logout from current session then relogin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Simple demonstration of documents inserts against mongodb replica set | |
*/ | |
var MongoClient = require('mongodb').MongoClient, | |
assert=require('assert'); | |
var connection_string = "mongodb://127.0.0.1:27017,127.0.0.1:27018,127.0.0.1:27019/pcshop"; | |
console.log("[INFO] - Connecting to "+connection_string+" ..."); | |
MongoClient.connect(connection_string, function(err, db){ | |
if (err) throw err; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTES: Adjust replSet, dbpath, port parameters as you see them fit on your system environments. | |
# Supposed, by default, we want to create a shardings environment where it made up from 2 replica set & each replica set is made up form 3 nodes. | |
# Step #1: Create & Configure replica set for shard 0 | |
# Creates data directories for 3 mongod servers (rs_01, rs_02, rs_03) | |
rm -rf *.log | |
rm -rf ~/MongoDatabase/shard_0/rs_01 ~/MongoDatabase/shard_0/rs_02 ~/MongoDatabase/shard_0/rs_03 | |
mkdir -p ~/MongoDatabase/shard_0/rs_01 ~/MongoDatabase/shard_0/rs_02 ~/MongoDatabase/shard_0/rs_03 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A sample demo to demonstrate Read Preference settings when reading data from a replica set. | |
* Instructions: | |
* 1. Run your replica set servers. | |
* 2. Run this app (note: adjust the replica set's hosts & ports as you see them fit in your environments.) | |
* 3. Shutdown your replica set's primary node. | |
* 4. Watch the outputs of this running app. Confirm that the findOne were defered ( no errors being throws) when the primary node is downed and | |
* then come up again after a new primary node is elected in the replica set. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple code to demonstrate write concerns setting when inserting documents into replica set. | |
* Run this command to install required dependency, in this source code's directory: npm install mongodb | |
*/ | |
var MongoClient = require('mongodb').MongoClient; | |
var assert = require('assert'); | |
// Notice the url query string in the below connection string to replica set. We define write concern = 1 as the default write concern setting. | |
// w=1 means, the driver would returns success once a document has been successfully inserted into the Primary Node. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A sample demo to demonstrate Mongodb Replica Set's failover capability. | |
* Instructions: | |
* 1. Run your replica set servers. | |
* 2. Run this app (note: adjust the replica set's hosts & ports as you see them fit in your environments.) | |
* 3. Shutdown your replica set's primary node. | |
* 4. Watch the outputs of this running app. Confirm that the inserts are defered ( no errors being throws) when the primary node is downed and | |
* then come up again after a new primary node is elected in the replica set. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple code to demonstrate CRUD function on a document against an replica set. | |
* Run this command in this source code's directory to install required dependency: npm install mongodb | |
*/ | |
var MongoClient = require('mongodb').MongoClient; | |
var assert = require('assert'); | |
// Notice that the difference of connection string for connecting to a replica set and a single mongodb server, | |
var connection_string = "mongodb://127.0.0.1:27018, 127.0.0.1:27019, 127.0.0.1:27020/restaurant"; |