Ben McCann

Co-founder at Connectifier.
ex-Googler. CMU alum.

Ben McCann on LinkedIn Ben McCann on AngelList Ben McCann on Twitter


Migrating from MongoDB to TokuMX


First be sure to install the latest version of TokuMX on the target machines, which is currently 1.4.2. Also, for all long-running commands, you’ll want to run them in a tmux session. You can create a new tmux session with tmux new, attach to the default session with tmux attach -d, and quit a tmux Read More

Finding the size of all MongoDB collections


Here’s a helpful script for finding the size of every table in MongoDB in MB: var collNames = db.getCollectionNames(); for (var i = 0; i < collNames.length; i++) { var coll = db.getCollection(collNames[i]); var stats = coll.stats(1024 * 1024); print(stats.ns, stats.storageSize); }

Resyncing a very stale MongoDB Replica


I logged into the primary member of the replica set and ran rs.status() which showed me that the replica was too stale (“error RS102 too stale to catch up”): { “_id” : 4, “name” : “”, “health” : 1, “state” : 3, “stateStr” : “RECOVERING”, “uptime” : 502511, “optime” : { “t” : 1340841938000, “i” Read More

Backing Up MySQL with Percona Xtrabackup


You can create a MySQL backup with Percona Xtrabackup by running: $ innobackupex –user=DBUSER –password=DBUSERPASS /path/to/BACKUP-DIR/ You can then restore the backup with: $ xtrabackup –prepare –datadir=/var/lib/mysql –target-dir=/path/to/BACKUP-DIR/ $ sudo service mysql stop $ sudo mv /var/lib/mysql ~/dbbackup $ sudo mv /path/to/BACKUP-DIR /var/lib/mysql $ sudo chown -R mysql:mysql /var/lib/mysql $ sudo service mysql start $ Read More

Setting up the RockMongo GUI on Ubuntu


The easiest way to get started is to install Apache and PHP: $ sudo apt-get install apache2 php5 php-pear If you need to edit the Apache ports because you already have another server running on port 80 then edit /etc/apache2/ports.conf. You’ll need to install the PHP Mongo connector: sudo pecl install php_mongo Add “extension=mongo.so” to Read More

Brewer’s CAP Theorem Explained


When dealing with distributed systems, Brewer’s CAP theorem is often brought up when discussing how a system will behave in certain error conditions. The CAP theorem means that you can only have two of: consistency, availability, and partition tolerance. Here’s what you’ll be giving up for each of the three that you may sacrifice: C: Read More

Migrating from MySQL to Percona Server


Percona Server is just MySQL with a few extra options added in by Percona. It’s backwards compatible and based off the same code base. If you’re not familiar with Percona, they are the world’s leading MySQL consultants. The main reason I switched is because Ubuntu uses an old version of MySQL. Ubuntu is about a Read More

MySQL Commands Cheatsheet


Install SQL Buddy sudo apt-get install apache2 libapache2-mod-php5 php5-mysql sudo /etc/init.d/apache2 restart Download SQL Buddy, unzip, and move to /var/www Allow connections from a remote server: Set the bind address in /etc/mysql/my.cnf to your ip address Open the port in the firewall by running “/sbin/iptables -A INPUT -i eth0 -p tcp –destination-port 3306 -j ACCEPT” Read More