Merge pull request #884 from lonvia/docs-tomkdocs

Switch to mkdocs for building documentation
This commit is contained in:
Sarah Hoffmann 2018-01-16 22:43:49 +01:00 committed by GitHub
commit dfa74daf52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 225 additions and 547 deletions

View File

@ -1,32 +1,17 @@
# Auto-generated vagrant install documentation # Auto-generated vagrant install documentation
set (INSTALLDOCFILES
Install-on-Centos-7
Install-on-Ubuntu-16
)
foreach (df ${INSTALLDOCFILES}) # build the actual documentation
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"
)
ADD_CUSTOM_TARGET( md_install_${df} ALL configure_file(mkdocs.yml ../mkdocs.yml)
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${df}.md file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/appendix)
)
endforeach()
# 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()

View File

@ -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
<Directory "$USERHOME/Nominatim/build/website">
Options FollowSymLinks MultiViews
AddType text/html .php
DirectoryIndex search.php
Require all granted
</Directory>
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
<?php
@define('CONST_Database_Web_User', 'apache');
@define('CONST_Website_BaseURL', '/nominatim/');
EOF
```
Nominatim is now ready to use. Continue with
[importing a database from OSM data](Import-and-Update.md).

View File

@ -1,169 +0,0 @@
*Note:* these installation instructions are also available in executable
form for use with vagrant under vagrant/Install-on-Ubuntu-16.sh.
Installing the Required Software
================================
These instructions expect that you have a freshly installed Ubuntu 16.04.
Make sure all packages are are up-to-date by running:
sudo apt-get update -qq
Now you can install all packages needed for Nominatim:
sudo apt-get install -y build-essential cmake g++ libboost-dev libboost-system-dev \
libboost-filesystem-dev libexpat1-dev zlib1g-dev libxml2-dev\
libbz2-dev libpq-dev libgeos-dev libgeos++-dev libproj-dev \
postgresql-server-dev-9.5 postgresql-9.5-postgis-2.2 postgresql-contrib-9.5 \
apache2 php php-pgsql libapache2-mod-php php-pear php-db \
php-intl git
If you want to run the test suite, you need to install the following
additional packages:
sudo apt-get install -y python3-setuptools python3-dev python3-pip \
python3-psycopg2 python3-tidylib phpunit php-cgi
pip3 install --user behave nose # urllib3
sudo pear install PHP_CodeSniffer
System Configuration
====================
The following steps are meant to configure a fresh Ubuntu 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
---------------------
Tune the postgresql configuration, which is located in
`/etc/postgresql/9.5/main/postgresql.conf`. See section *Postgres Tuning* in
[the installation page](Installation.md) for the parameters to change.
Restart 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
for reading only:
sudo -u postgres createuser -s $USERNAME
sudo -u postgres createuser www-data
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/apache2/conf-available/nominatim.conf << EOFAPACHECONF
<Directory "$USERHOME/Nominatim/build/website">
Options FollowSymLinks MultiViews
AddType text/html .php
DirectoryIndex search.php
Require all granted
</Directory>
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
<?php
@define('CONST_Website_BaseURL', '/nominatim/');
EOF
```
Nominatim is now ready to use. Continue with
[importing a database from OSM data](Import-and-Update.md).

View File

@ -1,56 +0,0 @@
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
-----
### 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:
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:
ALTER TABLE location_area ADD COLUMN postcode TEXT;
* reimport functions
./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
* create appropriate triggers with SQL:
CREATE TRIGGER location_postcode_before_update BEFORE UPDATE ON location_postcode
FOR EACH ROW EXECUTE PROCEDURE postcode_update();
* populate postcode table (will take a while):
./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:
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;

View File

@ -1,8 +1,4 @@
Frequently Asked Questions # Running Your Own Instance
==========================
Running Your Own Instance
-------------------------
### Can I import only a few countries and also keep them up to date? ### Can I import only a few countries and also keep them up to date?
@ -25,8 +21,7 @@ for a script that runs the updates using osmosis.
Make sure there are no spaces at the beginning of your `settings/local.php` file. Make sure there are no spaces at the beginning of your `settings/local.php` file.
Installation # Installation
------------
### I accidentally killed the import process after it has been running for many hours. Can it be resumed? ### I accidentally killed the import process after it has been running for many hours. Can it be resumed?
@ -34,11 +29,14 @@ It is possible if the import already got to the indexing stage.
Check the last line of output that was logged before the process Check the last line of output that was logged before the process
was killed. If it looks like this: was killed. If it looks like this:
Done 844 in 13 @ 64.923080 per second - Rank 26 ETA (seconds): 7.886255
Done 844 in 13 @ 64.923080 per second - Rank 26 ETA (seconds): 7.886255
then you can resume with the following command: then you can resume with the following command:
./utils/setup.php --index --create-search-indices --create-country-names ```sh
./utils/setup.php --index --create-search-indices --create-country-names
```
If the reported rank is 26 or higher, you can also safely add `--index-noanalyse`. If the reported rank is 26 or higher, you can also safely add `--index-noanalyse`.
@ -69,8 +67,9 @@ something like this:
Or Or
echo "date.timezone = 'America/Denver'" > /etc/php.d/timezone.ini ```
echo "date.timezone = 'America/Denver'" > /etc/php.d/timezone.ini
```
### When running the import I get a version mismatch: ### When running the import I get a version mismatch:
`COPY_END for place failed: ERROR: incompatible library "/opt/Nominatim/module/nominatim.so": 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`. On CentOS v7 the PostgreSQL server is started with `systemd`.
Check if `/usr/lib/systemd/system/httpd.service` contains a line `PrivateTmp=true`. 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, 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 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 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. That's fine. For each import the flatnodes file get overwritten.
See https://help.openstreetmap.org/questions/52419/nominatim-flatnode-storage See https://help.openstreetmap.org/questions/52419/nominatim-flatnode-storage

View File

@ -1,16 +1,23 @@
Importing a new database
========================
The following instructions explain how to create a Nominatim 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 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 is assumed that you have already successfully installed the Nominatim
software itself, if not return to the [installation page](Installation.md). 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:
<?php
without any leading spaces.
There are lots of configuration settings you can tweak. Have a look There are lots of configuration settings you can tweak. Have a look
at `settings/settings.php` for a full list. Most should have a sensible default. at `settings/default.php` for a full list. Most should have a sensible default.
### Flatnode files
If you plan to import a large dataset (e.g. Europe, North America, planet), If you plan to import a large dataset (e.g. Europe, North America, planet),
you should also enable flatnode storage of node locations. With this you should also enable flatnode storage of node locations. With this
setting enabled, node coordinates are stored in a simple file instead setting enabled, node coordinates are stored in a simple file instead
@ -20,12 +27,11 @@ Add to your `settings/local.php`:
@define('CONST_Osm2pgsql_Flatnode_File', '/path/to/flatnode.file'); @define('CONST_Osm2pgsql_Flatnode_File', '/path/to/flatnode.file');
Replace the second part with a suitable path on your system and make sure Replace the second part with a suitable path on your system and make sure
the directory exists. There should be at least 35GB of free space. the directory exists. There should be at least 40GB of free space.
Downloading additional data # Downloading additional data
---------------------------
### Wikipedia rankings ## Wikipedia rankings
Wikipedia can be used as an optional auxiliary data source to help indicate Wikipedia can be used as an optional auxiliary data source to help indicate
the importance of osm features. Nominatim will work without this information the importance of osm features. Nominatim will work without this information
@ -43,7 +49,7 @@ size of nominatim. They also increase the install time by an hour or so.
the initial import of the data if you want the rankings applied to the the initial import of the data if you want the rankings applied to the
loaded data. loaded data.
### UK postcodes ## UK postcodes
Nominatim can use postcodes from an external source to improve searches that involve a UK postcode. This data can be optionally downloaded: Nominatim can use postcodes from an external source to improve searches that involve a UK postcode. This data can be optionally downloaded:
@ -51,48 +57,50 @@ Nominatim can use postcodes from an external source to improve searches that inv
wget https://www.nominatim.org/data/gb_postcode_data.sql.gz wget https://www.nominatim.org/data/gb_postcode_data.sql.gz
Initial import of the data # Initial import of the data
--------------------------
**Important:** first try the import with a small excerpt, for example from **Important:** first try the import with a small excerpt, for example from
[Geofabrik](https://download.geofabrik.de). [Geofabrik](https://download.geofabrik.de).
Download the data to import and load the data with the following command: Download the data to import and load the data with the following command:
./utils/setup.php --osm-file <your data file> --all [--osm2pgsql-cache 28000] 2>&1 | tee setup.log ```sh
./utils/setup.php --osm-file <data file> --all [--osm2pgsql-cache 28000] 2>&1 | tee setup.log
```
The `--osm2pgsql-cache` parameter is optional but strongly recommended for The `--osm2pgsql-cache` parameter is optional but strongly recommended for
planet imports. It sets the node cache size for the osm2pgsql import part 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 (see `-C` parameter in osm2pgsql help). As a rule of thumb, this should be
import, for excerpts you can use less. Adapt to your available RAM to about the same size as the file you are importing but never more than
avoid swapping, never give more than 2/3 of RAM to osm2pgsql. 2/3 of RAM available. If your machine starts swapping reduce the size.
Computing word frequency for search terms can improve the performance of Computing word frequency for search terms can improve the performance of
forward geocoding in particular under high load as it helps Postgres' query forward geocoding in particular under high load as it helps Postgres' query
planner to make the right decisions. To recompute word counts run: 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 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 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 performance becomes an issue. Just make sure that updates are stopped before
running this function. running this function.
Loading additional datasets 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:
The following commands will create additional entries for POI searches:
./utils/specialphrases.php --wiki-import > specialphrases.sql ./utils/specialphrases.php --wiki-import > specialphrases.sql
psql -d nominatim -f 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 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: instance by following these steps:
1. Install the GDAL library and python bindings and the unzip tool 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` * Ubuntu: `sudo apt-get install python-gdal unzip`
* CentOS: `sudo yum install gdal-python unzip` * CentOS: `sudo yum install gdal-python unzip`
2. Get the TIGER 2015 data. You will need the EDGES files 2. Get preprocessed TIGER 2015 data and unpack it into the
data directory in your Nominatim sources:
cd Nominatim/data
wget https://nominatim.org/data/tiger2017-nominatim-preprocessed.tar.gz
tar xf tiger2017-nominatim-preprocessed.tar.gz
3. Import the data into your Nominatim database:
./utils/setup.php --import-tiger-data
4. Enable use of the Tiger data in your `settings/local.php` by adding:
@define('CONST_Use_US_Tiger_Data', true);
5. Apply the new settings:
```sh
./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
```
The entire US adds about 10GB to your database.
You can also process the data from the original TIGER data to create the
SQL files, Nominatim needs for the import:
1. Get the TIGER 2017 data. You will need the EDGES files
(3,234 zip files, 11GB total). Choose one of the two sources: (3,234 zip files, 11GB total). Choose one of the two sources:
wget -r ftp://ftp2.census.gov/geo/tiger/TIGER2015/EDGES/ wget -r ftp://ftp2.census.gov/geo/tiger/TIGER2017/EDGES/
wget -r ftp://mirror1.shellbot.com/census/geo/tiger/TIGER2015/EDGES/ wget -r ftp://mirror1.shellbot.com/census/geo/tiger/TIGER2017/EDGES/
The first one is the original source, the second a considerably faster The first one is the original source, the second a considerably faster
mirror. mirror.
3. Convert the data into SQL statements (stored in data/tiger): 2. Convert the data into SQL statements:
./utils/imports.php --parse-tiger <tiger edge data directory> ./utils/imports.php --parse-tiger <tiger edge data directory>
4. Import the data into your Nominatim database: 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`.
./utils/setup.php --import-tiger-data # Updates
5. Enable use of the Tiger data in your `settings/local.php` by adding:
@define('CONST_Use_US_Tiger_Data', true);
6. Apply the new settings:
./utils/setup.php --create-functions --enable-diff-updates --create-partition-functions
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.
Updates
=======
There are many different possibilities to update your Nominatim database. There are many different possibilities to update your Nominatim database.
The following section describes how to keep it up-to-date with Pyosmium. 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`. 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 It is recommended to install Pyosmium via pip. Run (as the same user who
will later run the updates): 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 Nominatim needs a tool called `pyosmium-get-updates` that comes with
Pyosmium. You need to tell Nominatim where to find it. Add the 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. The path above is fine if you used the `--user` parameter with pip.
Replace `user` with your user name. 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 Next the update needs to be initialised. By default Nominatim is configured
to update using the global minutely diffs. 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 The --init-updates command needs to be rerun whenever the replication service
is changed. is changed.
Updating Nominatim ### Updating Nominatim
------------------
The following command will keep your database constantly up to date: The following command will keep your database constantly up to date:

View File

@ -1,20 +1,16 @@
Nominatim installation
======================
This page contains generic installation instructions for Nominatim and its This page contains generic installation instructions for Nominatim and its
prerequisites. There are also step-by-step instructions available for prerequisites. There are also step-by-step instructions available for
the following operating systems: the following operating systems:
* [Ubuntu 16.04](Install-on-Ubuntu-16.md) * [Ubuntu 16.04](../appendix/Install-on-Ubuntu-16.md)
* [CentOS 7.2](Install-on-Centos-7.md) * [CentOS 7.2](../appendix/Install-on-Centos-7.md)
These OS-specific instructions can also be found in executable form These OS-specific instructions can also be found in executable form
in the `vagrant/` directory. in the `vagrant/` directory.
Prerequisites # Prerequisites
-------------
### Software ## Software
For compiling: For compiling:
@ -23,8 +19,7 @@ For compiling:
* a recent C++ compiler * a recent C++ compiler
Nominatim comes with its own version of osm2pgsql. See the Nominatim comes with its own version of osm2pgsql. See the
[osm2pgsql README](../osm2pgsql/README.md) for additional dependencies osm2pgsql README for additional dependencies required for compiling osm2pgsql.
required for compiling osm2pgsql.
For running tests: For running tests:
@ -47,23 +42,22 @@ For running continuous updates:
* [pyosmium](http://osmcode.org/pyosmium/) * [pyosmium](http://osmcode.org/pyosmium/)
### Hardware ## Hardware
A minimum of 2GB of RAM is required or installation will fail. For a full 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. 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 For a full planet install you will need about 600GB of hard disk space (as of
June 2016, take into account that the OSM database is growing fast). SSD disks January 2017, take into account that the OSM database is growing fast). SSD disks
will help considerably to speed up import and queries. 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 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. 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 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 make best use of your hardware. You should tune the following parameters in
@ -90,13 +84,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 corruption. Autovacuum must not be switched off because it ensures that the
tables are frequently analysed. tables are frequently analysed.
### Webserver setup ## Webserver setup
The `website/` directory in the build directory contains the configured The `website/` directory in the build directory contains the configured
website. Include the directory into your webbrowser to serve php files website. Include the directory into your webbrowser to serve php files
from there. from there.
#### Configure for use with Apache ### Configure for use with Apache
Make sure your Apache configuration contains the required permissions for the Make sure your Apache configuration contains the required permissions for the
directory and create an alias: directory and create an alias:
@ -115,7 +109,7 @@ build directory.
After making changes in the apache config you need to restart apache. After making changes in the apache config you need to restart apache.
The website should now be available on http://localhost/nominatim. 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. Use php-fpm as a deamon for serving PHP cgi. Install php-fpm together with nginx.
@ -148,7 +142,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 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). Now continue with [importing the database](Import-and-Update.md).

66
docs/admin/Migration.md Normal file
View File

@ -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;
```

1
docs/index.md Normal file
View File

@ -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).

18
docs/mkdocs.yml Normal file
View File

@ -0,0 +1,18 @@
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'
markdown_extensions:
- codehilite:
use_pygments: False

View File

@ -19,18 +19,21 @@
# Now you can install all packages needed for Nominatim: # Now you can install all packages needed for Nominatim:
sudo yum install -y postgresql-server postgresql-contrib postgresql-devel postgis postgis-utils \ #DOCS: :::sh
sudo yum install -y postgresql-server postgresql-contrib postgresql-devel \
postgis postgis-utils \
git cmake make gcc gcc-c++ libtool policycoreutils-python \ git cmake make gcc gcc-c++ libtool policycoreutils-python \
php-pgsql php php-pear php-pear-DB php-intl libpqxx-devel proj-epsg \ php-pgsql php php-pear php-pear-DB php-intl libpqxx-devel \
bzip2-devel proj-devel geos-devel libxml2-devel boost-devel expat-devel zlib-devel proj-epsg bzip2-devel proj-devel libxml2-devel boost-devel \
expat-devel zlib-devel
# If you want to run the test suite, you need to install the following # If you want to run the test suite, you need to install the following
# additional packages: # additional packages:
sudo yum install -y python-pip python-Levenshtein python-psycopg2 \ #DOCS: :::sh
python-numpy php-phpunit-PHPUnit sudo yum install -y python34-pip python34-setuptools python34-devel \
pip install --user --upgrade pip setuptools lettuce==0.2.18 six==1.9 \ php-phpunit-PHPUnit
haversine Shapely pytidylib pip3 install --user behave nose pytidylib psycopg2
sudo pear install PHP_CodeSniffer sudo pear install PHP_CodeSniffer
# #
@ -77,7 +80,8 @@
# #
# Next tune the postgresql configuration, which is located in # Next tune the postgresql configuration, which is located in
# `/var/lib/pgsql/data/postgresql.conf`. See section *Postgres Tuning* in # `/var/lib/pgsql/data/postgresql.conf`. See section *Postgres Tuning* in
# [the installation page](Installation.md) for the parameters to change. # [the installation page](../admin/Installation.md#postgresql-tuning)
# for the parameters to change.
# #
# Now start the postgresql service after updating this config file. # Now start the postgresql service after updating this config file.
@ -99,7 +103,7 @@
# You need to create an alias to the website directory in your apache # You need to create an alias to the website directory in your apache
# configuration. Add a separate nominatim configuration to your webserver: # configuration. Add a separate nominatim configuration to your webserver:
#DOCS:``` #DOCS:```sh
sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF sudo tee /etc/httpd/conf.d/nominatim.conf << EOFAPACHECONF
<Directory "$USERHOME/build/website"> #DOCS:<Directory "$USERHOME/Nominatim/build/website"> <Directory "$USERHOME/build/website"> #DOCS:<Directory "$USERHOME/Nominatim/build/website">
Options FollowSymLinks MultiViews Options FollowSymLinks MultiViews
@ -141,12 +145,10 @@ sudo sed -i 's:#.*::' /etc/httpd/conf.d/nominatim.conf #DOCS:
# #
# Get the source code from Github and change into the source directory # Get the source code from Github and change into the source directory
# #
if [ "x$1" == "xyes" ]; then #DOCS: if [ "x$1" == "xyes" ]; then #DOCS: :::sh
cd $USERHOME cd $USERHOME
git clone --recursive git://github.com/openstreetmap/Nominatim.git git clone --recursive git://github.com/openstreetmap/Nominatim.git
cd Nominatim cd Nominatim
else #DOCS: else #DOCS:
cd $USERHOME/Nominatim #DOCS: cd $USERHOME/Nominatim #DOCS:
fi #DOCS: fi #DOCS:
@ -154,14 +156,14 @@ fi #DOCS:
# When installing the latest source from github, you also need to # When installing the latest source from github, you also need to
# download the country grid: # download the country grid:
if [ ! -f data/country_osm_grid.sql.gz ]; then #DOCS: if [ ! -f data/country_osm_grid.sql.gz ]; then #DOCS: :::sh
wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
fi #DOCS: fi #DOCS:
# The code must be built in a separate directory. Create this directory, # The code must be built in a separate directory. Create this directory,
# then configure and build Nominatim in there: # then configure and build Nominatim in there:
cd $USERHOME #DOCS: cd $USERHOME #DOCS: :::sh
mkdir build mkdir build
cd build cd build
cmake $USERHOME/Nominatim cmake $USERHOME/Nominatim
@ -170,7 +172,7 @@ fi #DOCS:
# You need to create a minimal configuration file that tells nominatim # You need to create a minimal configuration file that tells nominatim
# the name of your webserver user and the URL of the website: # the name of your webserver user and the URL of the website:
#DOCS:``` #DOCS:```sh
tee settings/local.php << EOF tee settings/local.php << EOF
<?php <?php
@define('CONST_Database_Web_User', 'apache'); @define('CONST_Database_Web_User', 'apache');
@ -180,4 +182,4 @@ EOF
# Nominatim is now ready to use. Continue with # Nominatim is now ready to use. Continue with
# [importing a database from OSM data](Import-and-Update.md). # [importing a database from OSM data](../admin/Import-and-Update.md).

View File

@ -18,6 +18,7 @@ export DEBIAN_FRONTEND=noninteractive #DOCS:
# Make sure all packages are are up-to-date by running: # Make sure all packages are are up-to-date by running:
# #
#DOCS: :::sh
sudo apt-get -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" --force-yes -fuy install grub-pc #DOCS: sudo apt-get -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" --force-yes -fuy install grub-pc #DOCS:
sudo apt-get update -qq sudo apt-get update -qq
@ -25,8 +26,9 @@ export DEBIAN_FRONTEND=noninteractive #DOCS:
sudo apt-get install -y build-essential cmake g++ libboost-dev libboost-system-dev \ sudo apt-get install -y build-essential cmake g++ libboost-dev libboost-system-dev \
libboost-filesystem-dev libexpat1-dev zlib1g-dev libxml2-dev\ libboost-filesystem-dev libexpat1-dev zlib1g-dev libxml2-dev\
libbz2-dev libpq-dev libgeos-dev libgeos++-dev libproj-dev \ libbz2-dev libpq-dev libproj-dev \
postgresql-server-dev-9.5 postgresql-9.5-postgis-2.2 postgresql-contrib-9.5 \ postgresql-server-dev-9.5 postgresql-9.5-postgis-2.2 \
postgresql-contrib-9.5 \
apache2 php php-pgsql libapache2-mod-php php-pear php-db \ apache2 php php-pgsql libapache2-mod-php php-pear php-db \
php-intl git php-intl git
@ -36,7 +38,7 @@ export DEBIAN_FRONTEND=noninteractive #DOCS:
sudo apt-get install -y python3-setuptools python3-dev python3-pip \ sudo apt-get install -y python3-setuptools python3-dev python3-pip \
python3-psycopg2 python3-tidylib phpunit php-cgi python3-psycopg2 python3-tidylib phpunit php-cgi
pip3 install --user behave nose # urllib3 pip3 install --user behave nose
sudo pear install PHP_CodeSniffer sudo pear install PHP_CodeSniffer
# #
@ -76,7 +78,8 @@ export DEBIAN_FRONTEND=noninteractive #DOCS:
# #
# Tune the postgresql configuration, which is located in # Tune the postgresql configuration, which is located in
# `/etc/postgresql/9.5/main/postgresql.conf`. See section *Postgres Tuning* in # `/etc/postgresql/9.5/main/postgresql.conf`. See section *Postgres Tuning* in
# [the installation page](Installation.md) for the parameters to change. # [the installation page](../admin/Installation.md#postgresql-tuning)
# for the parameters to change.
# #
# Restart the postgresql service after updating this config file. # Restart the postgresql service after updating this config file.
@ -98,7 +101,7 @@ export DEBIAN_FRONTEND=noninteractive #DOCS:
# You need to create an alias to the website directory in your apache # You need to create an alias to the website directory in your apache
# configuration. Add a separate nominatim configuration to your webserver: # configuration. Add a separate nominatim configuration to your webserver:
#DOCS:``` #DOCS:```sh
sudo tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF sudo tee /etc/apache2/conf-available/nominatim.conf << EOFAPACHECONF
<Directory "$USERHOME/build/website"> #DOCS:<Directory "$USERHOME/Nominatim/build/website"> <Directory "$USERHOME/build/website"> #DOCS:<Directory "$USERHOME/Nominatim/build/website">
Options FollowSymLinks MultiViews Options FollowSymLinks MultiViews
@ -129,12 +132,10 @@ sudo sed -i 's:#.*::' /etc/apache2/conf-available/nominatim.conf #DOCS:
# #
# Get the source code from Github and change into the source directory # Get the source code from Github and change into the source directory
# #
if [ "x$1" == "xyes" ]; then #DOCS: if [ "x$1" == "xyes" ]; then #DOCS: :::sh
cd $USERHOME cd $USERHOME
git clone --recursive git://github.com/openstreetmap/Nominatim.git git clone --recursive git://github.com/openstreetmap/Nominatim.git
cd Nominatim cd Nominatim
else #DOCS: else #DOCS:
cd $USERHOME/Nominatim #DOCS: cd $USERHOME/Nominatim #DOCS:
fi #DOCS: fi #DOCS:
@ -142,14 +143,14 @@ fi #DOCS:
# When installing the latest source from github, you also need to # When installing the latest source from github, you also need to
# download the country grid: # download the country grid:
if [ ! -f data/country_osm_grid.sql.gz ]; then #DOCS: if [ ! -f data/country_osm_grid.sql.gz ]; then #DOCS: :::sh
wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz
fi #DOCS: fi #DOCS:
# The code must be built in a separate directory. Create this directory, # The code must be built in a separate directory. Create this directory,
# then configure and build Nominatim in there: # then configure and build Nominatim in there:
cd $USERHOME #DOCS: cd $USERHOME #DOCS: :::sh
mkdir build mkdir build
cd build cd build
cmake $USERHOME/Nominatim cmake $USERHOME/Nominatim
@ -158,7 +159,7 @@ fi #DOCS:
# You need to create a minimal configuration file that tells nominatim # You need to create a minimal configuration file that tells nominatim
# where it is located on the webserver: # where it is located on the webserver:
#DOCS:``` #DOCS:```sh
tee settings/local.php << EOF tee settings/local.php << EOF
<?php <?php
@define('CONST_Website_BaseURL', '/nominatim/'); @define('CONST_Website_BaseURL', '/nominatim/');
@ -167,4 +168,4 @@ EOF
# Nominatim is now ready to use. Continue with # Nominatim is now ready to use. Continue with
# [importing a database from OSM data](Import-and-Update.md). # [importing a database from OSM data](../admin/Import-and-Update.md).