1 # Advanced installations
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).
8 ## Importing multiple regions
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:
16 │ │ └── sequence.state
22 ├── andorra-latest.osm.pbf
23 └── monaco-latest.osm.pbf
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.
30 ### Configuring multiple regions
32 The file `import_multiple_regions.sh` needs to be edited as per your requirement:
34 1. List of countries. eg:
36 COUNTRIES="europe/monaco europe/andorra"
38 2. Path to Build directory. eg:
40 NOMINATIMBUILD="/srv/nominatim/build"
42 3. Path to Update directory. eg:
44 UPDATEDIR="/srv/nominatim/update"
46 4. Replication URL. eg:
48 BASEURL="https://download.geofabrik.de"
49 DOWNCOUNTRYPOSTFIX="-latest.osm.pbf"
51 ### Setting up multiple regions
54 If your database already exists and you want to add more countries,
55 replace the setting up part
56 `${SETUPFILE} --osm-file ${UPDATEDIR}/tmp/combined.osm.pbf --all 2>&1`
57 with `${UPDATEFILE} --import-file ${UPDATEDIR}/tmp/combined.osm.pbf --index --index-instances N 2>&1`
58 where N is the numbers of CPUs in your system.
60 Run the following command from your Nominatim directory after configuring the file.
62 bash ./utils/import_multiple_regions.sh
64 !!! danger "Important"
65 This file uses osmium-tool. It must be installed before executing the import script.
66 Installation instructions can be found [here](https://osmcode.org/osmium-tool/manual.html#installation).
68 ### Updating multiple regions
70 To import multiple regions in your database, you need to configure and run ```utils/update_database.sh```.
71 This uses the update directory set up while setting up the DB.
73 ### Configuring multiple regions
75 The file `update_database.sh` needs to be edited as per your requirement:
77 1. List of countries. eg:
79 COUNTRIES="europe/monaco europe/andorra"
81 2. Path to Build directory. eg:
83 NOMINATIMBUILD="/srv/nominatim/build"
85 3. Path to Update directory. eg:
87 UPDATEDIR="/srv/nominatim/update"
89 4. Replication URL. eg:
91 BASEURL="https://download.geofabrik.de"
92 DOWNCOUNTRYPOSTFIX="-updates"
94 5. Followup can be set according to your installation. eg: For Photon,
96 FOLLOWUP="curl http://localhost:2322/nominatim-update"
98 will handle the indexing.
100 ### Updating the database
102 Run the following command from your Nominatim directory after configuring the file.
104 bash ./utils/update_database.sh
106 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.
108 ## Importing Nominatim to an external PostgreSQL database
110 You can install Nominatim using a database that runs on a different server when
111 you have physical access to the file system on the other server. Nominatim
112 uses a custom normalization library that needs to be made accessible to the
113 PostgreSQL server. This section explains how to set up the normalization
116 ### Option 1: Compiling the library on the database server
118 The most sure way to get a working library is to compile it on the database
119 server. From the prerequisites you need at least cmake, gcc and the
120 PostgreSQL server package.
122 Clone or unpack the Nominatim source code, enter the source directory and
123 create and enter a build directory.
131 Now configure cmake to only build the PostgreSQL module and build it:
134 cmake -DBUILD_IMPORTER=off -DBUILD_API=off -DBUILD_TESTS=off -DBUILD_DOCS=off -DBUILD_OSM2PGSQL=off ..
138 When done, you find the normalization library in `build/module/nominatim.so`.
139 Copy it to a place where it is readable and executable by the PostgreSQL server
142 ### Option 2: Compiling the library on the import machine
144 You can also compile the normalization library on the machine from where you
148 You can only do this when the database server and the import machine have
149 the same architecture and run the same version of Linux. Otherwise there is
150 no guarantee that the compiled library is compatible with the PostgreSQL
151 server running on the database server.
153 Make sure that the PostgreSQL server package is installed on the machine
154 **with the same version as on the database server**. You do not need to install
155 the PostgreSQL server itself.
157 Download and compile Nominatim as per standard instructions. Once done, you find
158 the normalization library in `build/module/nominatim.so`. Copy the file to
159 the database server at a location where it is readable and executable by the
160 PostgreSQL server process.
162 ### Running the import
164 On the client side you now need to configure the import to point to the
165 correct location of the library **on the database server**. Add the following
166 line to your your `.env` file:
169 NOMINATIM_DATABASE_MODULE_PATH="<directory on the database server where nominatim.so resides>"
172 Now change the `NOMINATIM_DATABASE_DSN` to point to your remote server and continue
173 to follow the [standard instructions for importing](/admin/Import).