Skip to content

Instantly share code, notes, and snippets.

@azat
azat / mongos
Created Apr 25, 2012
mongos sysv init script
View mongos
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
@azat
azat / mongodb-configsrv
Created Apr 25, 2012
mongodb config server sysv init script
View mongodb-configsrv
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
@azat
azat / mongodb
Created Apr 25, 2012
clear mongodb sysv init script
View mongodb
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
@azat
azat / mongodb-arbiter
Created May 21, 2012
mongodb arbiter sysv init script (replica set)
View mongodb-arbiter
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
@azat
azat / mongodb-arbiter.conf
Created May 21, 2012
mongodb arbiter configuration file
View mongodb-arbiter.conf
# mongodb-arbiter.conf
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
#dbpath=/var/lib/mongodb
dbpath=/work/mongo/db_arbiter
@azat
azat / mongos.conf
Created May 21, 2012
mongos configuration file
View mongos.conf
logpath = /var/log/mongodb/mongos.log
logappend = true
configdb = 127.0.0.1:27019
@azat
azat / mongodb-configsrv.conf
Created May 21, 2012
mongodb-configsrv configuration file
View mongodb-configsrv.conf
configsvr = true
logpath = /var/log/mongodb/mongodcfg.log
logappend = true
dbpath = /work/mongo/configsrv
@azat
azat / crc32.js
Created May 21, 2012
crc32 javascript implementation
View crc32.js
// @link http://www.digsys.se/JavaScript/CRC.aspx
var crc32 = {
// CRC polynomial 0xEDB88320
tab: [ // integer because this is a copy-paste from json string
0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,
249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,
498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,
325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,
997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,
901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,
@azat
azat / shard-status.js
Created May 21, 2012
mongodb shard-status
View shard-status.js
// shard-status
while (true) {
db.currentOp().inprog.forEach(function(row) { if (row.query.moveChunk) printjson(row.query.shardId + " " + row.msg + " secs: " + row.secs_running + " switches: " + row.numYields); });
sleep(1000);
}
@azat
azat / mongodb-unshard.js
Created May 21, 2012
mongodb manually unshard
View mongodb-unshard.js
// set
var collection = ;
var db = ;
var fromHost = ;
// unshard
db = db.getMongo().getDB(db);
var collection = db.getCollection(collection);
var m = new Mongo(fromHost);