User:Ngt
Jump to navigation
Jump to search
About me | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Aktiv in
Nepal
Schönbuchlichtung
Holzgerlingen
Altdorf
Hildrizhausen
Weil im Schönbuch
United States
South Dakota
Webseiten
(DE)Ubuntuusers:Lm_sensors
(DE)Ubuntuusers:Munin
(EN)Wiki:Nominatim/Installation
(DE)Offline Tile & Nominatim server by Chrisoph Ziehr
mod_tile config & troubleshooting
Nominatim install script
Serverconfig
NetCup vServer VPS 2000 G7 SE OS: Ubuntu Server 16.04.1 LTS CPU: 6 vCPU RAM: 8 GB vRAM Storage: 160GB SAS
scripts: /osm/scripts/ files: /osm/files/ planetfiles: /osm/planet/ datenbank: /database/ tiles: /osm/tiles/ styles: /osm/styles
!! WARNING: scripts ARE incomplete and not tested at all !!
Setup Script for PGSql 9.5, postgis 2.2, osm2pgsql
#!/bin/bash #Prerequisits for osm2pgsql sudo apt-get install make cmake g++ libboost-dev libboost-system-dev libboost-filesystem-dev libexpat1-dev zlib1g-dev libbz2-dev libpq-dev libgeos-dev libgeos++-dev libproj-dev lua5.2 liblua5.2-dev #Postgresql installieren sudo apt-get install postgresql-9.5-postgis-2.2 sudo mkdir /osm mkdir /osm/scripts mkdir /osm/files mkdir /osm/planet mkdir /osm/styles mkdir /osm/tiles sudo chown -R $USER /osm sudo mkdir /database sudo mkdir /database/data sudo chown -R postgres /database #Drop default cluster sudo -u postgres pg_dropcluster --stop 9.5 main sudo -u postgres pg_createcluster -d /database/data 9.5 osmcluster sudo service postgresql start sudo -u postgres createuser -s $USER sudo -u postgres createdb -E UTF8 gis cd /osm/files git clone git://github.com/openstreetmap/osm2pgsql.git cd /osm/files/osm2pgsql mkdir build cd /osm/files/osm2pgsql/build cmake .. make sudo make install
Script for reimporting a file to the database ("update_bw.sh")
#!/bin/bash OSM_FILENAME="/osm/planet/baden-wuerttemberg-latest.osm.pbf" OSM_STYLE_FILENAME="/osm/styles/feuerwehr-carto/feuerwehr.style" OSM_POLY_FILE="/osm/planet/baden-wuerttemberg.poly" OSM_DOWNLOAD_PATH="http://download.geofabrik.de/europe/germany/baden-wuerttemberg-latest.osm.pbf" OSM_DOWNLOAD_PATH_POLY="http://download.geofabrik.de/europe/germany/baden-wuerttemberg.poly" export OSM_DOWNLOAD_PATH_POLY export OSM_POLY_FILE export OSM_FILENAME export OSM_STYLE_FILENAME export OSM_DOWNLOAD_PATH /osm/scripts/_update_tiles.sh
General script for importing to a new database. It is called trough update_bw.sh ("_update_tiles.sh")
#!/bin/bash wget -N -O $OSM_FILENAME $OSM_DOWNLOAD_PATH wget -N -O $OSM_POLY_FILE $OSM_DOWNLOAD_PATH_POLY dropdb gis_new createdb -E UTF8 -O $USER gis_new psql -d gis_new -c "CREATE EXTENSION postgis;" time osm2pgsql --create --slim -d gis_new --cache 6500 --number-processes 5 --style $OSM_STYLE_FILENAME $OSM_FILENAME psql postgres -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='gis';" dropdb gis psql postgres -c "ALTER DATABASE gis_new RENAME TO gis;" createdb -E UTF8 -O $USER gis_new psql -d gis_new -c "CREATE EXTENSION postgis;" #Set timestamp file for osmupdate osmconvert --out-timestamp $OSM_FILENAME > /osm/scripts/import_timestamp
[deprecated] Setup Script for PGSql 9.3, Nominatim, Mapnik, osm-carto, mod_tile
#!/bin/bash echo "This will install Nominatim, osm2pgsql, mod_tile, apache2 with php5, postgresql 9.3, postgis 2.1, osm-carto style and munin" echo "This install will require up to 1.5 GB free disk space" read -p "Continue:" goon sudo mkdir /osm sudo chown -R $USER /osm mkdir /osm/files mkdir /osm/planet mkdir /osm/shapefiles sudo mkdir -m 755 /tiles sudo chown -R $USER /tiles sudo mkdir /var/run/renderd sudo chown $USER /var/run/renderd sudo mkdir /var/lib/mod_tile sudo chown $USER /var/lib/mod_tile sudo apt-get update sudo apt-get -y upgrade sudo apt-get --no-install-recommends -y install libboost-all-dev subversion git vim tar unzip wget bzip2 build-essential autoconf automake gcc sudo apt-get --no-install-recommends -y install node-carto proj-bin libgeos++-dev libpq-dev libbz2-dev libproj-dev libprotobuf-c0-dev protobuf-c-compiler sudo apt-get --no-install-recommends -y install libpng12-dev libtiff4-dev libicu-dev libgdal-dev libcairo-dev libcairomm-1.0-dev libagg-dev liblua5.2-dev sudo apt-get --no-install-recommends -y install ttf-unifont lua5.1 liblua5.1-dev libgeos-c1 python-software-properties libtool libxml2-dev libgeos-dev sudo apt-get --no-install-recommends -y install postgresql postgresql-contrib postgis postgresql-9.3-postgis-2.1 postgresql-server-dev-9.3 libfreetype6-dev sudo apt-get --no-install-recommends -y install libboost-regex-dev libboost-system-dev libboost-thread-dev apache2-mpm-prefork lm-sensors sudo apt-get --no-install-recommends -y install apache2 apache2-dev apache2-utils libwww-perl libdbd-pg-perl php5 php-pear php5-pgsql php5-json php-db sudo apt-get --no-install-recommends -y install munin munin-node munin-plugins-extra if [ ! -d "/var/www" ]; then sudo mkdir /var/www fi sudo mkdir -m 755 /var/www/nominatim sudo chown $USER /var/www/nominatim sudo mkdir /database sudo mkdir /database/data sudo chown -R postgres /database #Drop default cluster sudo -u postgres pg_dropcluster --stop 9.3 main sudo -u postgres pg_createcluster -d /database/data 9.3 osmcluster sudo service postgresql start sudo -u postgres createuser -s $USER sudo -u postgres createuser -SDR www-data psql -d gis -c "CREATE EXTENSION postgis;" psql -d gis -c "GRANT SELECT ON spatial_ref_sys TO PUBLIC;" psql -d gis -c "GRANT ALL ON geometry_columns TO $USER;" psql -d gis -c "ALTER TABLE spatial_ref_sys OWNER TO $USER;" psql -d gis -c "ALTER TABLE geometry_columns OWNER TO $USER;" cd /osm git clone git://github.com/mapnik/mapnik cd mapnik git branch 2.2 origin/2.2.x git checkout 2.2 python scons/scons.py configure INPUT_PLUGINS=all OPTIMIZATION=3 SYSTEM_FONTS=/usr/share/fonts/truetype/ make sudo make install sudo ldconfig cd /osm git clone git://github.com/openstreetmap/mod_tile.git cd mod_tile ./autogen.sh ./configure make sudo make install sudo make install-mod_tile sudo ldconfig sudo touch /etc/apache2/conf-available/mod_tile.conf sudo chmod 777 /etc/apache2/conf-available/mod_tile.conf echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf cd /osm git clone --recursive git://github.com/twain47/Nominatim.git cd Nominatim ./autogen.sh ./configure make cd /osm git clone https://github.com/gravitystorm/openstreetmap-carto.git #Create copy of Nomintatim to allow an import to a seperate import-table to allow a full reimport and operation at the same time mkdir /osm/Nominatim-import mv /osm/Nominatim/* /osm/Nominatim-import touch /osm/Nominatim-import/settings/local.php echo "<?php" >> /osm/Nominatim/settings/local.php echo "@define('CONST_Postgresql_Version', '9.3');" >> /osm/Nominatim-import/settings/local.php echo "@define('CONST_Postgis_Version', '2.1');" >> /osm/Nominatim-import/settings/local.php echo "@define('CONST_Database_DSN', 'pgsql://@/nominatim_new');" >> /osm/Nominatim-import/settings/local.php echo "?>" >> /osm/Nominatim-import/settings/local.php touch /osm/Nominatim/settings/local.php echo "<?php" >> /osm/Nominatim/settings/local.php echo "@define('CONST_Postgresql_Version', '9.3');" >> /osm/Nominatim/settings/local.php echo "@define('CONST_Postgis_Version', '2.1');" >> /osm/Nominatim/settings/local.php echo "@define('CONST_Website_BaseURL', 'http://localhost/nominatim/');" >> /osm/Nominatim/settings/local.php echo "?>" >> /osm/Nominatim/settings/local.php /osm/Nominatim/utils/setup.php --create-website /var/www/nominatim #nominatim plugins sudo ln -s /osm/Nominatim/munin/nominatim_query_speed /etc/munin/plugins sudo ln -s /osm/Nominatim/munin/nominatim_importlag /etc/munin/plugins sudo ln -s /osm/Nominatim/munin/nominatim_requests /etc/munin/plugins #postgres plugins sudo ln -s /usr/share/munin/plugins/postgres_bgwriter /etc/munin/plugins/ sudo ln -s /usr/share/munin/plugins/postgres_cache_ /etc/munin/plugins/postgres_cache_nominatim sudo ln -s /usr/share/munin/plugins/postgres_cache_ /etc/munin/plugins/postgres_cache_nominatim_new sudo ln -s /usr/share/munin/plugins/postgres_cache_ /etc/munin/plugins/postgres_cache_gis sudo ln -s /usr/share/munin/plugins/postgres_cache_ /etc/munin/plugins/postgres_cache_gis_new sudo ln -s /usr/share/munin/plugins/postgres_checkpoints /etc/munin/plugins/ sudo ln -s /usr/share/munin/plugins/postgres_connections_ /etc/munin/plugins/postgres_connections_nominatim sudo ln -s /usr/share/munin/plugins/postgres_connections_ /etc/munin/plugins/postgres_connections_nominatim_new sudo ln -s /usr/share/munin/plugins/postgres_connections_ /etc/munin/plugins/postgres_connections_gis sudo ln -s /usr/share/munin/plugins/postgres_connections_db /etc/munin/plugins/ sudo ln -s /usr/share/munin/plugins/postgres_size_ /etc/munin/plugins/postgres_size_nominatim sudo ln -s /usr/share/munin/plugins/postgres_size_ /etc/munin/plugins/postgres_size_nominatim_new sudo ln -s /usr/share/munin/plugins/postgres_size_ /etc/munin/plugins/postgres_size_gis sudo ln -s /usr/share/munin/plugins/postgres_size_ /etc/munin/plugins/postgres_size_gis_new sudo ln -s /usr/share/munin/plugins/postgres_querylength_ /etc/munin/plugins/postgres_querylength_nominatim sudo ln -s /usr/share/munin/plugins/postgres_querylength_ /etc/munin/plugins/postgres_querylength_nominatim_new sudo ln -s /usr/share/munin/plugins/postgres_querylength_ /etc/munin/plugins/postgres_querylength_gis sudo ln -s /usr/share/munin/plugins/postgres_scans_ /etc/munin/plugins/postgres_scans_nominatim sudo ln -s /usr/share/munin/plugins/postgres_scans_ /etc/munin/plugins/postgres_scans_nominatim_new sudo ln -s /usr/share/munin/plugins/postgres_scans_ /etc/munin/plugins/postgres_scans_gis sudo ln -s /usr/share/munin/plugins/postgres_tuples_ /etc/munin/plugins/postgres_tuples_nominatim sudo ln -s /usr/share/munin/plugins/postgres_tuples_ /etc/munin/plugins/postgres_tuples_nominatim_new sudo ln -s /usr/share/munin/plugins/postgres_tuples_ /etc/munin/plugins/postgres_tuples_gis #apache plugins sudo ln -s /usr/share/munin/plugins/apache_accesses /etc/munin/plugins/ sudo ln -s /usr/share/munin/plugins/apache_processes /etc/munin/plugins/ sudo ln -s /usr/share/munin/plugins/apache_volume /etc/munin/plugins/ #mod_tile plugins sudo ln -s /osm/mod_tile/munin/* /etc/munin/plugins/ sudo chmod a+x /osm/mod_tile/munin/* #sensors sudo ln -s /usr/share/munin/plugins/sensors_ /etc/munin/plugins/sensors_fan sudo ln -s /usr/share/munin/plugins/sensors_ /etc/munin/plugins/sensors_volt sudo ln -s /usr/share/munin/plugins/sensors_ /etc/munin/plugins/sensors_temp sudo touch /etc/munin/plugin-conf.d/munin-node sudo chmod 755 /etc/munin/plugin-conf.d/munin-node echo "" >> /etc/munin/plugin-conf.d/munin-node echo "[postgres_*]" >> /etc/munin/plugin-conf.d/munin-node echo "user postgres" >> /etc/munin/plugin-conf.d/munin-node echo "env.PGUSER postgres" >> /etc/munin/plugin-conf.d/munin-node echo "env.PGPORT 5432" >> /etc/munin/plugin-conf.d/munin-node echo "" >> /etc/munin/plugin-conf.d/munin-node echo "[nominatim_*]" >> /etc/munin/plugin-conf.d/munin-node echo "user www-data" >> /etc/munin/plugin-conf.d/munin-node echo "env.PGUSER www-data" >> /etc/munin/plugin-conf.d/munin-node echo "env.PGPORT 5432" >> /etc/munin/plugin-conf.d/munin-node echo "env.PGDATABASE nominatim" >> /etc/munin/plugin-conf.d/munin-node echo "env.age_warning 21600" >> /etc/munin/plugin-conf.d/munin-node echo "env.age_critical 86400" >> /etc/munin/plugin-conf.d/munin-node sudo ln -s /var/cache/munin/www/ /var/www/munin sudo touch /etc/apache2/sites-available/munin.conf sudo chmod 755 /etc/apache2/sites-available/munin.conf echo "" >> /etc/apache2/sites-available/munin.conf echo ' Alias /munin/ "/var/www/munin/"' >> /etc/apache2/sites-available/munin.conf echo ' <Directory "/var/www/munin/">' >> /etc/apache2/sites-available/munin.conf echo ' Options Indexes MultiViews FollowSymLinks' >> /etc/apache2/sites-available/munin.conf echo ' AllowOverride None' >> /etc/apache2/sites-available/munin.conf echo ' Order deny,allow' >> /etc/apache2/sites-available/munin.conf echo ' Allow from all' >> /etc/apache2/sites-available/munin.conf echo ' Require all granted' >> /etc/apache2/sites-available/munin.conf echo ' </Directory>' >> /etc/apache2/sites-available/munin.conf sudo sed -i "s|Allow from.*|Allow from all|" /etc/munin/apache.conf sudo service munin-node restart sudo service apache2 reload echo "Setup complete!" proj psql --version grep 'default_version' '/usr/share/postgresql/9.3/extension/postgis.control' geos-config --version osm2pgsql --version osmconvert -h | head -n2 echo " " echo "Important Folders:" echo "/osm All OSM-Related programs and files" echo "/osm/log Logfiles für setup and imports" echo "/database All " echo "/osm/nominatim" echo "/osm/planet Exported .osm.pbf file" echo "/osm/files Additional Files" echo "/osm/style Style mapnik will use" echo "/osm/shapefiles Shapefiles" wget -N -O /osm/planet/baden-wuerttemberg-latest.osm.pbf http://download.geofabrik.de/europe/germany/baden-wuerttemberg-latest.osm.pbf wget -N -O /osm/files/simplified-land-polygons-complete-3857.zip http://data.openstreetmapdata.com/simplified-land-polygons-complete-3857.zip wget -N -O /osm/files/land-polygons-split-3857.zip http://data.openstreetmapdata.com/land-polygons-split-3857.zip wget -N -O /osm/files/ne_10m_populated_places_simple.zip http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places_simple.zip sudo unzip /osm/files/simplified-land-polygons-complete-3857.zip -d /osm/shapefiles sudo unzip /osm/files/land-polygons-split-3857.zip -d /osm/shapefiles sudo unzip /osm/files/ne_10m_populated_places_simple.zip -d /osm/shapefiles
osm-update.sh
#!/bin/bash #wget -N -O /osm/planet/baden-wuerttemberg-latest.osm.pbf http://downloads.geofabrik.de/europe/germany/baden-wuerttemberg-latest.osm.pbf #wget -N -O /osm/Nominatim-import/data/wikipedia_article.sql.bin http://www.nominatim.org/data/wikipedia_article.sql.bin #wget -N -O /osm/Nominatim-import/data/wikipedia_redirect.sql.bin http://www.nominatim.org/data/wikipedia_redirect.sql.bin dropdb gis_new createdb gis_new psql -d gis_new -c "CREATE EXTENSION postgis;" psql -d gis_new -c "GRANT SELECT ON spatial_ref_sys TO PUBLIC;" psql -d gis_new -c "GRANT ALL ON geometry_columns TO $USER;" psql -d gis_new -c "ALTER TABLE spatial_ref_sys OWNER TO $USER;" psql -d gis_new -c "ALTER TABLE geometry_columns OWNER TO $USER;" osm2pgsql --create --slim -d gis_new --cache 8000 --number-processes 6 --style /osm/openstreetmap-carto/openstreetmap-carto.style --multi-geometry /osm/planet/baden-wuerttemberg-latest.osm.pbf psql postgres -c "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname='gis';ALTER DATABASE gis RENAME TO gis_old;" psql postgres -c "ALTER DATABASE gis_new RENAME TO gis;" dropdb nominatim_new /osm/Nominatim-import/utils/specialphrases.php --countries > /osm/files/specialphrases_countries.sql /osm/Nominatim-import/utils/specialphrases.php --wiki-import > /osm/files/specialphrases.sql /osm/Nominatim-import/utils/setup.php --osm-file /osm/planet/baden-wuerttemberg-latest.osm.pbf --all --osm2pgsql-cache 8000 --threads 4 2>&1 | tee /osm/log/`date +"$Y%m%d"`nominatim_import.log psql -d nominatim_new -f /osm/files/specialphrases.sql psql -d nominatim_new -f /osm/files/specialphrases_countries.sql dropdb nominatim_old psql postgres -c "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname='nominatim';ALTER DATABASE nominatim RENAME TO nominatim_old;" psql postgres -c "ALTER DATABASE nominatim_new RENAME TO nominatim;"