Changes between Initial Version and Version 1 of HowToRunMultipleGeonetworkInstancesUnderTomcat


Ignore:
Timestamp:
May 26, 2010, 5:26:48 PM (14 years ago)
Author:
avowkind
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HowToRunMultipleGeonetworkInstancesUnderTomcat

    v1 v1  
     1= How to run Multiple instances of Geonetwork in a single Tomcat server =
     2
     3== What is it you want to do? ==
     4When GN is installed it typically becomes available at the URL http://domain.etc:8080/geonetwork. If you want a second copy running you might start a second instance of tomcat on another port e.g. http://domain.etc:8090/geonetwork.  Instead I want to be able to run both copies in the same Tomcat server at different names rather than ports. e.g. http://domain.etc/geonetwork_test,  http://domain.etc/geonetwork  etc.
     5
     6== Why would you want to do this? ==
     71. You may wish to run several separate copies of Geonetwork for test and development purposes. e.g a dev, test and production version. Each instance can be started and stopped independently, can connect to different schemas on the database etc.
     8
     92. You may wish to run two separate portals for Geonetwork containing different collections of metadata from two organisations. You may wish to have separate branding and titles.
     10
     11== Summary of changes ==
     12 * set the application name in web.xml
     13 * set the application name in index.html
     14 * set the database
     15 * add the instance to tomcat server.xml
     16
     17These changes can be made in the original source code or after installation as a post install customisation. For the purposes of this how to I will assume the following :
     18 * Geonetwork is installed in /usr/local/geonetwork and is running as http://domain.etc/geonetwork
     19 * Tomcat is installed in /opt/tomcat
     20 * You want a second copy to be installed in /usr/local/geonetwork_test and available as http://domain.etc/geonetwork_test
     21 * you are using or can at least follow unix commands.
     22
     23== The Steps ==
     24=== Duplicate the installation ===
     25{{{
     26cd /usr/local
     27cp -r geonetwork geonetwork_test
     28}}}
     29
     30or you can run the installer a second time.
     31
     32=== Set the application name in web.xml ===
     33The display-name entry in the web app xml configuration file is used extensively though geonetwork as the base url for links and resources.
     34
     35 * edit web/geonetwork_test/WEB-INF/web.xml
     36 * replace <display-name>geonetwork</display-name> with <display-name>geonetwork_test</display-name> at about line 4
     37 * replace /geonetwork/  with /geonetwork_test/ in the parameters section further down.
     38{{{
     39    <param-name>urls-to-expire-forward</param-name>
     40    <param-value>/geonetwork/scripts,/geonetwork/images,/geonetwork/loc</param-value>
     41}}}
     42 
     43For those who like regular expressions the following sed script makes these two changes:
     44{{{
     45$NAME = geonetwork_test
     46sed -e "s/\(<display-name>\).*\(<\/display-name>\)/\1$NAME\2/"  -e "s/\(<param-value>\/\).*\(\/scripts,\/\).*\(\/images,\/\).*\(\/loc<\/param-value>\)/\1$NAME\2$NAME\3$NAME\4/" web/geonetwork/WEB-INF/web.xml
     47}}} 
     48
     49=== Set the application name in index.html ===
     50The root folder index.html file ensures that links to http://domain.etc/geonetwork are redirected to http://domain.etc/geonetwork/srv/en/main.home
     51 * edit web/geonetwork_test/index.html
     52 * replace the line with window.location=geonetwork... with the new path
     53
     54{{{
     55$NAME = geonetwork_test
     56sed -e "s/\(window.location=\"\/\).*\(\/srv\/en\/main.home\)/\1$NAME\2/" $NAME/web/geonetwork/index.html
     57}}} 
     58
     59=== Set the database ===
     60Run bin/gast.sh and setup the database so that it uses a different database name. You can then use gast to initialise the new database.
     61Alternatively directly edit the file /web/geonetwork/WEB-INF/config.xml.  Look for the <resources>  <resource enabled="true"> element to change the database settings.
     62
     63=== add the instance to tomcat server.xml ===
     64There are a couple of  ways to add services to the tomcat server, you can add separate host server.xml files into folders or you can add Context lines to the main server.xml file.  This how to assumes the latter.
     65
     66Add or modify the following code to the file /opt/tomcat/current/conf/server.xml. I'm assuming that both geonetwork services will share the same intermap and geoserver.
     67{{{
     68<!-- Define the default virtual host  -->
     69  <Host name="localhost"  appBase="webapps"  unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
     70    <!-- Metadata Catalog - supporting services -->
     71    <Context path="/intermap" docBase="/usr/local/geonetwork/geonetwork/web/intermap" crossContext="false"  reloadable ="false" />
     72    <Context path="/geoserver" docBase="/usr/local/geonetwork/web/geoserver" crossContext="false"  reloadable ="false" />
     73   
     74    <!-- Metadata Catalog geonetwork -->
     75    <Context path="/geonetwork"      docBase="/usr/local/geonetwork/web/geonetwork" crossContext="false" reloadable="false" />
     76    <Context path="/geonetwork_test" docBase="/usr/local/geonetwork_test/web/geonetwork" crossContext="false" reloadable="false" />
     77  </Host>
     78}}}
     79
     80== Branding the different versions ==
     81For me the simplest way to brand the versions was to add an H1 title to the banner that shows the values of the administrative setting for name and organisation.
     82
     83in web/geonetwork/xsl/banner.xsl
     84{{{
     85 <tr class="banner">
     86   <td class="banner">
     87       <h1 id="logo"><span><xsl:value-of select="//site/organization"/> - <xsl:value-of select="//site/name"/></span></h1>
     88   </td>
     89 </tr>
     90}}}
     91
     92
     93,,Andrew Watkins is Systems Development Team Manager at the National Institute of Water and Atmospheric Research (NIWA) in New Zealand,,