Nominatim Server Setup

visiondrive5 years ago

I have a Nominatim server working fine that Anton configured for me but I would like to set one up for myself.

Why you ask?

Lets just say that as an Engineer is pains me when I try to get things working and cannot - I have spent the good part of nearly two days following the various sites with zero success and as linux is not high in my skill set I am seeking some help/mentoring.

If you have what it takes to help me out step by step I am more than happy to pay for your time.

Like I said above - I already have one working but I want to set one up on my own so I know how it all works config wise and learn some linux on the way.

Anyone interested?

Diego Marchesini5 years ago
Open Cart5 years ago

Hello
Please contact me [removed]
I can help you out.

visiondrive5 years ago

My issue is with server config - I have it working on Ubuntu with a very small db (Fiji) but cannot import larger DB without the import process failing due to lack of memory even when using reverse geocoding only option.

Any pointers on correct config for low memory system?

Open Cart I emailed you but never heard back.

visiondrive5 years ago

I got this sorted and have successfully built two nominatim servers each on Ubuntu with no problems. I have kept my instructions and notes so if anyone needs help let me know.

jay5 years ago

Visiondrive...can you send me instruction how to build a nominatim server. Thank u in advance

Enrique Luis 5 years ago

Hello visiondrive.
How i can reach you to get the instructions. I has been struggling with this problem for a couple of week. Very grateful for any help. Best regards. Enrique

visiondrive5 years ago

My issue was that the VPS's I was using had very limited RAM but you can work around using a swap file as per notes below - I ended up installing UBUNTU in a VM on a windows server in Virtual Box and assigning it more cpu and ram than it needed to make it all work for the data processing and then lowered it back afterwards. TRACCAR runs on the same server so the reverse lookup is all on the same machine.

Here are my swap notes if needed.

root@vps258452:~# sudo fallocate -l 2G /swapfile

root@vps258452:~# sudo chmod 600 /swapfile

root@vps258452:~# sudo mkswap /swapfile

Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=e833239f-edfc-460c-9114-141ee600fa40

root@vps258452:~# sudo swapon -a

sudo swapon /swapfile

Now onto NOMINATIM...

NOMINATIM UBUNTU INSTALLATION 17 SEPT 2019

Create username during setup - fresh install of UBUNTU

username
password

Install TELNET if you prefer to use rather than terminal access via VM login - I was using a VM

https://www.howtoforge.com/how-to-install-and-use-telnet-on-ubuntu-1804/

Note root has no password defined - so sudo passwd root

sudo apt update

sudo apt upgrade

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 libproj-dev \
                        postgresql-server-dev-10 postgresql-10-postgis-2.4 \
                        postgresql-contrib-10 postgresql-10-postgis-scripts \
                        apache2 php php-pgsql libapache2-mod-php \
                        php-intl git

sudo useradd -d /srv/nominatim -s /bin/bash -m nominatim

passwd nominatim
(set password)

usermod -aG sudo nominatim

(add nominatim to sudo list)


su - nominatim

(login)


export USERNAME=nominatim


export USERHOME=/srv/nominatim


chmod a+x $USERHOME


sudo systemctl restart postgresql


sudo -u postgres createuser -s $USERNAME


sudo -u postgres createuser www-data

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

sudo a2enconf nominatim

sudo systemctl restart apache2

cd $USERHOME
git clone --recursive git://github.com/openstreetmap/Nominatim.git
cd Nominatim

wget -O data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz

mkdir build
cd build
cmake $USERHOME/Nominatim
make

tee settings/local.php << EOF
<?php
 @define('CONST_Website_BaseURL', '/nominatim/');
EOF


(Stay in build dir)

wget http://download.geofabrik.de/australia-oceania/australia-latest.osm.pbf

./utils/setup.php --osm-file australia-latest.osm.pbf  --all --reverse-only   2>&1 | tee setup.log



2019-09-15 23:00:20 == WARNING: resetting threads to 1
2019-09-15 23:00:20 == module path: /srv/nominatim/Nominatim/build/module
2019-09-15 23:00:20 == Create DB
2019-09-15 23:00:32 == Setup DB
Postgres version found: 9.05
Postgis version found: 2.2
2019-09-15 23:02:09 == WARNING: optional external GB postcode table file (/srv/nominatim/Nominatim/data/gb_postcode_data.sql.gz) not found. Skipping.
2019-09-15 23:02:09 == WARNING: optional external US postcode table file (/srv/nominatim/Nominatim/data/us_postcode_data.sql.gz) not found. Skipping.
2019-09-15 23:02:09 == Import data
osm2pgsql version 0.96.0 (64 bit id space)

Allocating memory for dense node cache
Allocating dense node cache in one big chunk
Allocating memory for sparse node cache
Sharing dense sparse
Node-cache: cache=256MB, maxblocks=4096*65536, allocation method=11
Mid: pgsql, cache=256
Setting up table: planet_osm_nodes
Setting up table: planet_osm_ways
Setting up table: planet_osm_rels
Parsing gazetteer style file '/srv/nominatim/Nominatim/settings/import-full.style'.
Using projection SRS 4326 (Latlong)
NOTICE:  table "place" does not exist, skipping

Reading in file: /srv/nominatim/Nominatim/build/australia-latest.osm.pbf
Using PBF parser.’

THIS WILL TAKE SOME TIME…..many many hours depending on data size

If the process fails you need to delete the database and start the import again.

Here are my notes

Login as nominatim

nominatim@vps258452:~/Nominatim/build$ psql

psql (10.10 (Ubuntu 10.10-0ubuntu0.18.04.1))


nominatim=#

nominatim=# \c postgres

You are now connected to database "postgres" as user "nominatim”.

postgres=# drop database nominatim;

DROP DATABASE
postgres-# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)

postgres-# \q                                                       

Notes:

systemctl start postgresql 
systemctl stop postgresql 
systemctl restart postgresql 
jay5 years ago

Thank you. Im in south africa...how do I download SA maps

visiondrive5 years ago

Jay you can find the files at this link - the australian files were linked above in my example as this is what I used.

http://download.geofabrik.de

jay5 years ago

Thank will give it a shot..thank you sir

Enrique Luis 5 years ago

visiondrive
Thank you very much. I really apreciate the help.

jaya year ago

does anybody have an update instruction on setting up this nominatim server

Anton Tananaeva year ago
jaya year ago

Will a 4gig memory on a vps server be sufficient to run this.