GeoNetwork installation on Ubuntu 14.04 LTS server

Installing GeoNetwork

There are different ways to set up a GeoNetwork metadata catalogue. The project comes with a platform independet installer (.jar) which can be used on Windows, Linux and Mac OS X platforms as well. It should install GeoNetwork and Geoserver, uses Jetty as servlet container and h2 as database (though another database can be configured).

There is also the option to use the .war archive with the h2 database. In case you come here frustrated by this approach: the most common problem seems to be, that the default h2 database location /var/lib/tomcat7 is not writable by the tomcat user and therefore the location has to be changed to a writable location as described for GeoNetwork 2.x for example here).

The following guide describes how to set up GeoNetwork without Geoserver on an Ubuntu 14.04 LTS server with Tomcat7 and a PostgreSQL database.

System Ressources

The minimum specs are lower but - trust me - together with Tomcat and Postgresql you really want to have at least 2 cores and 2 GB of ram.

OpenJDK 7

Though the GeoNetwork installation guide still states "JRE 1.6.0" - in times of Java8 - you don't want to do go with the outdated 1.6 version. At the time of writing OpenJDK7 is the default version in the repository and to my experience/knowledge it works just as well as Oracle/SUN Java:

sudo apt-get install openjdk-7-jre-headless

Tomcat 7

Install Tomcat with:

sudo apt-get install tomcat7 tomcat7-admin

Now you should configure the users - removing the default ones and add the ones you need. To be more specific: we need a role with "manager-gui" and a user with this role to be able to use the manager gui.

sudo vi /var/lib/tomcat7/conf/tomcat-users.xml

            <tomcat-users>
              <role rolename="manager-gui"/>
              <user username="youUserName" password="yourPassword" roles="manager-gui"/>
            </tomcat-users>

Now we can use elinks to download the .war archive from:

https://sourceforge.net/projects/geonetwork/files/GeoNetwork_opensource/

Opening the tomcat manager gui in a browser we can easily deploy the .war file.
To get a better performance for your application you should grant Tomcat more ressources:

sudo vi /etc/default/tomcat7

in JAVA_OPTS you should

  • set a higher value for the maximum heap size (xmx) for example -Xmx1024m instead of the initial 128.
  • Also you should add the initial heap size parameter (xms) and set it's value to the same one as xsx, e.g. -Xms1024m

Next you can set a higher value for maxThreads. A rule of thumb is to set the value x200 times the number of cores:

sudo vi /etc/tomcat7/server.xml

Add to the <connector> for a server with two cores:

maxThreads="400"

PostgreSQL

As database we choose PostgreSQL which can be used for a bunch of other GIS applications as well.

sudo apt-get install postgresql postgis*

In Ubuntu 14.04: Don't forget the asterisk after postgis - otherwise you will miss some postgis packages. For other distros this might not be necessary.

After installation check the services if postgreSQL is up an running:

service postgresql status

Now start your database session with psql:

sudo -u postgres psql

and set a new password:

\password postgres

leave psql with

\q

Now about the configuration:

sudo vi /etc/postgresql/9.3/main/postgresql.conf

search for shared buffers:

/shared_buffers

and set a higher value (e.g. 512 or 1024). Here is also the location where you set the listen_addresses of your database. I really would advise you to keep the setting "localhost" if your server is available on the internet.

Anyways - after setting shared_buffers restart PostgreSQL:

sudo service postgresql restart

Now let's configure the authentication settings:

sudo vi /etc/postgresql/9.3/main/pg_hba.conf

You have to allow login with encrypted password by generating a local "md5" entry (the database will be only accessible from the server with the local setting).

You can either change the line

local  all all peer

to

local  all all md5

Or add a new line in the end of the file where you explicitly specify your database and user, e.g.

local  geonetwork  geonetwork  md5

"geonetwork" because for this howto I used geonetwork as database user and database name - but feel free to pick something more suiitable

Details about the pg_hba.conf are explained here

Afterwards let's reconnect with psql to PostgreSQL to create a new database for GeoNetwork:

sudo su postgres
psql
CREATE USER geonetwork WITH PASSWORD 'yourPassword';
CREATE DATABASE geonetwork WITH OWNER = geonetwork ENCODING 'UTF8';
\q
psql -d geonetwork -c "CREATE EXTENSION postgis;"
psql -d geonetwork -c "CREATE EXTENSION postgis_topology;"

Tomcat Configuration

Now let's connect the newly created database!

Configuration for GeoNetwork 2.x

sudo vi /var/lib/tomcat7/webapps/geonetwork/WEB-INF/config.xml

Here we have to disable the default h2 database container by setting it to: enabled="false".

Also we have to add a new ressource for our PostgreSQL database:

            <resource enabled="true">
                    <name>main-db</name>
                    <provider>jeeves.resources.dbms.ApacheDBCPool</provider>
                    <config>
                            <user>geonetwork</user>
                            <password>yourPassword</password>
                            <driver>org.postgis.DriverWrapper</driver>
                            <url>jdbc:postgresql_postGIS://localhost:5432/geonetwork</url>
                            <poolSize>10</poolSize>
                            <validationQuery>SELECT 1</validationQuery>
                    </config>
            </resource>

More information can be found here.

Configuration for GeoNetwork 3.x

As Ernest Chiarello pointed out the configuration file has been split up since GeoNetwork 3.0. (Many thanks Ernest!) Here is his description of the new configuration settings.

In the srv.xml file the database resource has to be set to postgres.xml and the h2 option commented out.

sudo vi /var/lib/tomcat7/webapps/geonetwork/WEB-INF/config-node/srv.xml

<import resource="../config-db/postgres.xml"/>

If you are running the postgresql database on a different port you also might want to have a look at the postgres.xml file.

sudo vi /var/lib/tomcat7/webapps/geonetwork/WEB-INF/config-db/postgres.xml

<constructor-arg value="jdbc:postgresql://${jdbc.host}:5432/${jdbc.database}"/>

The configuration of your connection settings is done in the jdbc.properties files:

sudo vi /var/lib/tomcat7/webapps/geonetwork/WEB-INF/config-db/jdbc.properties

jdbc.username=geonetwork
jdbc.password=yourPassword
jdbc.database=geonetwork
jdbc.host=localhost
Hello Stacktrace

Now your GeoNetwork should be ready to go - so lets start it from Tomcats manager gui and afterwards check:

http://yourIP:8080/geonetwork/

Otherwise the stacktrace displayed hopefully gives you some good pointers where to look :) But don't worry: this is GeoNetworks way to communicate with you.

GeoNetwork Konfiguration

GeoNetwork gives you rich possiblities for configuration. Some of them should be set right from the beginning:

Login as admin (password admin) to GeoNetwork:

Automatic CSW insert transaction

Have a look at this how-to in case you are interested in inserting metadata records via the CSW interface using a Python script.

Server Security

You might also be interested in my (unfortunately not completed) guide about hardening your Ubuntu Server.

Feedback

I'm really happy about feedback! In case you got suggestions how to improve this guide, just let me know: ed.rutkafunamnetadoeg@tkatnok