From: Sarah Hoffmann Date: Sun, 14 Jan 2018 22:43:15 +0000 (+0100) Subject: use mkdocs for compiling the documentation X-Git-Tag: v3.1.0~1^2~2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/b8f7563da9656b9f07e6fefbb8ddae12badda717 use mkdocs for compiling the documentation Requires to shuffle around the documentation. make doc will now compile the documentation in the build directory. The markdowns created from the vagrant files are no longer versioned. --- diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 1a7dbd1c..e8596e49 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,32 +1,17 @@ # Auto-generated vagrant install documentation -set (INSTALLDOCFILES - Install-on-Centos-7 - Install-on-Ubuntu-16 - ) -foreach (df ${INSTALLDOCFILES}) - ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${df}.md - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/${df}.sh ${CMAKE_CURRENT_BINARY_DIR}/${df}.md - MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/vagrant/${df}.sh - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh - COMMENT "Creating markdown docs from vagrant/${df}.sh" - ) +# build the actual documentation -ADD_CUSTOM_TARGET( md_install_${df} ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${df}.md - ) -endforeach() +configure_file(mkdocs.yml ../mkdocs.yml) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/appendix) -# Copied static documentation +ADD_CUSTOM_TARGET(doc + COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/admin ${CMAKE_CURRENT_BINARY_DIR}/admin + COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/index.md ${CMAKE_CURRENT_BINARY_DIR}/index.md + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Centos-7.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Centos-7.md + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bash2md.sh ${PROJECT_SOURCE_DIR}/vagrant/Install-on-Ubuntu-16.sh ${CMAKE_CURRENT_BINARY_DIR}/appendix/Install-on-Ubuntu-16.md + COMMAND mkdocs build -d ${CMAKE_CURRENT_BINARY_DIR}/../site-html -f ${CMAKE_CURRENT_BINARY_DIR}/../mkdocs.yml +) -set (GENERALDOCFILES - Installation.md - Import-and-Update.md - Faq.md - ) - -foreach (df ${GENERALDOCFILES}) - CONFIGURE_FILE(${df} ${df}) -endforeach() diff --git a/docs/Install-on-Centos-7.md b/docs/Install-on-Centos-7.md deleted file mode 100644 index 0ac1e53b..00000000 --- a/docs/Install-on-Centos-7.md +++ /dev/null @@ -1,182 +0,0 @@ - -*Note:* these installation instructions are also available in executable - form for use with vagrant under `vagrant/Install-on-Centos-7.sh`. - -Installing the Required Software -================================ - -These instructions expect that you have a freshly installed CentOS version 7. -Make sure all packages are up-to-date by running: - - sudo yum update -y - -The standard CentOS repositories don't contain all the required packages, -you need to enable the EPEL repository as well. To enable it on CentOS, -install the epel-release RPM by running: - - sudo yum install -y epel-release - -Now you can install all packages needed for Nominatim: - - sudo yum install -y postgresql-server postgresql-contrib postgresql-devel postgis postgis-utils \ - git cmake make gcc gcc-c++ libtool policycoreutils-python \ - php-pgsql php php-pear php-pear-DB php-intl libpqxx-devel proj-epsg \ - bzip2-devel proj-devel geos-devel libxml2-devel boost-devel expat-devel zlib-devel - -If you want to run the test suite, you need to install the following -additional packages: - - sudo yum install -y python-pip python-Levenshtein python-psycopg2 \ - python-numpy php-phpunit-PHPUnit - pip install --user --upgrade pip setuptools lettuce==0.2.18 six==1.9 \ - haversine Shapely pytidylib - sudo pear install PHP_CodeSniffer - - -System Configuration -==================== - -The following steps are meant to configure a fresh CentOS installation -for use with Nominatim. You may skip some of the steps if you have your -OS already configured. - -Creating Dedicated User Accounts --------------------------------- - -Nominatim will run as a global service on your machine. It is therefore -best to install it under its own separate user account. In the following -we assume this user is called nominatim and the installation will be in -/srv/nominatim. To create the user and directory run: - - sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim - -You may find a more suitable location if you wish. - -To be able to copy and paste instructions from this manual, export -user name and home directory now like this: - - export USERNAME=nominatim - export USERHOME=/srv/nominatim - -**Never, ever run the installation as a root user.** You have been warned. - -Make sure that system servers can read from the home directory: - - chmod a+x $USERHOME - -Setting up PostgreSQL ---------------------- - -CentOS does not automatically create a database cluster. Therefore, start -with initializing the database, then enable the server to start at boot: - - sudo postgresql-setup initdb - sudo systemctl enable postgresql - - -Next tune the postgresql configuration, which is located in -`/var/lib/pgsql/data/postgresql.conf`. See section *Postgres Tuning* in -[the installation page](Installation.md) for the parameters to change. - -Now start the postgresql service after updating this config file. - - sudo systemctl restart postgresql - - -Finally, we need to add two postgres users: one for the user that does -the import and another for the webserver which should access the database -only for reading: - - - sudo -u postgres createuser -s $USERNAME - sudo -u postgres createuser apache - - -Setting up the Apache Webserver -------------------------------- - -You need to create an alias to the website directory in your apache -configuration. Add a separate nominatim configuration to your webserver: - -``` -sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF - - Options FollowSymLinks MultiViews - AddType text/html .php - DirectoryIndex search.php - Require all granted - - -Alias /nominatim $USERHOME/Nominatim/build/website -EOFAPACHECONF -``` - - - - -Then reload apache - - - sudo systemctl restart httpd - - -Adding SELinux Security Settings --------------------------------- - -It is a good idea to leave SELinux enabled and enforcing, particularly -with a web server accessible from the Internet. At a minimum the -following SELinux labeling should be done for Nominatim: - - sudo semanage fcontext -a -t httpd_sys_content_t "$USERHOME/Nominatim/(website|lib|settings)(/.*)?" - sudo semanage fcontext -a -t lib_t "$USERHOME/Nominatim/module/nominatim.so" - sudo restorecon -R -v $USERHOME/Nominatim - - -Installing Nominatim -==================== - -Building and Configuration --------------------------- - -Get the source code from Github and change into the source directory - - - - cd $USERHOME - git clone --recursive git://github.com/openstreetmap/Nominatim.git - cd Nominatim - - - - - -When installing the latest source from github, you also need to -download the country grid: - - - wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz - - -The code must be built in a separate directory. Create this directory, -then configure and build Nominatim in there: - - - mkdir build - cd build - cmake $USERHOME/Nominatim - make - -You need to create a minimal configuration file that tells nominatim -the name of your webserver user and the URL of the website: - -``` -tee settings/local.php << EOF - - Options FollowSymLinks MultiViews - AddType text/html .php - DirectoryIndex search.php - Require all granted - - -Alias /nominatim $USERHOME/Nominatim/build/website -EOFAPACHECONF -``` - - - - -Then enable the configuration and restart apache - - - sudo a2enconf nominatim - sudo systemctl restart apache2 - - -Installing Nominatim -==================== - -Building and Configuration --------------------------- - -Get the source code from Github and change into the source directory - - - - cd $USERHOME - git clone --recursive git://github.com/openstreetmap/Nominatim.git - cd Nominatim - - - - - -When installing the latest source from github, you also need to -download the country grid: - - - wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz - - -The code must be built in a separate directory. Create this directory, -then configure and build Nominatim in there: - - - mkdir build - cd build - cmake $USERHOME/Nominatim - make - -You need to create a minimal configuration file that tells nominatim -where it is located on the webserver: - -``` -tee settings/local.php << EOF - /etc/php.d/timezone.ini - +``` +echo "date.timezone = 'America/Denver'" > /etc/php.d/timezone.ini +``` ### When running the import I get a version mismatch: `COPY_END for place failed: ERROR: incompatible library "/opt/Nominatim/module/nominatim.so": version mismatch` @@ -98,7 +97,7 @@ to get the full error message. On CentOS v7 the PostgreSQL server is started with `systemd`. Check if `/usr/lib/systemd/system/httpd.service` contains a line `PrivateTmp=true`. If so then Apache cannot see the `/tmp/.s.PGSQL.5432` file. It's a good security feature, -so use the [[#PostgreSQL_UNIX_Socket_Location_on_CentOS|preferred solution]] +so use the [preferred solution](../appendix/Install-on-Centos-7/#adding-selinux-security-settings). However, you can solve this the quick and dirty way by commenting out that line and then run @@ -120,7 +119,7 @@ have the [http://pear.php.net/package/DB/ Pear module 'DB'] installed. sudo pear install DB -### I forgot to delete the flatnodes file before starting an import +### I forgot to delete the flatnodes file before starting an import. That's fine. For each import the flatnodes file get overwritten. See https://help.openstreetmap.org/questions/52419/nominatim-flatnode-storage diff --git a/docs/Import-and-Update.md b/docs/admin/Import-and-Update.md similarity index 68% rename from docs/Import-and-Update.md rename to docs/admin/Import-and-Update.md index b523f65d..26ed9eb9 100644 --- a/docs/Import-and-Update.md +++ b/docs/admin/Import-and-Update.md @@ -1,16 +1,23 @@ -Importing a new database -======================== - The following instructions explain how to create a Nominatim database from an OSM planet file and how to keep the database up to date. It is assumed that you have already successfully installed the Nominatim software itself, if not return to the [installation page](Installation.md). -Configuration setup in settings/local.php ------------------------------------------ +# Configuration setup in settings/local.php + +The Nominatim server can be customized via the file `settings/local.php` +in the build directory. Note that this is a PHP file, so it must always +start like this: + + --all [--osm2pgsql-cache 28000] 2>&1 | tee setup.log +```sh +./utils/setup.php --osm-file --all [--osm2pgsql-cache 28000] 2>&1 | tee setup.log +``` The `--osm2pgsql-cache` parameter is optional but strongly recommended for planet imports. It sets the node cache size for the osm2pgsql import part -(see `-C` parameter in osm2pgsql help). 28GB are recommended for a full planet -import, for excerpts you can use less. Adapt to your available RAM to -avoid swapping, never give more than 2/3 of RAM to osm2pgsql. - +(see `-C` parameter in osm2pgsql help). As a rule of thumb, this should be +about the same size as the file you are importing but never more than +2/3 of RAM available. If your machine starts swapping reduce the size. Computing word frequency for search terms can improve the performance of forward geocoding in particular under high load as it helps Postgres' query planner to make the right decisions. To recompute word counts run: - ./utils/update.php --recompute-word-counts +```sh +./utils/update.php --recompute-word-counts +``` This will take a couple of hours for a full planet installation. You can also defer that step to a later point in time when you realise that performance becomes an issue. Just make sure that updates are stopped before running this function. -Loading additional datasets ---------------------------- - -The following commands will create additional entries for POI searches: +If you want to be able to search for places by their type through +[special key phrases](https://wiki.openstreetmap.org/wiki/Nominatim/Special_Phrases) +you also need to enable these key phrases like this: ./utils/specialphrases.php --wiki-import > specialphrases.sql psql -d nominatim -f specialphrases.sql +Note that this command downloads the phrases from the wiki link above. + -Installing Tiger housenumber data for the US -============================================ +# Installing Tiger housenumber data for the US Nominatim is able to use the official TIGER address set to complement the -OSM housenumber data in the US. You can add TIGER data to your own Nominatim +OSM house number data in the US. You can add TIGER data to your own Nominatim instance by following these steps: 1. Install the GDAL library and python bindings and the unzip tool @@ -100,49 +108,62 @@ instance by following these steps: * Ubuntu: `sudo apt-get install python-gdal unzip` * CentOS: `sudo yum install gdal-python unzip` - 2. Get the TIGER 2015 data. You will need the EDGES files - (3,234 zip files, 11GB total). Choose one of the two sources: + 2. Get preprocessed TIGER 2015 data and unpack it into the + data directory in your Nominatim sources: - wget -r ftp://ftp2.census.gov/geo/tiger/TIGER2015/EDGES/ - wget -r ftp://mirror1.shellbot.com/census/geo/tiger/TIGER2015/EDGES/ + cd Nominatim/data + wget https://nominatim.org/data/tiger2017-nominatim-preprocessed.tar.gz + tar xf tiger2017-nominatim-preprocessed.tar.gz - The first one is the original source, the second a considerably faster - mirror. + 3. Import the data into your Nominatim database: - 3. Convert the data into SQL statements (stored in data/tiger): + ./utils/setup.php --import-tiger-data - ./utils/imports.php --parse-tiger + 4. Enable use of the Tiger data in your `settings/local.php` by adding: + + @define('CONST_Use_US_Tiger_Data', true); - 4. Import the data into your Nominatim database: + 5. Apply the new settings: - ./utils/setup.php --import-tiger-data +```sh + ./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions +``` - 5. Enable use of the Tiger data in your `settings/local.php` by adding: +The entire US adds about 10GB to your database. - @define('CONST_Use_US_Tiger_Data', true); +You can also process the data from the original TIGER data to create the +SQL files, Nominatim needs for the import: - 6. Apply the new settings: + 1. Get the TIGER 2017 data. You will need the EDGES files + (3,234 zip files, 11GB total). Choose one of the two sources: - ./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions + wget -r ftp://ftp2.census.gov/geo/tiger/TIGER2017/EDGES/ + wget -r ftp://mirror1.shellbot.com/census/geo/tiger/TIGER2017/EDGES/ -Be warned that the import can take a very long time, especially if you -import all of the US. The entire US adds about 10GB to your database. + The first one is the original source, the second a considerably faster + mirror. + + 2. Convert the data into SQL statements: + + ./utils/imports.php --parse-tiger +Be warned that this can take quite a long time. After this process is finished, +the same preprocessed files as above are available in `data/tiger`. -Updates -======= +# Updates There are many different possibilities to update your Nominatim database. The following section describes how to keep it up-to-date with Pyosmium. For a list of other methods see the output of `./utils/update.php --help`. -Installing the newest version of Pyosmium ------------------------------------------ +### Installing the newest version of Pyosmium It is recommended to install Pyosmium via pip. Run (as the same user who will later run the updates): - pip install --user osmium +```sh +pip install --user osmium +``` Nominatim needs a tool called `pyosmium-get-updates` that comes with Pyosmium. You need to tell Nominatim where to find it. Add the @@ -153,8 +174,7 @@ following line to your `settings/local.php`: The path above is fine if you used the `--user` parameter with pip. Replace `user` with your user name. -Setting up the update process ------------------------------ +### Setting up the update process Next the update needs to be initialised. By default Nominatim is configured to update using the global minutely diffs. @@ -180,8 +200,7 @@ what you expect. The --init-updates command needs to be rerun whenever the replication service is changed. -Updating Nominatim ------------------- +### Updating Nominatim The following command will keep your database constantly up to date: diff --git a/docs/Installation.md b/docs/admin/Installation.md similarity index 89% rename from docs/Installation.md rename to docs/admin/Installation.md index 1cdd9d10..fbdff93e 100644 --- a/docs/Installation.md +++ b/docs/admin/Installation.md @@ -1,20 +1,16 @@ -Nominatim installation -====================== - This page contains generic installation instructions for Nominatim and its prerequisites. There are also step-by-step instructions available for the following operating systems: - * [Ubuntu 16.04](Install-on-Ubuntu-16.md) - * [CentOS 7.2](Install-on-Centos-7.md) + * [Ubuntu 16.04](../appendix/Install-on-Ubuntu-16.md) + * [CentOS 7.2](../appendix/Install-on-Centos-7.md) These OS-specific instructions can also be found in executable form in the `vagrant/` directory. -Prerequisites -------------- +# Prerequisites -### Software +## Software For compiling: @@ -47,23 +43,22 @@ For running continuous updates: * [pyosmium](http://osmcode.org/pyosmium/) -### Hardware +## Hardware A minimum of 2GB of RAM is required or installation will fail. For a full planet import 32GB of RAM or more strongly are recommended. -For a full planet install you will need about 500GB of hard disk space (as of -June 2016, take into account that the OSM database is growing fast). SSD disks +For a full planet install you will need about 600GB of hard disk space (as of +January 2017, take into account that the OSM database is growing fast). SSD disks will help considerably to speed up import and queries. On a 6-core machine with 32GB RAM and SSDs the import of a full planet takes a bit more than 2 days. Without SSDs 7-8 days are more realistic. -Setup of the server -------------------- +# Setup of the server -### PostgreSQL tuning +## PostgreSQL tuning You might want to tune your PostgreSQL installation so that the later steps make best use of your hardware. You should tune the following parameters in @@ -90,13 +85,13 @@ Don't forget to reenable them after the initial import or you risk database corruption. Autovacuum must not be switched off because it ensures that the tables are frequently analysed. -### Webserver setup +## Webserver setup The `website/` directory in the build directory contains the configured website. Include the directory into your webbrowser to serve php files from there. -#### Configure for use with Apache +### Configure for use with Apache Make sure your Apache configuration contains the required permissions for the directory and create an alias: @@ -115,7 +110,7 @@ build directory. After making changes in the apache config you need to restart apache. The website should now be available on http://localhost/nominatim. -#### Configure for use with Nginx +### Configure for use with Nginx Use php-fpm as a deamon for serving PHP cgi. Install php-fpm together with nginx. @@ -148,7 +143,7 @@ unix socket by adding the location definition to the default configuration. } Restart the nginx and php5-fpm services and the website should now be available -on http://localhost/. +at `http://localhost/`. Now continue with [importing the database](Import-and-Update.md). diff --git a/docs/admin/Migration.md b/docs/admin/Migration.md new file mode 100644 index 00000000..2f03c200 --- /dev/null +++ b/docs/admin/Migration.md @@ -0,0 +1,66 @@ +Database Migrations +=================== + +This page describes database migrations necessary to update existing databases +to newer versions of Nominatim. + +SQL statements should be executed from the postgres commandline. Execute +`psql nominiatim` to enter command line mode. + +# 3.0.0 -> 3.1.0 + +### Postcode Table + +A new separate table for artificially computed postcode centroids was introduced. +Migration to the new format is possible but **not recommended**. + +Create postcode table and indexes, running the following SQL statements: + +```sql +CREATE TABLE location_postcode + (place_id BIGINT, parent_place_id BIGINT, rank_search SMALLINT, + rank_address SMALLINT, indexed_status SMALLINT, indexed_date TIMESTAMP, + country_code varchar(2), postcode TEXT, + geometry GEOMETRY(Geometry, 4326)); +CREATE INDEX idx_postcode_geometry ON location_postcode USING GIST (geometry); +CREATE UNIQUE INDEX idx_postcode_id ON location_postcode USING BTREE (place_id); +CREATE INDEX idx_postcode_postcode ON location_postcode USING BTREE (postcode); +GRANT SELECT ON location_postcode TO "www-data"; +``` + +Add postcode column to `location_area` tables with SQL statement: + +```sql +ALTER TABLE location_area ADD COLUMN postcode TEXT; +``` + +Then reimport the functions: + +```sh +./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions +``` + +Create appropriate triggers with SQL: + +```sql +CREATE TRIGGER location_postcode_before_update BEFORE UPDATE ON location_postcode + FOR EACH ROW EXECUTE PROCEDURE postcode_update(); +``` + +Finally populate the postcode table (will take a while): + +```sh +./utils/setup.php --calculate-postcodes --index --index-noanalyse +``` + +This will create a working database. You may also delete the old artificial +postcodes now. Note that this may be expensive and is not absolutely necessary. +The following SQL statement will remove them: + +```sql +DELETE FROM place_addressline a USING placex p + WHERE a.address_place_id = p.place_id and p.osm_type = 'P'; +ALTER TABLE placex DISABLE TRIGGER USER; +DELETE FROM placex WHERE osm_type = 'P'; +ALTER TABLE placex ENABLE TRIGGER USER; +``` diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..41eadde1 --- /dev/null +++ b/docs/index.md @@ -0,0 +1 @@ +Nominatim (from the Latin, 'by name') is a tool to search OSM data by name and address and to generate synthetic addresses of OSM points (reverse geocoding). diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml new file mode 100644 index 00000000..0bbc48c8 --- /dev/null +++ b/docs/mkdocs.yml @@ -0,0 +1,15 @@ +site_name: Nominatim Documentation +theme: readthedocs +docs_dir: ${CMAKE_CURRENT_BINARY_DIR} +site_url: http://nominatim.org +repo_url: https://github.com/openstreetmap/Nominatim +pages: + - 'Introduction' : 'index.md' + - 'Administration Guide': + - 'Basic Installation': 'admin/Installation.md' + - 'Importing and Updating' : 'admin/Import-and-Update.md' + - 'Migration from older Versions' : 'admin/Migration.md' + - 'Troubleshooting' : 'admin/Faq.md' + - 'Appendix': + - 'Installation on CentOS 7' : 'appendix/Install-on-Centos-7.md' + - 'Installation on Ubuntu 16' : 'appendix/Install-on-Ubuntu-16.md'