Montag, 9. Juli 2012

Setting up Mapnik Cloud Server (Ubuntu 11.10 on Amazon EC2)

Rendering with mapnik is very CPU intensive, my PC needs about 500 hours to make a complete rendering of the alps from zoom level 1 to 15. This is frustrating.
It doesn't make sense to buy a powerful server either, because you don't want to render the map every day. This is a great use case for using the cloud.
A cloud server is a bare server with a standard OS installation only. And a server looses all data and configuration when you shut it down. (At least when you don't want to pay for a server which is not running. And this is the core idea of cloud computing)
Therefore it is necessary to have a setup script to fully enable the server for the intended function after the boot process. In case of mapnik, this script needs to install libraries prerequisites for mapnik, compile and install mapnik and put all configurations in place.
I don't want to place the PostGIS Database onto the cloud server. This server is supposed to be a stateless computation unit. The data must be located somewhere else. I will describe my complete setup in another post.

Here is the setup script. It is derived from the description on switch2osm. But I had to modify the libraries and added the mapnik configuration setup.

(
# INSTALL LIBRARIES
sudo apt-get update
sudo apt-get -y install git-core libltdl-dev libpng-dev libicu-dev libboost-python-dev python-cairo-dev python-nose libboost-dev libboost-filesystem-dev libboost-iostreams-dev libboost-regex-dev libboost-thread-dev libboost-program-options-dev libboost-python-dev libfreetype6-dev libcairo2-dev libcairomm-1.0-dev libgeotiff-dev libtiff4 libtiff4-dev libtiffxx0c2 libsigc++-dev libsigc++0c2 libsigx-2.0 libsigx-2.0-dev libgdal1-dev python-gdal imagemagick ttf-dejavu libxml2-dev subversion
# INSTALL MAPNIK
sudo mkdir /opt/mapnik
sudo chown ubuntu.users /opt/mapnik
cd /opt/mapnik
git clone git://github.com/mapnik/mapnik
cd mapnik
git branch 0.7 origin/0.7.x
git checkout 0.7
python scons/scons.py configure INPUT_PLUGINS=all OPTIMIZATION=3 SYSTEM_FONTS=/usr/share/fonts/truetype/
python scons/scons.py
sudo python scons/scons.py install
sudo /sbin/ldconfig
# GET MAPNIK STYLE
svn co -r 27279 http://svn.openstreetmap.org/applications/rendering/mapnik mapnikstyle
# GET SHADING IMAGES WHICH HAVE ALREADY BEEN RENDERED
mkdir mapnikstyle/shades
cd mapnikstyle/shades
wget http://{my_server}/hillshades.tar.gz
tar -xvzf hillshades.tar.gz
# GET CONFIGURATION FOR MAPNIK
cd ..
wget http://{my_server}/osm.xml
wget http://{my_server}/datasource-settings.xml.inc
mv datasource-settings.xml.inc inc
wget http://{my_server}/settings.xml.inc
mv settings.xml.inc inc
wget http://{my_server}/fontset-settings.xml.inc
mv fontset-settings.xml.inc inc
) >> /var/log/mapniksetup.log 2>&1

Keine Kommentare:

Kommentar veröffentlichen