OpenStreetMap

Switch2OSM.org Serving Tiles - Updating your database as people edit

Posted by SomeoneElse on 26 July 2022 in English. Last updated on 27 July 2022.

Munin

Since the release of Ubuntu 22.04 LTS, it’s now much easier to keep a tile-serving database updated. This version of Ubuntu ships with much more recent versions of osm2pgsql and osmium, so it’s easier to set up updates using those.

First things first, the new “setting up a rendering server” instructions for Ubuntu 22.04 are here. These are much shorter than they used to be because most of the software setup is done automatically as it is installed.

osm2pgsql-replication

The first option is to use osm2pgsql-replication. The manual page for this is here. The switch2osm page walks you through initialising replication, and creating scripts to apply updates and mark tiles as “dirty”, so that they will get rerendered as required when the underlying data has changed. Download sites such as Geofabrik and download.openstreetmap.fr provide extracts and replication feeds for those extracts - for example, you can load data for Europe, and then apply updates only for Europe - your database will not grow with other updates from all around the world.

PyOsmium

Another option, slightly more flexible, is to use Pyosmium. The documentation for this is here. Again, the switch2osm page walks you through initialising replication, and creating scripts to apply updates and mark tiles as “dirty”, so that they will get rerendered as required when the underlying data has changed. Example scripts are provided that use Zverik’s trim_osm.py script to cut-down replication update files to the area that you’re interested in.

A script to measure that measures the current replication lag and a script to call that from munin are also included.

Alternatives

Osmosis

Using osmosis should still work with Ubuntu 22.04, but comes with rather more dependencies.

Using osm2pgsql-replication or Pyosmium in earlier releases

This should also be posible if you build from source.

Location: Crossmoyle, Clones Urban ED, Ballybay-Clones Municipal District, County Monaghan, Ulster, Ireland

Discussion

Log in to leave a comment