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
var mongo = require('mongodb'), | |
primary1 = new mongo.Server('127.0.0.1', 27017, {auto_reconnect:true, poolSize:5}), | |
secondary1 = new mongo.Server('127.0.0.1', 27018, {auto_reconnect:true, poolSize:5}), | |
primary2 = new mongo.Server('127.0.0.1', 27017, {auto_reconnect:true, poolSize:5}), | |
secondary2 = new mongo.Server('127.0.0.1', 27018, {auto_reconnect:true, poolSize:5}), | |
websiteRs = new mongo.ReplSetServers([primary1, secondary1], { | |
rs_name:'nodetest3', | |
read_secondary:true, | |
readPreference:mongo.Server.READ_SECONDARY_ONLY |
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
db.accounts.drop(); | |
db.content.drop(); | |
for(var i=0;i<22000;i++){ | |
print(i) | |
var id = new ObjectId(); | |
db.accounts.save({_id:id}) | |
var numcontent = parseInt(Math.random() * 100) | |
for(var j=0;j<numcontent;j++){ | |
db.content.insert({account_id:id, avg_ctr:Math.random(), published:new Date() }) |
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
# Change the cluster name here | |
whirr.cluster-name=mongotesting | |
# Change the number and roles of machines in the cluster here | |
#whirr.instance-templates=1 mongodb-standalone | |
#whirr.instance-templates=2 mongodb-replsetmember,1 mongodb-arbiter | |
whirr.instance-templates=3 mongodb-replsetmember | |
# For EC2 set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. | |
whirr.provider=aws-ec2 |
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
import sys | |
import subprocess | |
import clint | |
import argparse | |
import random | |
import string | |
import os | |
CLUSTER_TYPES = ["standalone", "replset"] | |
PATH_TO_WHIRR = "/Users/mike/projects/Whirr-MongoDB/bin/whirr" |
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
db.getSiblingDB("admin"); | |
var databases = null; | |
databases = db.runCommand("listDatabases"); | |
if(databases){ | |
for(var i=0;i<databases.databases.length;i++){ | |
//TODO skip if it's the admin database |
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
var mongo = require('mongodb'); | |
var logger = require('logger'); | |
logger.debug = console.log | |
function connect_to_mongo( config_name, master_config, raw, on_connect ) { | |
if (raw){ | |
return create_connection( master_config[config_name]); | |
} | |
var mongo_wrapper = { |
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
From c23186a9dd96ba5dee1b526beab5c91344928836 Mon Sep 17 00:00:00 2001 | |
From: Mike O'Brien <[email protected]> | |
Date: Tue, 14 Aug 2012 18:44:52 -0400 | |
Subject: [PATCH] hack to allow direct linking of mongouris | |
--- | |
build.sbt | 2 +- | |
.../main/java/com/mongodb/hadoop/MongoConfig.java | 5 ++ | |
.../com/mongodb/hadoop/util/MongoConfigUtil.java | 15 ++++- | |
.../com/mongodb/hadoop/util/MongoSplitter.java | 73 +++++++++++++------- |
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
//Usage | |
// example: unwind "tags" field, group by tag + count, save output to collection "FOO" | |
// db.things.agg().unwind("tags").group("tags", {total:{$sum:1}}).out("FOO").exec() | |
var AggHelper = function(collection){ | |
this.collection = collection | |
this.db = collection.getDB() | |
this.pipeline = [] | |
} |
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
function collectDataForCluster(seed){ | |
var connection = new Mongo(seed); | |
var configDb = connection.getDB("config") | |
var shards = configDb.shards.find().toArray() | |
var shardData = {} | |
for(var i=0;i<shards.length;i++){ | |
var shardHosts = shards[i].host; | |
var slashIndex = shardHosts.indexOf("/") | |
if(slashIndex >=0){ | |
replSetName = shardHosts.substring(0, slashIndex); |
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 lang="en-US"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Kanagrinder</title> | |
<!-- Styles --> | |
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css"> | |
<style type="text/css"> | |
td { text-align: center; } |