How to enable ephemeral storage on Amazon Beanstalk instance.

Amazon's Beanstalk is a great deployment environment for startup like us. Occasionally, we see issue on the beanstalk but lucky beanstalk allow us to use custom AMI for the beanstalk instances.

One of the issue we seen is that beanstalk only comes with 8GB ESB storage. But in fact, each EC2 instance comes with ephemeral(local) storages.(the size varies based on the instance type).

Our goal is to enable these missing ephemeral storage for the tomcat application. To do create a custom AMI with ephemeral storage.

I. Disable Auto Mount


Due to the default setting in CloudInit, it always mounts the first ephemeral drive on /media/ephemeral. To make the mountpoint customizable, we have to disable automount ephemeral0 first.

To do so, you have to launch a new instance with the beanstalk AMI first.
ec2-run-instances ami-b8c539d1 -t m1.large

Log in to the server
Edit /etc/sysconfig/cloudinit, and set CONFIG_MOUNTS=no.
Edit the /etc/fstab

/dev/sdb /var/cache/tomcat6 auto defaults 0 2
  /dev/sdc /tmp auto defaults 0 2
And then delete everything in /var/cache/tomcat6.

rm -rf /var/cache/tomcat6/*

II. Create a Temporary AMI


Log in to http://aws-portal.amazon.com and create a new AMI based on the instance we just used.

III. Create the Cloud Init Script


Open your text editor and create a tomcat.init script on your local machine

#!/bin/sh

chown root:root /var/cache/tomcat6
chmod 755 /var/cache/tomcat6
chmod 1777 /tmp

if [ ! -d  /var/cache/tomcat6/temp ]
then 
  mkdir /var/cache/tomcat6/temp
  chmod 775 /var/cache/tomcat6/temp
  chown tomcat:root /var/cache/tomcat6/temp
fi
if [ ! -d  /var/cache/tomcat6/work ]
then 
  mkdir /var/cache/tomcat6/work
  chmod 775 /var/cache/tomcat6/work
  chown tomcat:root /var/cache/tomcat6/work
fi

IV. Create a New Instance with Ephemeral Storage

ec2-run-instances ami-xxxxxxx --user-data-file tomcat.init -b /dev/sdb=ephemeral0 -b /dev/sdc=ephemeral1 -t m1.large 

V. Create Beanstalk AMI



Log in to http://aws-portal.amazon.com and create a new AMI based on the instance we just initiated. This AMI is the AMI you can use in your beanstalk environment.

Why google.map don't work well in Taiwan

This is part of my posting on telnet://ptt.cc

Google街景不準,跟台灣門牌號碼制度的落後比較有關。

先說美國的門牌號碼作法,以紐約市為例 http://tinyurl.com/44arddr

直的是 Ave(大道),橫的是St(街),門牌號碼的排法是每一個路口就是重新算 100號做起始。所以算 3712 號,就是在該路第三十七跟三十八個路口間,用內差法來做排列。若是一個大樓占據了整個區間,下一個路口仍是從 xx00 開始排

至於台灣的排法,則是從路口來數大樓數,要是碰上一個大樓佔了整個區塊,下一個建物還是的門牌還是 N+1

http://tinyurl.com/4yhjwz7
所以就碰上了從市貿到NY Bagles 這邊,整排都是大型大樓,就只有幾個門牌號碼。在這一區,Google就吃鱉吃的很慘,我有次要去鴻喜花園的店,Google.Map給我的地址跑到三百公尺外的牡丹園去。

美國的門牌號碼編法,讓Google.Map等要存的資料較少,要定位時用內插法來估,也不會歪太遠;台灣的門牌編法,除了一個一個點的去存資料,不然變成沒有辦法精確的定位。

ps: 台灣門牌,原地改建時會變得更好玩,一棟變三棟就變 -1 -2 -3 ,我上禮拜有碰過 -47 的 Orz..