]> git.openstreetmap.org Git - nominatim.git/blob - docs/admin/Installation.md
doc: clarify the influence of autovacuum on memory
[nominatim.git] / docs / admin / Installation.md
1 # Basic Installation
2
3 This page contains generic installation instructions for Nominatim and its
4 prerequisites. There are also step-by-step instructions available for
5 the following operating systems:
6
7   * [Ubuntu 18.04](../appendix/Install-on-Ubuntu-18.md)
8   * [Ubuntu 16.04](../appendix/Install-on-Ubuntu-16.md)
9   * [CentOS 7.2](../appendix/Install-on-Centos-7.md)
10
11 These OS-specific instructions can also be found in executable form
12 in the `vagrant/` directory.
13
14 Users have created instructions for other frameworks. We haven't tested those
15 and can't offer support.
16
17   * [Docker](https://github.com/mediagis/nominatim-docker)
18   * [Docker on Kubernetes](https://github.com/peter-evans/nominatim-k8s)
19   * [Ansible](https://github.com/synthesio/infra-ansible-nominatim)
20
21 ## Prerequisites
22
23 ### Software
24
25 For compiling:
26
27   * [cmake](https://cmake.org/)
28   * [libxml2](http://xmlsoft.org/)
29   * a recent C++ compiler (gcc 5+ or Clang 3.8+)
30
31 Nominatim comes with its own version of osm2pgsql. See the
32 [osm2pgsql README](https://github.com/openstreetmap/osm2pgsql/blob/master/README.md#building)
33 for additional dependencies required for compiling osm2pgsql.
34
35 For running tests:
36
37   * [behave](http://pythonhosted.org/behave/)
38   * [Psycopg2](https://initd.org/psycopg)
39   * [nose](https://nose.readthedocs.io)
40   * [phpunit](https://phpunit.de)
41
42 For running Nominatim:
43
44   * [PostgreSQL](https://www.postgresql.org) (9.3 or later)
45   * [PostGIS](https://postgis.org) (2.2 or later)
46   * [PHP](https://php.net) (7.0 or later)
47   * PHP-pgsql
48   * PHP-intl (bundled with PHP)
49   * a webserver (apache or nginx are recommended)
50
51 For running continuous updates:
52
53   * [pyosmium](https://osmcode.org/pyosmium/) (with Python 3)
54
55 ### Hardware
56
57 A minimum of 2GB of RAM is required or installation will fail. For a full
58 planet import 64GB of RAM or more are strongly recommended. Do not report
59 out of memory problems if you have less than 64GB RAM.
60
61 For a full planet install you will need at least 800GB of hard disk space
62 (take into account that the OSM database is growing fast). SSD disks
63 will help considerably to speed up import and queries.
64
65 Even on a well configured machine the import of a full planet takes
66 at least 2 days. Without SSDs 7-8 days are more realistic.
67
68 ## Setup of the server
69
70 ### PostgreSQL tuning
71
72 You might want to tune your PostgreSQL installation so that the later steps
73 make best use of your hardware. You should tune the following parameters in
74 your `postgresql.conf` file.
75
76     shared_buffers = 2GB
77     maintenance_work_mem = (10GB)
78     autovacuum_work_mem = 2GB
79     work_mem = (50MB)
80     effective_cache_size = (24GB)
81     synchronous_commit = off
82     checkpoint_segments = 100 # only for postgresql <= 9.4
83     max_wal_size = 1GB # postgresql > 9.4
84     checkpoint_timeout = 10min
85     checkpoint_completion_target = 0.9
86
87 The numbers in brackets behind some parameters seem to work fine for
88 64GB RAM machine. Adjust to your setup. A higher number for `max_wal_size`
89 means that PostgreSQL needs to run checkpoints less often but it does require
90 the additional space on your disk.
91
92 Autovacuum must not be switched off because it ensures that the
93 tables are frequently analysed. If your machine has very little memory,
94 you might consider setting:
95
96     autovacuum_max_workers = 1
97
98 and even reduce `autovacuum_work_mem` further. This will reduce the amount
99 of memory that autovacuum takes away from the import process.
100
101 For the initial import, you should also set:
102
103     fsync = off
104     full_page_writes = off
105
106 Don't forget to reenable them after the initial import or you risk database
107 corruption.
108
109
110 ### Webserver setup
111
112 The `website/` directory in the build directory contains the configured
113 website. Include the directory into your webbrowser to serve php files
114 from there.
115
116 #### Configure for use with Apache
117
118 Make sure your Apache configuration contains the required permissions for the
119 directory and create an alias:
120
121     <Directory "/srv/nominatim/build/website">
122       Options FollowSymLinks MultiViews
123       AddType text/html   .php
124       DirectoryIndex search.php
125       Require all granted
126     </Directory>
127     Alias /nominatim /srv/nominatim/build/website
128
129 `/srv/nominatim/build` should be replaced with the location of your
130 build directory.
131
132 After making changes in the apache config you need to restart apache.
133 The website should now be available on http://localhost/nominatim.
134
135 #### Configure for use with Nginx
136
137 Use php-fpm as a deamon for serving PHP cgi. Install php-fpm together with nginx.
138
139 By default php listens on a network socket. If you want it to listen to a
140 Unix socket instead, change the pool configuration (`pool.d/www.conf`) as
141 follows:
142
143     ; Comment out the tcp listener and add the unix socket
144     ;listen = 127.0.0.1:9000
145     listen = /var/run/php5-fpm.sock
146
147     ; Ensure that the daemon runs as the correct user
148     listen.owner = www-data
149     listen.group = www-data
150     listen.mode = 0666
151
152 Tell nginx that php files are special and to fastcgi_pass to the php-fpm
153 unix socket by adding the location definition to the default configuration.
154
155     root /srv/nominatim/build/website;
156     index search.php index.html;
157     location ~ [^/]\.php(/|$) {
158         fastcgi_split_path_info ^(.+?\.php)(/.*)$;
159         if (!-f $document_root$fastcgi_script_name) {
160             return 404;
161         }
162         fastcgi_pass unix:/var/run/php5-fpm.sock;
163         fastcgi_index search.php;
164         include fastcgi.conf;
165     }
166
167 Restart the nginx and php5-fpm services and the website should now be available
168 at `http://localhost/`.
169
170
171 Now continue with [importing the database](Import-and-Update.md).