Monthly Archives: December 2010

Allow users to use rabbitmqctl

RabbitMQ is our message queue of choice for Celery. One of its main commands is rabbitmqctl; it lets you manage your rabbit nodes. The command itself is just a shell script that uses sudo -u rabbitmq to run an the Erlang rabbitmqctl program. It has to use sudo so that can it run as the rabbitmq user to use the same Erlang cookie that the broker is running with.

If you want to allow more than root or wheel group members to use the command, just use this sudoers privilege specification:

ALL=(rabbitmq) SETENV: NOPASSWD: /usr/local/bin/erl

(rabbitmq) assumes your RabbitMQ broker runs as the ‘rabbitmq’ user. It also assume you have Erlang installed in /usr/local

memcache-top patch to see curr_items

I stumbled upon memcache-top in the Homebrew Formula repository. It’s a neat little Perl application that aggregate stats from a memcached cluster and displays it in a nice little table.

I like to use: memcache-top --servers='server1,server2,server3' --commands --sleep=1

My only qualm is it doesn’t display the curr_items stat. So I wrote a little patch for v0.6 that will add an ITEMS column to the table.

Get the patch from the issue I filed.

MySQL 5.5 Homebrew Formula

I recently switched to a 27″ iMac workstation running Snow Leopard from Ubuntu 10.10 (Maverick Meerkat). The resident Mac fanbois suggested Homebrew over Fink and MacPorts. At first I didn’t heed their warnings and went with MacPorts (I do love the FreeBSD ports system of which MacPorts is based on). However, when it decided to start setting up its own environment I understood the warnings. So I scrapped that and went with Homebrew.

Small issue with Homebrew is it seems to want to stick to ‘Stable’ releases. I really didn’t want to use MySQL 5.1 since it’s a snail compared to MySQL 5.5. Not having an ultra-fast storage array in my iMac this would become an issue with all the work I have to do. So I set out into Ruby land and banged out my first Homebrew formula.

Since it hasn’t been pulled into the official repo, here’s the latest commit: MySQL 5.5 Homebrew Formula

Mainline Homebrew now has 5.5.x as the default MySQL version

Updated: Oracle released MySQL 5.5.8; the first GA release of the 5.5 series.

Resources:
Homebrew Formula cookbook
Building MySQL [5.5] from Source

How to dump memcache key/value pairs fast

Recently we migrated our memcached cluster to a new larger one. This needed to be done mostly for reliability and speed, but it’s also nice being able to have access to new stats like ‘reclaimed’ in 1.4.5.

We decided against migrating data from cluster to cluster because there are long-expire keys we no longer care about. Instead, we just ran some scripts to fill the new cluster with new data. After the scripts finished and the new cluster ran in production for a couple days, it only contained ~70% the data the old cluster possessed. We were curious what that old data was, so we decided to dump it and analyze.
Continue reading