]> git.openstreetmap.org Git - nominatim.git/blob - docs/admin/Advanced-Installations.md
switch documentation to describing dotenv
[nominatim.git] / docs / admin / Advanced-Installations.md
1 # Advanced installations
2
3 This page contains instructions for setting up multiple countries in 
4 your Nominatim database. It is assumed that you have already successfully
5 installed the Nominatim software itself, if not return to the 
6 [installation page](Installation.md).
7
8 ## Importing multiple regions
9
10 To import multiple regions in your database, you need to configure and run `utils/import_multiple_regions.sh` file. This script will set up the update directory which has the following structure:
11
12 ```bash
13 update
14     ├── europe
15     │   ├── andorra
16     │   │   └── sequence.state
17     │   └── monaco
18     │       └── sequence.state
19     └── tmp
20         ├── combined.osm.pbf
21         └── europe
22                 ├── andorra-latest.osm.pbf
23                 └── monaco-latest.osm.pbf
24
25
26 ```
27
28 The `sequence.state` files will contain the sequence ID, which will be used by pyosmium to get updates. The tmp folder is used for import dump.
29
30 ### Configuring multiple regions
31
32 The file `import_multiple_regions.sh` needs to be edited as per your requirement:
33
34 1. List of countries. eg:
35
36         COUNTRIES="europe/monaco europe/andorra"
37
38 2. Path to Build directory. eg:
39
40         NOMINATIMBUILD="/srv/nominatim/build"
41
42 3. Path to Update directory. eg:
43         
44         UPDATEDIR="/srv/nominatim/update"
45
46 4. Replication URL. eg:
47     
48         BASEURL="https://download.geofabrik.de"
49         DOWNCOUNTRYPOSTFIX="-latest.osm.pbf"
50  
51 !!! tip
52     If your database already exists and you want to add more countries, replace the setting up part
53     `${SETUPFILE} --osm-file ${UPDATEDIR}/tmp/combined.osm.pbf --all 2>&1`
54     with `${UPDATEFILE} --import-file ${UPDATEDIR}/tmp/combined.osm.pbf --index --index-instances N 2>&1`
55     where N is the numbers of CPUs in your system.
56
57 ### Setting up multiple regions
58
59 Run the following command from your Nominatim directory after configuring the file.
60
61     bash ./utils/import_multiple_regions.sh
62
63 !!! danger "Important"
64         This file uses osmium-tool. It must be installed before executing the import script.
65         Installation instructions can be found [here](https://osmcode.org/osmium-tool/manual.html#installation).
66
67 ### Updating multiple regions
68
69 To import multiple regions in your database, you need to configure and run ```utils/update_database.sh```.
70 This uses the update directory set up while setting up the DB.   
71
72 ### Configuring multiple regions
73
74 The file `update_database.sh` needs to be edited as per your requirement:
75
76 1. List of countries. eg:
77
78         COUNTRIES="europe/monaco europe/andorra"
79
80 2. Path to Build directory. eg:
81
82         NOMINATIMBUILD="/srv/nominatim/build"
83
84 3. Path to Update directory. eg:
85         
86         UPDATEDIR="/srv/nominatim/update"
87
88 4. Replication URL. eg:
89     
90         BASEURL="https://download.geofabrik.de"
91         DOWNCOUNTRYPOSTFIX="-updates"
92
93 5. Followup can be set according to your installation. eg: For Photon,
94
95         FOLLOWUP="curl http://localhost:2322/nominatim-update"
96
97     will handle the indexing.
98
99 ### Updating the database
100
101 Run the following command from your Nominatim directory after configuring the file.
102
103     bash ./utils/update_database.sh
104
105 This will get diffs from the replication server, import diffs and index the database. The default replication server in the script([Geofabrik](https://download.geofabrik.de)) provides daily updates.
106
107 ## Importing Nominatim to an external PostgreSQL database
108
109 You can install Nominatim using a database that runs on a different server when
110 you have physical access to the file system on the other server. Nominatim
111 uses a custom normalization library that needs to be made accessible to the
112 PostgreSQL server. This section explains how to set up the normalization
113 library.
114
115 ### Option 1: Compiling the library on the database server
116
117 The most sure way to get a working library is to compile it on the database
118 server. From the prerequisites you need at least cmake, gcc and the
119 PostgreSQL server package.
120
121 Clone or unpack the Nominatim source code, enter the source directory and
122 create and enter a build directory.
123
124 ```sh
125 cd Nominatim
126 mkdir build
127 cd build
128 ```
129
130 Now configure cmake to only build the PostgreSQL module and build it:
131
132 ```
133 cmake -DBUILD_IMPORTER=off -DBUILD_API=off -DBUILD_TESTS=off -DBUILD_DOCS=off -DBUILD_OSM2PGSQL=off ..
134 make
135 ```
136
137 When done, you find the normalization library in `build/module/nominatim.so`.
138 Copy it to a place where it is readable and executable by the PostgreSQL server
139 process.
140
141 ### Option 2: Compiling the library on the import machine
142
143 You can also compile the normalization library on the machine from where you
144 run the import.
145
146 !!! important
147     You can only do this when the database server and the import machine have
148     the same architecture and run the same version of Linux. Otherwise there is
149     no guarantee that the compiled library is compatible with the PostgreSQL
150     server running on the database server.
151
152 Make sure that the PostgreSQL server package is installed on the machine
153 **with the same version as on the database server**. You do not need to install
154 the PostgreSQL server itself.
155
156 Download and compile Nominatim as per standard instructions. Once done, you find
157 the nomrmalization library in `build/module/nominatim.so`. Copy the file to
158 the database server at a location where it is readable and executable by the
159 PostgreSQL server process.
160
161 ### Running the import
162
163 On the client side you now need to configure the import to point to the
164 correct location of the library **on the database server**. Add the following
165 line to your your `.env` file:
166
167 ```php
168 NOMINATIM_DATABASE_MODULE_PATH="<directory on the database server where nominatim.so resides>"
169 ```
170
171 Now change the `NOMINATIM_DATABASE_DSN` to point to your remote server and continue
172 to follow the [standard instructions for importing](/admin/Import).