Skip to content

Instantly share code, notes, and snippets.

View bugcy013's full-sized avatar
🪄
Focusing

Dhanasekaran Anbalagan bugcy013

🪄
Focusing
View GitHub Profile
@bugcy013
bugcy013 / mongodb_3.2.x_sharding.md
Created October 21, 2016 08:48 — forked from leommoore/mongodb_3.2.x_sharding.md
MongoDB 3.2.x Sharding

#MongoDB 3.2.x Sharding Sharding is used when the database is too large to run on a single server and you need to spread the load across multiple servers. The name itself refers to the breaking (sharding) of the data into seperate groups of data which will reside on different servers.

##Configuration Server Start the server on your server (myserver0)

mongod --configsvr --dbpath /data

On myserver1 start the shard giving the configuration server as the --configdb option

#MongoDB 3.2.x Replica Sets on AWS EC2 A MongoDB replica set provides a mechanism to allow for a reliable database services. The basic replica set consists of three servers, a primary, a secondary and an arbitrator. The primary and secondary both hold a copy of the data. The arbitrator is normally a low spec server which just monitors the other servers and help with the failover process. In production, there can be more than three servers.

To setup mongo as a replica set on Amazon Web Services EC2 you need to first setup a security group with ssh on port 22 and mongodb on port 27017. You then need to create three servers. Select Ubuntu 14.04 LTS x64 and a micro (or bigger depending on your database size, ideally you should have enough memory to match your database size) instance for the primary and secondary and a nano instance for the arbitrator.

##Adjust the File System on each Server The operating system by default will update the last access time on a file. In a high data throughput database application

@bugcy013
bugcy013 / gist:11e503446767178808fa
Created December 18, 2015 09:52 — forked from StuHorsman-zz/gist:0ed851f01bf926377bef
Mysql on Ubuntu setup (CM)
# install mysql
cd ~/cdh-preinstall
apt-get install mysql-server mysql-client libmysql-java -y
# stop and copy in new my.cnf
sudo service mysql stop
sudo cp files/my.cnf.ubuntu /etc/mysql/my.cnf
# restart mysql and secure
sudo mysql start
@bugcy013
bugcy013 / example2.js
Last active October 18, 2015 12:44 — forked from anonymous/example2.js
MongoDB map reduce example 2
// suggested shell cmd line to run this:
//
// mongo --shell example2.js
//
// Note: the { out : … } parameter is for mongodb 1.8+
db.things.insert( { _id : 1, tags : ['dog', 'cat'] } );
db.things.insert( { _id : 2, tags : ['cat'] } );
db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } );
db.things.insert( { _id : 4, tags : [] } );
@bugcy013
bugcy013 / our_setup_script.js
Created October 18, 2015 12:43 — forked from shussekaido/our_setup_script.js
MongoDB M102 week6 file
db = db.getSisterDB("config");
var mongosConn = db; // assume we connected to a mongos to get going
var res = null;
function check() {
printjson(res);
if( !res || !res.ok ) {
throw "check(): not ok, stopping";
#!/bin/bash
# credit: Robert Larsen
function create_shard(){
shard=$1
repl_factor=$2
shard_name="shard_${shard}"
shard_dir=shard${shard}
init='rs.initiate({_id:"'${shard_name}'",members:['
@bugcy013
bugcy013 / gist:058f0d837fa13e690cc8
Created October 5, 2015 09:35 — forked from umit/gist:6194262
MongoDB Sharding
#!/bin/bash
echo "Make data dirs...."
mkdir ~/data
mkdir ~/data/config
mkdir ~/data/db
mkdir ~/data/shard0
mkdir ~/data/shard0/rs0
mkdir ~/data/shard0/rs1
mkdir ~/data/shard0/rs2
@bugcy013
bugcy013 / MongoDB Basics.md
Last active October 5, 2015 09:33 — forked from blkpark/db_account.md
MongoDB Basics
@bugcy013
bugcy013 / shutdown_email.sh
Last active August 29, 2015 14:25 — forked from fuzzmz/email.sh
#!/bin/sh
### BEGIN INIT INFO
# Provides: SystemEmail
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Send email
# Description: Sends an email at system start and shutdown
### END INIT INFO
Variables
==========
predefined variables :
- inventory_hostname (fqdn) (normally the same as ansible.fqdn)
- inventory_hostname_short
To know the return codes returned by ansible modules, just use plain ansible -vvv to see them :
ansible -i ~/ansible/arrfab.net/hosts/hosts.cfg -vvv -m copy -a 'src=files/sysinfo dest=/etc/sysinfo' tungstene.arrfab.net
tungstene.arrfab.net | success >> {
"changed": true,