Serving up geospatial data from the Ec2 cloudPosted: June 30, 2011
Ec2 Free Tier
Recently I’ve been building a Debian Squeeze image on Amazon’s ec2 cloud for free (http://aws.amazon.com/free/). The purpose (aside from messing around) is to develop a nice POC (proof of concept) platform on which to stage geospatial web services (viewing, analysis, hosting, etc). Theoretically, whatever I build can be extended and expanded in terms of power and space so time well spent.
Ec2 has come a ways since I first started playing with it a few years ago. Aside from offering a dizzying array of services, the AWS management portal has become full featured and very useful. Needless to say I didn’t bother to install the ec2 API this time around. The goal here is to get up and running, plenty of time to automate the client end of this down the road.
Getting up and running was pretty straightforward. Sign up for an account, navigate to the ‘quickstart’ guide buried in ‘Documentation’, alter the instructions slightly (I prefer to use a Debian image rather than the guide’s default image), and log in. The only issue I ran into was permissions on my machine when using the public key to access the remote server (
ssh -i key.pem <server>). Without knowing it my public key was not being read by ssh, so the server was asking me for a password (which nobody has) and I was fairly confused. The solution:
sudo ssh -i key.pem <server>
I’m not exactly sure why this works (
'vim key.pem' reads the file). Maybe its a Mac thing.
Installing your software
Now that we’re logged in, we can begin installing and customizing our image (best practice is to create a user and sudo your way to glory). We’re going to use GeoServer to serve up our GIS data, so we’ll need Java. Depending on your linux distro you’ll have access to different packaging tools. I’m a big fan of apt (Debian, Ubuntu, etc.):
apt-get install sun-java6-sdk
If you have a permissions problem ‘sudo’ before the previous code. Now that we have Java up and running, let’s get GeoServer (http://geoserver.org/display/GEOS/Welcome) up. Grab the universal binary from the downloads section:
This will plop it in whatever directory you ran the command from. Geoserver is self contained in this form. Unzip it:
apt-get install unzip
Move into the directory and check out the README. Long story short, you need to go into bin/ and run the startup script. before you do so you’ll have to deal with JAVA_HOME. The quick and dirty way:
Best to stick that somewhere that runs on startup, but that’s out of the scope of this article. Also note the path to Java above works on Debian Squeeze with Sun’s JDK. If you deviated from the instructions you’ll have to find it yourself.
Ok! Assuming all went well navigate your way into geoserver_plus_version/bin and:
You should see GeoServer setting itself up. Head back to the AWS management console and navigate to ‘Security Groups’, ‘your group name’ (could be ‘default’) and edit your security rules so that all ips can access port 8080 (0.0.0.0/0). Make sure to click the ‘Apply Rule Changes’ button or your changes will not take effect. Type into your web browser:
Where <server> is the address you used to connect to the server via ssh. If all went well you should see GeoServer’s default startup screen! Impress your friends by going to ‘layer preview’ and clicking on an ‘OpenLayers’ link and pasting the ridiculously long URL into Skype or gChat!
That’s really up to you. I installed PostgreSQL 9 and PostGIS for GeoServer. For me this is a sandbox / development machine I will use to show friends what I’m up to. There’s no reason why a dynamic DNS server script couldn’t be installed and a web presence maintained (although there are some security issues to work out prior). A final tip:
The default EBS storage space is 1 Gig. I was able to get GeoServer up and running without issue. However once I started installing PostgreSQL I ran out of space rather quickly. To increase your space use the AWS management console and navigate to ‘EBS Volumes’. Take a snapshot of your volume (while the instance is running) and use it to make a new EBS volume (free tier will allow 10 Gig). Stop (don’t terminate) your instance, detach the 1 Gig volume and attack the 10 Gig volume to ‘sda1’. Startup the instance, log in, and enter the command:
This assumes your device is name ‘xvda1’. You can check with:
Essentially you are telling the operating system to check the size of the hard drive, as it has changed.