This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
I. Create a java project using Maven: | |
------------------------------------- | |
1. Run command: mvn archetype:generate. | |
2. On the next displayed prompt, press [ENTER]. | |
3. At next prompt, enter 1-6 option on the prompt. Enter the highest option number (e.g. 6). | |
4. Enter 'groupId' on the next prompt (e.g. com.mycompanyname). | |
5. Enter 'artifactId' on the next prompt (e.g. myapplicationname). | |
6. Enter 'packageName' on the next prompt (e.g. com.mycompanyname). | |
7. Enter 'version' on the next prompth (e.g. 1.0.0). | |
8. Run this command to ensure that your java project has been created successfully: |
This file contains hidden or 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
# This file is usually placed in this following path: /etc/nginx | |
user nginx; | |
#user root; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; |
This file contains hidden or 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> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script> | |
<style> | |
table, th, td { | |
border: 1px solid grey; | |
border-collapse: collapse; | |
} | |
th, td{ |