Archive for December, 2007

Oh Damn! A useful gag gift.

Monday, December 24th, 2007

Head Wipes

I shit you not. These actually do feel great after a long day but if you don’t believe me, a researcher and firefighter cannot be wrong. Seriously, though, given as a gag gift I was surprised to find that they felt great wiping down my scalp leaving behind a mild and pleasant scent in its wake. Certainly, I’ll be using them again and checking out some of their other products.

EC2, MySQL Replication, Monitoring, and You!

Monday, December 24th, 2007

So in a full turn of events I’ve gone back to replication as the the most cost effective solution for creating a high availability environment for MySQL in EC2. The problem of the development team issuing schema changes frequently and without notification hasn’t changed but I have gotten a little more sophisticated about how to deal with them kicking the slave in the teeth when they issue schema changes with impunity.

What I’ve done is build off the backup scripts I have written about prior–especially since they work so well and created the beginnings of a metascript to over see the slaves–it is aptly named slaver. This metascript checks the state of the slave and acts based on it is state: slave up, run backups, or slave down, issue notifications.

#!/bin/bash
### Slaver v0.0.1
### this script is intended to check on the status of the slave
### if the slave is down (IO or SQL) it will send an email out

### set the variables that we are checking for ###
slaver1=$(mysql -Bse ‘show slave status \G;’ | grep Slave_IO_Running)
slaver2=$(mysql -Bse ‘show slave status \G;’ | grep Slave_SQL_Running)
IO=${slaver1:29}
SQL=${slaver2:29}
COMBO=$IO-$SQL
count=$(mysql -Bse ‘show slave status \G;’| grep -c Yes)

### this is sanity check testing stuff ###

#count=1
#echo $IO
#echo $SQL
#echo $COMBO
#echo $count
### this is sanity check testing stuff ###

### run the exception check ###
if [[ "$count" == "2" ]] ; then
/opt/s3sync/db_backup.sh
exit
else
### create status file and mail it ###
date >> status.txt
mysql -Bse ‘show slave status \G;’ >> status.txt
mutt you@yourhome.com -s “Slave Status :: DOWN” < status.txt
rm status.txt
fi

The next pieces to build out will be freezing the automated deletion of the old backup sets and attempting recovery of the slave if it is down. To get started on the latter I made some changes to the backup routine on the master:

#! /bin/bash

# Hourly cron job to upload to current bucket
# This is built off what we are currently running

# set date variables
DAYNOW=$(date +%j)
TIMENOW=$(date +%H%M)
# set the environment
export AWS_ACCESS_KEY_ID=xxxyyyzzz
export AWS_SECRET_ACCESS_KEY=xxxyyyzzz
export SSL_CERT_DIR=/opt/s3sync/certs

sleep 1m

# grab info about the binlog and position of the database

status1=$(mysql -e ‘show master status \G’ | grep mysql)
status2=$(mysql -e ‘show master status \G’ | grep Position)
sql=${status1:18}
posit=${status2:18}

mkdir /mnt/tmp/backup/you-$DAYNOW-$TIMENOW

echo A.$sql >> \
/mnt/tmp/backup/you-$DAYNOW-$TIMENOW/master-$DAYNOW-$TIMENOW.txt
echo B.$posit >> \
/mnt/tmp/backup/you-$DAYNOW-$TIMENOW/master-$DAYNOW-$TIMENOW.txt

# dump database
mysqldump geezeo > \
/mnt/tmp/backup/you-$DAYNOW-$TIMENOW/you-$DAYNOW-$TIMENOW.sql

# tar SQL dump
cd /mnt/tmp/backup

tar -chf – you-$DAYNOW-$TIMENOW | gzip – > you-$DAYNOW-$TIMENOW.tar.gz

rm -r /mnt/tmp/backup/you-$DAYNOW-$TIMENOW/

# copy tar to S3
cd /opt/s3sync
ruby s3sync.rb -vr –ssl /mnt/tmp/backup/ you_db_backups:$DAYNOW

#clean up
rm /mnt/tmp/backup/*.gz*

The key piece here is the capturing of binlog number and position with those two pieces captured it becomes much easier to automate a recovery of the slave from the master’s backup.

More to follow…

Merry iPhonemas and an A.A. Milne High Stepper

Saturday, December 22nd, 2007

Merry iPhonemas

A.A. Milne High Stepper

Things you bring to a fire.

Tuesday, December 18th, 2007

Things you bring to a fire.

  1. Hoses
  2. Ladder
  3. Dildo?

Albums I could not get out off my playlists in 2007.

Monday, December 17th, 2007

2007 Albums

Aesop Rock – None Shall Pass
African Virtuoses – The Classic Guinean Guitar Group
Apparat – Walls
Beruit – The Flying Club Cup
Burial – Untrue
Dalek – Abandoned Language
Fanfare Ciocarlia – Kings and Queens
Glenn Jones – Against Which the Sea Continually Beats
Richard Swift – Dressed Up For The Letdown
Spanish Harlem Orchestra – United We Swing
Stars of the Lid – and Their Refinement of the Decline
Tinariwen – Aman Iman: Water Is Life
Waldeck – Ballroom Stories

Friday’s Four

Friday, December 14th, 2007

Over the shoulder

Cat Nap

Cascade of Hair

Peri Waits