Use EBS on EC2 Centos 5.2 and snapshot with cron to S3
Posted by Edmund Haselwanter on Friday, March 06, 2009
Create the volume and assign it to your instance
Attach it to your Centos 5.2 instance
yum install xfsprogs
according to Thread: Debian Lenny and XFS causes kernel panic: Suggested Workaround
mkfs.xfs -l version=1 /dev/sdh
insert into /etc/fstab
/dev/sdh /vol/shared xfs noatime 0 0
mount the volume
mount /vol/shared
Setup ec2-extra-tools
copy over your EC2_CERT and EC2_PRIVATE_KEY
setup /etc/profile.d/ec2.sh
1 2 export EC2_HOME=/home/ec2 3 export EC2_CERT=/root/.ec2/cert-xxx.pem 4 export EC2_PRIVATE_KEY=/root/.ec2/pk-xxx.pem 5 export AWS_ACCOUNT_NUMBER= 6 export AWS_ACCESS_KEY_ID= 7 export AWS_SECRET_ACCESS_KEY= 8 export PATH=$PATH:/home/ec2/bin/
install
http://github.com/cmer/ec2-extra-tools/tree/master
add the binaries to e.g. /home/ec2/bin/
test the setup with:
ec2-xfs-snapshot /dev/sdh
sample output:
1
2 [root@domU-XX-XX-XX-XX-XX-XX:~/] ec2-xfs-snapshot /dev/sdh
3 device: /dev/sdh
4 mount point: /vol/shared
5 ec2-volume-id: vol-67890a
6
7 Freezing XFS volume…
8
9 Creating snapshot…
10 SNAPSHOT snap-b99bh1d8 vol-67890a pending 2009-03-06T14:56:17+0000
11 Unfreezing XFS volume…
12
13 Done!
Setup cron
crontab -e
SHELL=/bin/bash
PATH=/usr/bin:/bin:/usr/sbin
5 20 * * * source /etc/profile.d/java.sh; source /etc/profile.d/ec2.sh ; \
ec2-xfs-snapshot /dev/sdh >> /var/log/ebs_snapshots 2>> /var/log/ebs_snapshots
you need both: java.sh and ec2.sh for the amazon tools.