Yearly Archives: 2010

Another Fabric Tutorial

I’ve been playing with  Python here and at the same time Fabric v.0.9 for simple deployment. This is a handy tool to manage several servers for application development,testing and production.

The code below is save to a file named fabfile.py

# Works with fabric v0.9
#
from fabric.api import run, env
from fabric.operations import local,put

def dev_server():
env.user = 'user_name'
env.hosts = ['testserver.domain.com']

def staging_server():
env.user = 'user_name'
env.hosts = ['staging.domain.com']

def production_server():
env.user = 'user_name'
env.hosts = [' prod1.domain.com', 'prod2.domain.com' ]

# define needed functions here.
def host_info():
print 'Checking lsb_release of host: ',  env.host
run('lsb_release -a')

def uptime():
run('uptime')

def simple_deploy():
put ('/tmp/testfile','/tmp')
#
# add deployment codes here

This assumes we can login to any of the server w/o ssh keypair.
See this link for setting up SSH without password.

Tip: Also if you have different keypair for each servers(dev,staging,production), you can add keypair using the command ssh-add. Continue reading

MySQL on RAID0 and useful MySQL tools

Maintaining a production DB containing 15-25M rows show best improvement with the use of RAID0 on EC2 platform. Having a MySQL master-slave replication of servers and keeping the documented procedure is very handy for restoring the DB and the RAID volumes.

Documenting the process on downgrading and upgrading RAID0+MySQL from large to xlarge EC2 instance or vice versa helps a lot.

The links below best describes the RAID0 performance for IO operations on EC2 and how to setup the EBS RAID0 and MySQL in your machine.

RAID0 Refrences
IO Performance on EBS
EC2 EBS SINGLE AND-RAID VOLUMES IO BENCHMARK
EC2 EBS RAID
mdadm: A New Tool For Linux Software RAID Management
Running MySQL on Amazon EC2 with Elastic Block Store

MySQL Tools
EC2 Consistent Snapshot
Using Maatkit to restore Slave-Master
Maatkit.Org
MySQL Sandbox
Auto MySQL Backup