Amazon EC2 finally support static IP addresses
April 2nd, 2008
To enable the static IP addresses function , you need to download the latest Amazon EC2 Command-Line Tools, the download link of it is http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&categoryID=88
after download, I recommend to unzip it to a folder call ec2 under your home path
1 2 3 |
mkdir ~/ec2 cd ~/ec2 unzip ec2-api-tools.zip |
you can now see a folder call ec2-api-tools-1.3-19403 under the ec2 folder.
now it is time to update the .profile , so that EC2 tool can find the library that it use.
you have to download the private and public cert from amazon
1 2 3 4 5 |
nano ~/.profile export PATH=~/ec2/ec2-api-tools-1.3-19403/bin:$PATH export EC2_HOME=~/ec2/ec2-api-tools-1.3-19403 export EC2_CERT=~/.ec2/cert-xxxxxxxxx.pem export EC2_PRIVATE_KEY=~/.ec2/pk-yyyyyy.pem |
then you can start a new console so that the profile update will be effective.
you can now allocate a new IP address for your account.
1 2 |
Chris:~ chrischan$ ec2-allocate-address ADDRESS 75.101.139.212 |
This new IP 75.101.140.212 is not bundle to any AMI instance yet.
You have to manually assign this IP address to a instance
First, you need to know the instance that you have already started. you can use the following command
1 2 3 4 5 |
Chris:~ chrischan$ ec2-describe-instances RESERVATION r-3c1bea55 073126868754 default INSTANCE i-7124dd30 ami-5035d079 ec2-67-202-34-115.compute-1.amazonaws.com domU-12-31-38-00-6D-98.compute-1.internal running 0m1.small 2008-03-05T15:51:36+0000 us-east-1a |
you can see that the instance id is i-7124dd30, we can then assign the IP to that instance
1 2 |
Chris:~ chrischan$ ec2-associate-address 75.101.140.212 -i i-7124dd30 ADDRESS 75.101.140.212 i-7124dd30 |
If you want to check the address allocation status, you can use the follow command
1 2 |
Chris:~ chrischan$ ec2-describe-addresses ADDRESS 75.101.140.212 i-7124dd30 |
for any time if you want to free the IP , you can use
ec2-release-address IP-address |
If you want to assign the existing IP address to a new instance , you can use ec2-associate-address, but this time , you assign the new instance IP, and the existing IP address bundling will remove, so the single IP address will always only bundle to one instance.
Also, a instance can only have one IP address assocate to it , so when you assign a new IP address to a instance, all the existing IP bundling will be removed. And all the IP address in this status will start to charge you account. So whenever any IP allocate has finished , please make to use ec2-describe-addresses to check the IP address bundling status.
Ankoder Architecture presentation
March 26th, 2008
In March, we had a ruby on rails user group meetup in Hangzhou, China. It was exciting to meet more rails developers in China and shares some experience on our projects. Hangzhou is famous for it’s West Lake, it is just 1.5 hrs south of Shanghai. It is turning into the Silicon Valley of China, because several large internet companies are based in Hangzhou, such as Alibaba. They are also experimenting with Rails, because of its amazing productivity gains.
We did a presentation on our architecture and how we host a fault tolerant system on Amazon’s EC2. We will already need to change this a little since Amazon has just released the long been waited feature Static IP. Now you don’t need to rely on DNS to failover to your new server, you can at least start a new instance and point your IP to the new host.
Ankoder API ruby library released
February 25th, 2008
Do you need to build a mini youtube for your client?
Do you want to include video functionalities to your site?
We’ve released the ruby library that we are already using on http://free.ankoder.com both in rails plugin form as well as ruby gem form.
Install it and have a look at the rdoc
Rails Plugin
script/plugin install http://ankoder.googlecode.com/svn/trunk/trunk/ankoder_on_rails |
Ruby Gem
http://rubyforge.org/projects/ankoder/
1 2 3 4 5 6 |
$ sudo gem install ankoder Password: Bulk updating Gem source index for: http://gems.rubyforge.org Successfully installed ankoder-0.0.2- Installing ri documentation for ankoder-0.0.2-... Installing RDoc documentation for ankoder-0.0.2-... |
Send us an email if you’re keen to try it.
We’re working on our payment model and cleaning up the UI so you can manage your services.
mpeg4aac for ffmpeg problem
January 15th, 2008
Error Message:
library: cannot resolve faacDecGetErrorMessage in libfaad.so.0!
Solution:
First you should comfirm that libfaad.so.0 library is located in the path which are defined by the LD_LIBRARY_PATH environment variable. Otherwise, you can use
export LD_LIBRARY_PATH=/home/ffmpeg/usr/local/lib
to add the libfaad.so.0 to the LD_LIBRARY_PATH. (in this case, libfaad.so.0 is in the /home/ffmpeg/usr/local/lib ).
Second, Modify libavcodec/libfaad.c in ffmpeg source code
change line:
do { static const char* n = "faacDec" #a; \
To:
do { static const char* n = "NeAACDec" #a; \
change line:
#define dfaac(a, b) s->faacDec ## a = faacDec ## a
To:
#define dfaac(a, b) s->faacDec ## a = NeAACDec ## a
Re-compile ffmpeg.
Step by step guide to preparing EC2 on MacOSX
January 8th, 2008
Amazon provides two types of tool.
1. Operational tools that use to startup and shutdown AMI instances
2. Packaging tool to pack the AMI that created , or modify on existing public AMI and rebundle to new private AMI
Operational tool
Create a new AWS Access Identifiers if you don't already have.
$ mkdir ~/.ec2
download both the Private Key file and X.509 Certificate file to ~/.ec2
rename the pk-xxxxxxxxxx.pem one to PrivateKey.pem
rename the cert-xxxxxxxxx.pem one to 509certificate.pem
( xxxxxxxxxx stand for the random name generate by amazon )
visit the following to download the packaged file to Download folder
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&categoryID=88
$ mkdir ~/ec2
$ cp ~/Downloads/ec2-api-tools.zip ~/ec2/
$ cd ~/ec2/
$ unzip ec2-api-tools.zip
$ nano ~/.profile
append the follow line to the end
export JAVA_HOME=/Library/Java/Home
export PATH=~/ec2/ec2-api-tools-1.2-13740/bin:$PATH
export EC2_HOME=~/ec2/ec2-api-tools-1.2-13740
export EC2_PRIVATE_KEY=~/.ec2/PrivateKey.pem
export EC2_CERT=~/.ec2/509certificate.pem
restart the terminal to active the changes on bash profile
$ ec2-describe-images -o amazon
IMAGE ami-20b65349 ec2-public-images/fedora-core4-base.manifest.xml amazon available public
IMAGE ami-22b6534b ec2-public-images/fedora-core4-mysql.manifest.xml amazon available public
IMAGE ami-23b6534a ec2-public-images/fedora-core4-apache.manifest.xml amazon available public
IMAGE ami-25b6534c ec2-public-images/fedora-core4-apache-mysql.manifest.xml amazon available public
IMAGE ami-26b6534f ec2-public-images/developer-image.manifest.xml amazon available public
IMAGE ami-2bb65342 ec2-public-images/getting-started.manifest.xml amazon available public
IMAGE ami-36ff1a5f ec2-public-images/fedora-core6-base-x86_64.manifest.xml amazon available public
IMAGE ami-bd9d78d4 ec2-public-images/demo-paid-AMI.manifest.xml amazon available public A79EC0DB
If install sucessfully , will show the list of the AMI that amazon provide
$ ec2-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BSGoFW5EF5Ai7i56RLGDqXHNXd8WnduhflFc2l
jtzifP1DFDsyR+dYbblT7b5DW2WntXTVsAk3Xn+oGcriL2qFvbGmce9H1fVnPaOKsZsMl3g86dEC
gYEAvQWGFlKFHGEB+mc3MPK3y0Q5oNC6sb2d+S5lGwS/jGYAbkbwtI0Myf2ouIm+wV2KIW0A04x1
shDO4cKwOeJKxeWXxEjU2DxRmWIB4FXTwgMOCVM/wkyshlW3mcn58iLrZELn9qXreZW5V75zwpbl
WPjaU1/YSUS1gFxAZO/rzAsCgYA3/w+OBSQqmzxlF/VE76ZPVWfknqH8iEoRg7wgPPBK3txfEeqA
AV5ph5A4lipBt0QpyIwJNJwIaId23s9tZSgSYq69jVsQG2USEMCCwTlMYczZ5IOtaLh2ck0E/y3W
oct2+DXf6gbDjEXlxN3YzU02/XStGUhF3/kCiBqF1vlT4QKBgFtaVjtc1VO/t0+vQ8CmTn4Y03Ml
pCORn4081m1w5PhfEbei+qzAY66r8AkB1Du9CT/NhrGXMsTTrsTiaApjoJ2HMUW3Pr/m6x/QIpTf
/4cFSHaDKnb5plNB3+DwPjjtDx/37PC6XAVTOPxaANr/lEkkST0vub+MkkQ/RxShLxKg
-----END RSA PRIVATE KEY-----
copy the above text including -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- to ~/.ssh/id_rsa-demo-keypair
$ nano ~/.ssh/id_rsa-demo-keypair
paste all the content to it and save
$ ec2-run-instances ami-25b6534c -k demo-keypair
RESERVATION r-b7fc17de 119012238391 default
INSTANCE i-6ea05007 ami-25b6534c pending ankoder 0 m1.small
2008-01-07T05:49:15+0000
if the terminal return the message similar to this , you have successfully started a AMI instance.
To show all the instances currently running can use the ec2-describe-instances command
$ ec2-describe-instances
INSTANCE i-6ea05007 ami-25b6534c ec2-67-202-24-116.compute-1.amazonaws.com
domU-12-31-38-00-29-48.compute-1.internal running ankoder m1.small
2008-01-07T05:49:15+0000
To shutdown a running instance, can first find the instance id by using `ec2-describe-instances` , the one that in format of i-xxxxxxxx is the instance id
$ ec2-terminate-instances i-6ea05007
INSTANCE i-6ea05007 running shutting-down
Allow the instance to be accessable from outside
$ ec2-authorize default -p 22
PERMISSION default ALLOWS tcp 22 22 FROM CIDR 0.0.0.0/0
$ ec2-authorize default -p 80
PERMISSION default ALLOWS tcp 80 80 FROM CIDR 0.0.0.0/0
$ ec2-authorize default -p 21
PERMISSION default ALLOWS tcp 80 21 FROM CIDR 0.0.0.0/0
To connect to the AMI instance from SSH
first check the hostname
$ ec2-describe-instances
INSTANCE i-55a0503c ami-25b6534c ec2-67-202-2-199.compute-1.amazonaws.com
domU-12-31-38-00-42-55.compute-1.internal running ankoder m1.small
2008-01-07T06:02:38+0000
using the private key that you generated to login
$ ssh root@ec2-67-202-2-199.compute-1.amazonaws.com -i ~/.ssh/id_rsa-demo-keypair
you can do whatever you like in this instance
install ec2onrails support tool
$ sudo gem install ec2onrails
As the Amazon EC2 tool is in rpm format, and MacOSX doesn't come with it.
so we have to use DarwinPorts to install rpm first
Install the rpm
$ sudo port install rpm
Install Amazon packaging tool
$ wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm
$ sudo rpm -i ec2-ami-tools.noarch.rpm --nodeps --ignoreos
Also, there is a gem for access the EC2 from ruby
$ sudo gem install amazon-ec2 --include-dependencies

