Sailfin in the Amazon EC2 Cloud

Getting Started with SailFin on Amazon EC2

A few SailFin users have inquired about SailFin hosting. I run one out of my garage. It is free but sorry I do not have the additional capacity :-) I had also rented a dedicated server at GoDaddy ($80/mo) to host our demo server. So far it has worked out well and it is quite a reasonable option. There may be other hosting providers there, we do not know about. Do let us know, if you run into anyone.

Sun ISV Engineering guys stepped up to create a rentable ready-to-go Sailfin AMI for Amazon EC2. This is easier to use because it has SailFin and MySQL pre-installed and pre-configured as services. So when the image comes up, you have a running server. All it needs is your service/application. The downside of any cloud image is that everytime you bring it up, it forgets what was configured. So you will have to write some scripts that start up the image and then deploy your application etc. Not a big deal. I will get you started in a moment...

It is always good to know where additional help is, in case you need it. For me, Getting Started document for EC2 & OpenSolaris [1], was all that was needed. I will condense the steps provided there and add some specific details for using SailFin.

  • First, get yourself an account on Amazon EC2, if you have not already done it. EC2 is not free, nor is it super cheap. Be prepared to supply a credit card number for billing. It appears to be reliable. I have not done any performance testing yet.
  • After you sign up you will get a Private Key and a Certificate. You need to save them as separate files with the .pem extension. The location of these two files needs to be set in the environment for the EC2 command line tools to work.
  • The AMI/API command line tools can be downloaded from the following locations:
    After completing the downloads, follow the instructions in the Amazon Getting Started Guide for setting up the tools to make it available or usable. The guide is available from: You will see how to download and configure the EC2 CLI tools in the the early sections of [1].  Here is what I have in my setup:
export EC2_HOME


export EC2_CERT

export EC2_URL

Just how does one fire up an AMI instance?

The AMI  is called: ami-9df312f4. It is SailFin v2, build 20, which has recent bug fixes. This AMI is provisioned with OpenSolaris, SailFin and MySQL all pre-configured.  When you start the AMI, SailFin and MySQL should both have started up as well and ready to use. I suspect when you have your own application on top of it, you will want to automate the deployment of your application also. 

ElasticFox is a very efficient graphical interface for EC2. When beginning, lets use the command line interface, so you get the hang of what is going under the hood. All the commands are in ${EC2_HOME}/bin directory.

  • First, generate a keypair:
ec2-add-keypair mykeypair

This will produce output which you must copy and paste into a file called mykeypair. Save everything between (and including) the "-----BEGIN RSA PRIVATE KEY-----" and "-----END RSA PRIVATE KEY-----" lines. You can generate as many keypairs as you want. You may want to keep one for sailfin usage.

chmod +x mykeypair 

  • Now start up the SailFin 2.0b20 AMI, for example:
ec2-run-instances ami-9df312f4 -k mykeypair
The output should be something like this:

RESERVATION    r-c73171ae    609350199924    default
INSTANCE    i-dfa197b6    ami-9df312f4            pending    mykeypair    0        m1.small    2009-07-09T22:00:03+0000    us-east-1d    aki-6552b60c    ari-6452b60d        monitoring-disabled

  • It does take a while for the instance to fire up. Check status with the instance id reported above:
ec2-describe-instances | grep i-dfa197b6

INSTANCE    i-dfa197b6    ami-9df312f4            pending    mykeypair    0        m1.small    2009-07-09T22:00:03+0000    us-east-1d    aki-6552b60c    ari-6452b60d        monitoring-disabled

Eventually (5 minutes or less) it will enter running state and is usable. You will then see a public DNS address for the active instance:

INSTANCE    i-dfa197b6    ami-9df312f4    ip-10-244-15-112.ec2.internal    running    mykeypair    m1.small    2009-07-09T22:00:03+0000    us-east-1d    aki-6552b60c    ari-6452b60d        monitoring-disabled

You can see the DNS name of the instance in the command output, in this case: Also note the instance identfier, in this case i-dfa197b6.

Opening Ports

The typical SailFin server needs to open some critical ports for traffic and administration. You can authorize ports explicitly. This profile definition is persistent. Here we use the default security profile.

    • ec2-authorize default -p 22 (opens up SSH port. Otherwise, ssh command above would not work)
    • ec2-authorize default -p 8080 (HTTP traffic)
    • ec2-authorize default -p 4848 (Admin Server Port)
    • ec2-authorize default -p 5060 (SIP Traffic).

    • To allow UDP SIP traffic, ec2-authorize default -p 5060 --protocol udp

Explore the running image

To login, you could use the DNS name of the instance in configuring the SIP phones. I used DynDNS service to point a domain to this Amzon instance. The IP address of the instance is encoded in the DNS name. For example,  the external IP Address of is

You can ssh to our instance. Use the DNS name that was reported by ec2-describe-instances (above)

ssh -i mykeypair -l root

Macintosh-202:ec2-api-tools-1.3-36506 Sreeram$ ssh -i mykeypair -l root
The authenticity of host ' (' can't be established.
RSA key fingerprint is 15:3a:03:d1:b9:3e:2d:37:7f:77:41:05:a2:1e:9a:d6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ',' (RSA) to the list of known hosts.
Last login: Thu Jul  9 22:47:48 2009 from sca-ea-fw-1.sun

Sun Microsystems Inc.   SunOS 5.11      snv_101b        November 2008

Welcome to an OpenSolaris on Amazon EC2 instance

Use of this OpenSolaris instance is subject to the license terms found at and in /etc/notices/LICENSE.

Users are advised to protect their MySQL database by following guidelines
mentioned within MySQL 5.1 database documentation

Additional software packages from the OpenSolaris Package Repository are
governed by the licenses provided in the individual software packages which can
be viewed using the package manager graphical user interface.

OpenSolaris 2008.11 AMI contains temporary fix for bug id #6787193 and
For details refer to

For important security information, and image usage instructions please review
the files in /root/ec2sun.

For latest updates and late breaking information, please visit the OpenSolaris
on EC2 blog at

Register at to receive latest
news on OpenSolaris AMIs

For technical questions:
You have new mail.
root@ip-10-244-159-143:~# ls
root@ip-10-244-159-143:~# cd ec2sun
root@ip-10-244-159-143:~/ec2sun# ls
DTrace.README  README  mysql.README  sailfin.README  sysbench.README

Be sure to look at the README files once before you start using the instance. You should see an instance of MySQL and SailFin already running. To check the status you can use:
root@ip-10-244-159-143:~/ec2sun# svcs -a | grep -i mysql
online         22:41:31 svc:/application/mysql:default
root@ip-10-244-159-143:~/ec2sun# svcs -a | grep -i domain1
online         22:42:33 svc:/application/SUNWappserver/domain1:default

You can also point your browser to the administration server: http://<DNS-address>:4848 

For your convenience, as database connection pool and JDBC resource has been configured in SailFin. You can see it by going down to explore JDBC Resources in the Admnin console. Ping the Connection pool named mysql and it should be succesful. Now run your usual asadmin scripts that deploy the service to the SailFin.

Stopping the Instance 

    You can terminate the instance as follows:

    ec2-terminate-instances i-<something>

    Using ElasticFox

    ElasticFox and SailFin

    ElasticFox is a a free FireFox plugin that simplifies dealing with the EC2 cloud. You can search for images, start them up, configure and do most of the management. Download details for ElasticFox are at AWS website. Documentation is great, and you will figure it out quite easily.


    Look into Amazon's elastic block storage - it will give you persistent storage for your AMI so that you don't lose data from instance restarts, etc.

    Posted by Branden Root on July 10, 2009 at 03:10 AM PDT #

    Thanks Branden. Having persistent storage would be a good thing. Can we get at this block storage with any well known Java API like JDBC, JPA or JDO?

    Posted by Sreeram on July 10, 2009 at 04:03 AM PDT #

    Post a Comment:
    Comments are closed for this entry.

    Various things I do at Sun Microsystems.


    « April 2014