Skip to content

Instantly share code, notes, and snippets.

View mhelmstetter's full-sized avatar

Mark Helmstetter mhelmstetter

  • MongoDB
  • San Diego, CA
View GitHub Profile
@mhelmstetter
mhelmstetter / SSLApp.java
Last active December 24, 2015 16:29
Sample Java application connecting to MongoDB via SSL
import javax.net.ssl.SSLSocketFactory;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
public class SSLApp {
#!/bin/bash
ps aux | grep mongod | awk '{print $2}' | xargs kill -9
ps aux | grep mongos | awk '{print $2}' | xargs kill -9
data=~/cluster
options="--smallfiles --noprealloc --oplogSize 128 --storageEngine wiredTiger"
rm -rf $data/config/*
rm -rf $data/shard0/*
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 85 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
# config: /etc/mongod.conf
# pidfile: /var/run/mongodb/mongod.pid
@mhelmstetter
mhelmstetter / gist:89fa0a415571d8211cef
Last active August 29, 2015 14:22
mongod-settings
#!/bin/bash
# chkconfig: 35 84 14
. /etc/rc.d/init.d/functions
echo "Applying MongoDB settings"
blockdev --setra 32 /dev/sdc
blockdev --setra 32 /dev/sdb
#!/bin/sh
### BEGIN INIT INFO
# Provides: disable-transparent-hugepages
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before: mongod mongodb-mms-automation-agent
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description: Disable Linux transparent huge pages, to improve
#!/bin/bash
ps aux | grep mongod | awk '{print $2}' | xargs kill -9
ps aux | grep mongos | awk '{print $2}' | xargs kill -9
data=~/cluster
options="--smallfiles --nojournal --noprealloc --oplogSize 128"
rm -rf $data/shard0/*
#!/bin/bash
echo -n "Enter MongoDB hostname of any replica member: "
read host
primary=`mongo --quiet --host $host <<EOF
db.isMaster().primary
EOF`
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 85 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod-blockstore
# config: /etc/mongod-blockstore.conf
. /etc/rc.d/init.d/functions
#!/bin/bash
### BEGIN INIT INFO
# Provides: disable-transparent-hugepages
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before: mongod mongodb-mms-automation-agent
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description: Disable Linux transparent huge pages, to improve
#!/bin/bash
ps aux | grep mongod | awk '{print $2}' | xargs kill -9
data=~/cluster
options=""
rm -rf $data/shard0/*
mkdir -p $data/shard0/m0