Log in

HCMC Journal

Building a tile-rendering server, attempt #2

: Martin Holmes

Note: this post covers several days, and I expect to keep updating it as we learn more.

I’m attempting to replicate, with documentation, Greg’s building of an OSM tile-rendering machine, starting from instructions here:


but using 16.04 beta 2. I first built a VM from Ubuntu 16.04 server beta2, with 16GB RAM and 200GB of disk space, adding only the install of ssh-server at install time, and selecting the non-LVM full-disk option. These are deviations that I had to deal with:

In the first set of software installs:

libtiff4-dev needs to be changed to libtiff5-dev

Then I did followed the instructions for installing and configuring postgres although the package version was different (do apt-cache search to find the current one). When I got to osm2pgsql, I just did

sudo apt-get install osm2pgsql

and then for mapnik:

sudo apt-get install libmapnik-dev libmapnik3.0 mapnik-utils mapnik-vector-tile openstreetmap-carto python-mapnik python3-mapnik

At some point, the node-carto package got installed; that’s a good thing, but I don’t know how it happened.

Next, I had chosen to use openstreetmap-carto instead of OSMBright, so I didn’t need to do that bit.

The next stumbling block was that when you edit the renderd.conf file, the paths proposed are not correct, because things are in different places due to installing from the repos rather than building locally. You want this:


When you come to tuning postgres, only three of the four settings can be found. Don’t add the missing setting, just set the others:

shared_buffers = 128MB
maintenance_work_mem = 256MB
autovacuum = off

I got the north-america-latest.osm.pbf, and you have to remember to chown its containing folder and itself to the user you created for tile-building. Then you su to that user and run the import command. That took 25 hours.

Starting renderd worked, and I was able to view specific tiles through Apache, after getting the paths of those tiles from GN; there’s no default interface that allows you to browse tiles (there used to be, apparently).

The next stage is getting renderd to start automatically; the original instructions predate systemd, so that’s potentially problematic. We’ve shelved that for the moment.

The next stage is to download the generate_tiles.py file from GitHub:

As the maptiler user, in the maptiler user’s home directory:

curl https://raw.githubusercontent.com/openstreetmap/mapnik-stylesheets/master/generate_tiles.py > generate_tiles.py
chmod u+x generate_tiles.py

Then you need to edit generate_tiles.py. You can comment out all the German cities at the end, but use one of them as a model for your own bounding box and render instruction. Create the bounding box (bottom-left, top-right) using this:


To avoid rendering the whole world in too much detail, change this line:

render_tiles(bbox, mapfile, tile_dir, 0, 5, "World")

to this:

render_tiles(bbox, mapfile, tile_dir, 0, 2, "World")

You’ll also need to change the path to the stylesheet:

mapfile = "/usr/share/openstreetmap-carto/style.xml"

Now when you try to run the script, you’ll get this error:

RuntimeError: Failed to find font face 'Arundina Sans Italic' in FontSet 'fontset-0' in FontSet at line 17 of '/usr/share/openstreetmap-carto/style.xml'

So fonts required by the stylesheet are missing. These are my attempts to resolve that problem:

The Arundina fonts package is already installed by default, so that’s a puzzle. I tried this:

sudo apt-get install latex-fonts-sipa-arundina

That put some fonts there, but they have the wrong names by default. So in this file:


replace Arundina Sans Italic with Arundina Italic.

Next is a missing Tamil font, Paranar:

sudo apt-get install fonts-taml-tscu

and so on for a range of other fonts:

sudo apt-get install fonts-knda fonts-droid-fallback fonts-noto fonts-sil-padauk fonts-indic fonts-tibetan-machine

However, there are still some fonts which are not available, but are references in the style.xml file. For the remainder, where I was able to find a good analogue or close option, I substituted it; otherwise, I commented out the line in the file which referenced it.

For finding out which font names python knows about, this helps:

from mapnik import *
for face in FontEngine.face_names():
  print face