Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
OpenTopoMap/mapnik/HOWTO_Ubuntu_16.04
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
208 lines (143 sloc)
6.69 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ############################################### | |
| # OpenTopoMap | |
| # (c) 2012-2018 Stefan Erhardt | |
| # https://github.com/der-stefan/OpenTopoMap | |
| # | |
| # opentopomap.org | |
| # | |
| ############################################### | |
| HOWTO install OpenTopoMap on Ubuntu (verified on 16.04 LTS) | |
| =========================================================== | |
| This guide is quite complete, but you should always think about before blindly copying the commands. | |
| # Recommendation for file systems: | |
| # /mnt/database on SSD | |
| # /mnt/tiles on HDD | |
| # Update your freshly installed Ubuntu 16.04: | |
| sudo apt update && sudo apt upgrade | |
| # Install some useful packages: | |
| sudo apt install vim git screen htop iftop | |
| # Install the apache web server: | |
| sudo apt install apache2 | |
| # Install Postgresql database: | |
| sudo apt install postgresql-9.5 postgresql-9.5-postgis-2.2 | |
| # change default path via symlink (works better than changing postgres config): | |
| sudo chown postgres /mnt/database | |
| sudo chgrp postgres /mnt/database | |
| sudo service postgresql stop | |
| sudo cp -a /var/lib/postgresql/9.5/main /mnt/database | |
| sudo rm -r /var/lib/postgresql/9.5 | |
| sudo ln -s /mnt/database /var/lib/postgresql/9.5 | |
| sudo service postgresql start | |
| # Tweaks: | |
| Edit the file /etc/postgresql/9.5/main/postgresql.conf and make the following changes: | |
| shared_buffers = 128MB | |
| work_mem = 256MB | |
| maintenance_work_mem = 256MB | |
| autovacuum = off | |
| As root, edit /etc/sysctl.conf and add these lines near the top after the other “kernel” definitions: | |
| # Increase kernel shared memory segments - needed for large databases | |
| kernel.shmmax=268435456 | |
| # Install Mapnik renderer: | |
| sudo apt install libmapnik3.0 libmapnik-dev mapnik-utils python-mapnik unifont | |
| # Install tirex from source | |
| sudo apt install devscripts libjson-perl libipc-sharelite-perl libgd-perl debhelper | |
| mkdir ~/src && cd ~/src | |
| git clone https://github.com/geofabrik/tirex | |
| cd tirex | |
| make deb | |
| cd ~/src | |
| sudo dpkg -i tirex-core_0.5.2_amd64.deb | |
| sudo dpkg -i tirex-backend-mapnik_0.5.2_amd64.deb | |
| # Install mod_tile from source | |
| sudo apt install autoconf apache2-dev | |
| cd ~/src | |
| git clone git://github.com/openstreetmap/mod_tile.git | |
| cd mod_tile | |
| echo '/etc/renderd.conf' > debian/renderd.conffiles | |
| debuild -i -b -us -uc | |
| cd ~/src | |
| sudo dpkg -i libapache2-mod-tile_0.4-12~precise2_amd64.deb | |
| sudo a2enmod tile | |
| # copy conf/tile.conf into /etc/apache2/mods-available/tile.conf | |
| # in /etc/tirex/renderer/mapnik.conf: | |
| # plugindir=/usr/lib/mapnik/3.0/input | |
| # fontdir=/usr/share/fonts/truetype | |
| # fontdir_recurse=1 | |
| # in /etc/apache2/sites-available/tileserver_site.conf change: | |
| # comment out "LoadTileConfigFile /etc/renderd.conf" | |
| # change "ModTileRenderdSocketName /var/lib/tirex/modtile.sock" | |
| sudo rm -rf /var/lib/mod_tile | |
| sudo ln -s /var/lib/tirex/tiles /var/lib/mod_tile | |
| # fix "error" of mod-tile installation (in fact there is no error, apache just can't load the default configs): | |
| sudo apt install -f | |
| # Tweak Apache for huge tile delivery speed-up | |
| # edit /etc/apache2/mods-available/mpm_prefork.conf: | |
| <IfModule mpm_prefork_module> | |
| ServerLimit 5000 | |
| StartServers 500 | |
| MinSpareServers 20 | |
| MaxSpareServers 5000 | |
| MaxRequestWorkers 5000 | |
| MaxConnectionsPerChild 1000 | |
| </IfModule> | |
| a2dismod mpm_event | |
| a2enmod mpm_prefork | |
| # Install osm2pgsql from source | |
| sudo apt install cmake libbz2-dev libgeos-dev libgeos++-dev libproj-dev lua5.3 liblua5.3-dev | |
| cd ~/src | |
| git clone git://github.com/openstreetmap/osm2pgsql.git | |
| cd osm2pgsql | |
| mkdir build && cd build | |
| cmake .. | |
| make | |
| sudo make install | |
| # Create user and database | |
| sudo -u postgres -i | |
| createuser --createdb osmuser // superuser!? | |
| createuser tirex // read only!? | |
| exit | |
| createdb gis | |
| psql -d gis -c 'CREATE EXTENSION postgis;' | |
| # Download OpenTopoMap files | |
| cd ~ | |
| git clone https://github.com/der-stefan/OpenTopoMap.git | |
| cd ~/OpenTopoMap/mapnik | |
| # get the generalized water polygons from http://openstreetmapdata.com/ | |
| mkdir data && cd data | |
| wget http://data.openstreetmapdata.com/water-polygons-generalized-3857.zip | |
| wget http://data.openstreetmapdata.com/water-polygons-split-3857.zip | |
| unzip water-polygons* | |
| # Now you need to create the hillshade and contours. We can't provide the data, since it consumes ~500 GB. | |
| # But there is a long howto in HOWTO_DEM | |
| # Load data into database | |
| mkdir ~/data && cd ~/data | |
| wget http://download.geofabrik.de/europe-latest.osm.pbf | |
| cd ~/data/updates | |
| wget http://download.geofabrik.de/europe-updates/state.txt | |
| screen osm2pgsql --slim -d gis -C 12000 --number-processes 10 --flat-nodes /mnt/database/flat-nodes/gis-flat-nodes.bin --style ~/OpenTopoMap/mapnik/osm2pgsql/opentopomap.style ~/data/planet-latest.osm.pbf | |
| screen osm2pgsql --slim -d gis -C 12000 --tablespace-slim-data hdd --tablespace-slim-index hdd --number-processes 10 --flat-nodes /mnt/database/flat-nodes/gis-flat-nodes.bin --style ~/OpenTopoMap/mapnik/osm2pgsql/opentopomap.style ~/data/planet-latest.osm.pbf | |
| # Now do the preprocessing of the OSM data for low zoom levels | |
| # A complete copy-paste guide is HOWTO_Preprocessing | |
| # Find out the sizes of the databases: | |
| psql -d gis -c "SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database;" | |
| # Optional: Install awstats, munin and letsencrypt | |
| sudo apt install awstats libgeo-ip-perl libgeo-ipfree-perl | |
| sudo apt install munin | |
| ======== below not verified yet ========================================================================== | |
| # Install osmosis (for diff updates) | |
| sudo apt install osmosis | |
| # Set up osmosis working dir for daily updates | |
| osmosis --rrii workingDirectory=~/data/updates | |
| # edit configuration.txt to baseUrl=http://download.geofabrik.de/europe/germany/bayern/mittelfranken-updates/ | |
| # Update data | |
| # Get state.txt file e.g. from http://osm.personalwerk.de/replicate-sequences/ | |
| osmosis --rri workingDirectory=~/data/updates --simplify-change --write-xml-change ~/data/updates/changes.osc.gz | |
| osm2pgsql --append --slim -d gis -C 12000 --number-processes 5 --flat-nodes /mnt/database/flat-nodes/gis-flat-nodes.bin --style ~/OpenTopoMap/mapnik/osm2pgsql/opentopomap.style ~/data/updates/changes.osc.gz | |
| # now we need to touch the outdated metatiles. Perhaps we need to write a script for this??? | |
| # touch -d "$(date -R -r 0.meta) - 10 years" 0.meta | |
| rm ~/data/updates/changes.osc.gz | |
| # Install cronjob: | |
| crontab -e | |
| */5 * * * * update.sh > output | |
| # perhaps we need to source out the index planet_osm_ways_nodes to the HDD in order to save space on the SSD: | |
| CREATE TABLESPACE anderertablespace LOCATION '/home/irgendwas'; ALTER INDEX planet_osm_ways_nodes SET TABLESPACE anderertablespace; | |