[OpenIndiana-discuss] Amazon EC2 and OpenIndiana
Gary
gdriggs at gmail.com
Wed Nov 10 20:09:11 UTC 2010
Here's a brief document I wrote with the assistance of the previously
referenced PDF -- note that the command used do require having
Amazon's EC2 and ELB management tools installed and in your path.
Also, pfexec may be substituted for sudo, mount locations changed,
different types/sizes of pools, etc. It's just a sample walkthrough...
HOWTO create a ZFS mirror on OpenSolaris with Amazon Elastic Block Store volumes
set up your environment
$ cat ~/.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
EC2_CERT=$HOME/.ec2/cert-FPGAG6000DYMT5SPWUS4CNMGVND3WF7Y.pem
EC2_PRIVATE_KEY=$HOME/.ec2/pk-FPGAG6000DYMT5SPWUS4CNMGVND3WF7Y.pem
PATH=/usr/gnu/bin:/usr/bin:/usr/X11/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/ec2/bin:/opt/ec2/sbin:/opt/elb/bin
MANPATH=/usr/gnu/share/man:/usr/share/man:/usr/X11/share/man
PAGER="/usr/bin/less -ins"
AWS_ELB_HOME=/opt/elb
EC2_HOME=/opt/ec2
JAVA_HOME=/usr/java
export PATH MANPATH PAGER AWS_ELB_HOME EC2_HOME JAVA_HOME EC2_CERT
EC2_PRIVATE_KEY
look at your instances, note their zone
$ ec2-describe-instances
RESERVATION r-7ef60316 164967591565 default
INSTANCE i-86d861ee ami-e56e8f8c
ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com
domU-XXX-XXX-XXX-XXX.compute-1.internal running gd 0
m1.small 2009-10-21T16:47:10+0000 us-east-1a
aki-1783627e ari-9d6889f4 monitoring-enabled
RESERVATION r-eb78b183 164967591565 default
INSTANCE i-7fce5417 ami-e56e8f8c
ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com
ip-XXX-XXX-XXX-XXX.ec2.internal running gd 0
m1.small 2009-11-12T17:37:48+0000 us-east-1d
aki-1783627e ari-9d6889f4 monitoring-enabled
check volume availability, note their zone
$ ec2dvol -H
VolumeId Size SnapshotId AvailabilityZone Status
CreateTime
VOLUME vol-d18c75b8 16 us-east-1d available
2009-11-12T17:39:17+0000
VOLUME vol-19956c70 16 us-east-1a available
2009-11-12T04:16:04+0000
VOLUME vol-d08c75b9 16 us-east-1d available
2009-11-12T17:39:29+0000
VOLUME vol-dc8c75b5 16 us-east-1a available
2009-11-12T17:38:45+0000
create a script to attach volumes for the zone your instance resides in.
$ more attach-vols
#!/usr/bin/bash
# usage: attach-vols instance-id starting-dev number-of-vols
# instance to attach volume
inst=$1
# starting device number
dev=$2
# number of volumes to attach
num=$3
let count=0
# get a list of available volumes
for vol in `ec2-describe-volumes | egrep -i available | egrep -i
us-east-1a | cut -f2`
do
# attach the volume to the next device
echo "ec2-attach-volume -i $inst -d $dev $vol"
ec2-attach-volume -i $inst -d $dev $vol
# increment the device number
let dev=dev+1
let count=count+1
# if specified number have been attached then exit
if (( count == num ))
then
exit 0
fi
done
$ ./attach-vols i-86d861ee 2 3
ec2-attach-volume -i i-86d861ee -d 2 vol-19956c70
ATTACHMENT vol-19956c70 i-86d861ee 2 attaching
2009-11-13T18:54:26+0000
ec2-attach-volume -i i-86d861ee -d 3 vol-dc8c75b5
ATTACHMENT vol-dc8c75b5 i-86d861ee 3 attaching
2009-11-13T18:54:35+0000
$ ec2-describe-volumes | egrep -i attached | cut -f2,3,4,5
vol-19956c70 i-86d861ee 2 attached
vol-dc8c75b5 i-86d861ee 3 attached
find out what devices they've attached as (the first two are local EC2 volumes)
then create a ZFS mirror, check its status and mount
$ sudo format
Password:
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c7d0 <DEFAULT cyl 1274 alt 0 hd 255 sec 63>
/xpvd/xdf at 0
1. c7d1 <DEFAULT cyl 19464 alt 0 hd 255 sec 63>
/xpvd/xdf at 1
2. c7d2 <DEFAULT cyl 2088 alt 0 hd 255 sec 63>
/xpvd/xdf at 2
3. c7d3 <DEFAULT cyl 2088 alt 0 hd 255 sec 63>
/xpvd/xdf at 3
Specify disk (enter its number): ^C
$ sudo zpool create logs mirror c7d2 c7d3
$ sudo zpool status
Password:
pool: logs
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
logs ONLINE 0 0 0
mirror ONLINE 0 0 0
c7d2 ONLINE 0 0 0
c7d3 ONLINE 0 0 0
errors: No known data errors
pool: mnt
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
mnt ONLINE 0 0 0
c7d1p0 ONLINE 0 0 0
errors: No known data errors
pool: rpool
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
c7d0s0 ONLINE 0 0 0
errors: No known data errors
$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
rpool/ROOT/opensolaris
8319892 3728123 4591770 45% /
swap 2093032 276 2092756 1% /etc/svc/volatile
/usr/lib/libc/libc_hwcap3.so.1
8319892 3728123 4591770 45% /lib/libc.so.1
swap 2092792 36 2092756 1% /tmp
swap 2092784 28 2092756 1% /var/run
rpool/export 4591791 21 4591770 1% /export
rpool/export/home 4591789 19 4591770 1% /export/home
rpool 4591848 79 4591770 1% /rpool
mnt 153796557 19 153796538 1% /mnt
logs 16385997 19 16385978 1% /logs
More information about the OpenIndiana-discuss
mailing list