Alert.png The wiki is deprecated and due to be decommissioned by the end of September 2022.
The content is being migrated to other supports, new updates will be ignored and lost.
If needed you can get in touch with EGI SDIS team using operations @

GOCDB/Regional Module Technical Documentation

From EGIWiki
Revision as of 13:54, 17 December 2013 by Jamesm (talk | contribs) (→‎Deployment)
Jump to navigation Jump to search
Main operations services Support Documentation Tools Activities Performance Technology Catch-all Services Resource Allocation Security

GOC DB menu: Home Documentation Index

This page is the main install documentation for GOCDB Version 5 



svn co
  • Latest dev/trunk svn:
svn checkout 

Note, for svn co, if you are asked to authenticate with a client certificate as below, you can dismiss by pressing Enter

Authentication realm:
Client certificate filename: <ENTER to dismiss>

OLD v4.4 Install doc has been relocated


System prerequisites

GOCDB-5 has two components: a database and a web front end. Both components can work on the same machine but it is very likely that in most environments they will be separated. This is what we would advise. Machine requirements for these 2 components are described below.


Version 5 of GocDB uses Doctrine ORM (Object Relational Mapping) as it's interface to the datastore. This allows GocDB to be deployed to either a Oracle, MySQL or SQLite database (Postgres comming soon).


  • Required database: Oracle 11g or higher (note: the free Oracle 11g XE Express Editions which comes with a free license is perfectly suitable. 10g may also work but is untested)
  • Required space: 150 MB Dowload free Oracle XE from the following link and follow the installation instructions:
  • For gocdb admin tasks, we also recommend the SQL Developer tool.



  • Required database: SQLite 3.x.x or higher. SQLite is produced as an open source database and all versions are free to use.
  • Required: See the SQLite documentation:

Web frontend

The machine to use as the web frontend will need the following:

  • Apache http server version 2.2 or higher.
  • PHP version 5.3 or higher (version <=5.2 has some OOP related bugs).
    • If using Oracle: PHP oci8 extension and Oracle Instant client v10 or higher (downloadable from Oracle website)
    • libxml2 and DOM support for PHP (Note: On RHEL, PHP requires the PHP XML RPM to be installed for this component to function).
    • OpenSSL Extension for PHP
  • An X509 host certificate for the machine


  • PHP Unit for testing developments

Preparing your installation

Database preparation

GocDB v5 comes with deploy script which will create the DB schema for GocDB (i.e. export the DDL to create the tables and sequences in the DB). The only preperation is that you have setup a database user/account in your chosen RDBMS and have the user access details which are required later in the installation when configuring GocDB for deployment. 

Details for creating GOCDB user on specific RDBMS:

GOCDB file system

Place the GocDB source folder on your chosen web server.


Pear is recommended to install Doctrine and PHPUnit, many builds of PHP come pre-bundled with PEAR.

Verify the PEAR installation by running pear version on the command line.

$ pear version
PEAR Version: 1.9.4
PHP Version: 5.3.8
Zend Engine Version: 2.3.0
Running on: Windows NT ESCPC0095 6.1 build 7601 (Windows 7 Business Edition Service Pack 1) i586


Doctrine can be installed using PEAR. First add the Doctrine and Symfony channels to PEAR:

$pear channel-discover
$pear channel-discover

Then install Doctrine and it's dependencies:

$pear install --alldeps doctrine/DoctrineORM

Verify the Doctrine installation by running "doctrine --version" on the command line (or doctrine.bat --version if on Win):

$ doctrine --version
Doctrine Command Line Interface version 2.3.3

More information on Doctrine can be found here at the Doctrine2 site.


PHPUnit is an optional choice for GOCDB users. GOCDB5 includes a test suite of unit tests that can be used to verify buisness logic and database connections for a deployed instance of GOCDB. In addition developers extending and modifying GOCDB can write unit tests for their own developements. To install PHPUnit use PEAR:

$pear clear-cache
$pear config-set auto_discover 1
$pear install

This install can then be verified using "phpunit --version" on the command line:

$ phpunit --version
PHPUnit 3.7.27 by Sebastian Bergmann.

More information on PHPUnit can be found via the PHPUnit documenation here.

Deploying GOCDB5

Database Connection

You should now have all the required blocks in place to deploy GOCDB V5. To Deploy the database schema to your desired database using Doctrine:

  • Navigate to to gocDBSrc/lib/Doctrine folder.
  • Locate the provided template file: bootstrap_doctrine_TEMPLATE.php. In this file you will find three blocks of code commented out, once for each of the supported databased, SQLite, Oracle and MySQL as shown below:
  • Copy this file to bootstrap_doctrine.php in the same dir as the template file and modify to specify your chosen DB connection details.
Un-comment the area for your chosen database and fill in the details for your chosen database. 

        ///////////////////////SQLITE CONNECTION DETAILS/////////////////////////////////////////////
	//      $conn = array(
	// 	        'driver' => 'pdo_sqlite',
	// 	        'path' => __DIR__ . '/db.sqlite',
	//      );

	///////////////////////ORACLE CONNECTION DETAILS////////////////////////////////////////////
	//	$conn = array(
	//		'driver' => 'oci8',
	//		'user' => 'docsvn',
	//		'password' => 'doc',
	//		'host' => 'localhost',
	//		'port' => 1521,
        //              /*'service' = true,*/  //This may be needed depending on your Oracle server
	//		'dbname' => 'XE'
	//	);
	//  // Need to explicitly set the Oracle session date format [1]
	//  $evm = new EventManager();
	//  $evm->addEventSubscriber(new OracleSessionInit(array('NLS_TIME_FORMAT' => 'HH24:MI:SS')));	

	///////////////////////MYSQL CONNECTION DETAILS////////////////////////////////////////////
	//  $conn = array(
	//	'driver' => 'pdo_mysql',
	//	'user' => 'doctrine',
	//	'password' => 'doc',
	//	'host' => 'localhost',
	//	'dbname' => 'doctrine'
	//  );

Note: Doctrine can use APC caching however this is not suitable for all deployments. To disable comment out the APC configuration lines within the bootstrap_doctrine.php file:

$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ApcCache());
$config->setQueryCacheImpl(new \Doctrine\Common\Cache\ApcCache());

Deploying GOCDB

GocDB can be deployed as a blank instance ready for use or as a sample instance with a small amount of example data to demonstrate GocDB. The deploy script can be found at /lib/Doctrine/deploy/

Windows Users: These scripts are designed for deployment on a Linux machine. If you are using Windows or Cygwin you will need to open and change: doctrine to doctrine.bat.

By supplying a flag when executing the script you can deploy either a new empty database or a sample database eg:

$./ -s

Deploying GocDB with sample data


$./ -n

Deploying new empty GocDB instance

Apache Configuration


Now that your database is deployed the final step is to configure Apache.

A few modules need to be enabled for GOCDB to work, check these are enabled on your Apache and if not enable them. 

In httpd.conf enable ssl_module by un-commenting these lines:

LoadModule ssl_module modules/


A sample gocdbssl.conf is provided in GocDBSrc/config. This file will define the alias and SSL settings used by Apache to connect to GocDB.


The first step is to setup the paths for the DocumentRoot, ErrorLog and TransferLog and define the ServerName and ServerAdmin details for your particular web service where you are hosting GocDB.

SSL Keys

The SSLCertificateFile should point to the location of your server SSL key file. The SSLCertificateKeyFile -- The SSLCACertificationPath should point to the location of your CA certificates.

For development the SSLCertificatedFile and SSLCertificateKeyFile can be self signed certificates. However these must not be used in production.


The final step is to set the Alias to map your desired directory for GocDB webportal and Programmatic Interface (PI) to the correct folder and ensure the correct rules are defined for your server.

For the webportal the following settings are an example:

    Alias "/portal" "/gocDBsrc/htdocs/web_portal"
    <Directory "/gocDBsrc/htdocs/web_portal">
            SSLVerifyClient  require
            Options FollowSymLinks Indexes
            Order deny,allow
            Allow from
            deny from all  

The alias should and file location should also be set for the public PI and private PI. Public PI:

Alias "/gocdbpi/public" "/gocDBsrc/htdocs/PI/public"
<Directory "/gocDBsrc/htdocs/PI/public">

Private PI:

Alias "/gocdbpi/private" "/gocDBsrc/htdocs/PI/private"
<Directory "/gocDBsrc/htdocs/PI/private">

Compiled Entities

This step is optional, but for production servers this step is strongly recommended. When Doctrine uses an entity it creates a compiled version of the entity which by default is stored in the machines temporary folder. This is un-suitable for production machines as this may well be emptied. To avoid this uncomment the following line in bootstrap_doctrine.php:


You now need to create this folder in the same directory as the bootstrap_doctrine.php file:

bootstrap_doctrine.php  bootstrap.php  cli-config.php  deploy  entities  README.txt
$mkdir compiledEntities

Once this folder is created it, your apache server needs write permissions (the exact command may change depending on your apache server):

$chown apache compiledEntities/
$ls -ltrh
total 28
drwxr--r-- 2 apache root 4.0K Nov 20 16:11 entities
-rw-r--r-- 1 apache root  131 Nov 20 16:11 README.txt
-rw-r--r-- 1 apache root  219 Nov 20 16:11 cli-config.php
-rw-r--r-- 1 apache root 1.6K Nov 20 16:11 bootstrap.php
-rw-r--r-- 1 apache root 3.0K Nov 20 16:11 bootstrap_doctrine_TEMPLATE.php
-rw-r--r-- 1 apache root 2.8K Nov 27 09:38 bootstrap_doctrine.php
drwxr--r-- 2 apache root 4.0K Nov 27 09:39 compiledEntities

Finally use the doctrine command line client to generate the compiled entities and store them in the folder:

doctrine orm:generate-proxies compiledEntities/

This folder is now configured with the compiledEntites. It can be copied and used for new instances of GocDB as long as there have been no changes made to any of the entities, or it can be recreated as demonstrated each time.

First Use

You should now be able to navigate to the GocDB webportal on your host using the URL defined in your alias. You will need to install a browser certificate that is suitable for the SSL keys you defined for your host to be able to view GocDB.



GocDB picks up a number of its settings and variables from the local_info.xml file located in the config folder. The web_portal_url will be output in the PI to create links from PI objects back to Portal views. The pi_url and server_base_url will both be used by the monitor. The monitor is a quick look status check for GocDB. The mointor can be found at your web_portal_url/GOCDB_monitor/. If these URL's are not set in the local config this feature will not work correctly.

default_scope defines which scope if any will be used if no scope is specified when running PI queries. This can be left blank or set to a scope of your choosing. default_scope_match is again used if no scope_match parameter is supplied with PI queries. This can be either all or any. The minimum_scopes section declares how many scopes an NGI, site, service or service group must have at creation. This can be left as 0 or set as 1 if you want all your users entities to belong to at least one scope or more as dictated by your use of GocDB.

It's important at this point to understand how the scopes work with GocDB v5 especially in relation to the output of the PI. If you specify a default scope within your local_info but none of your entities have this scope then nothing will show in the PI. For an in-depth look at the scopes mechanism the section please read the section 'Multiple Scopes and Projects' in the GOCDB5 Grid Topology Information System document on page 5.

Setup an Admin User

To get started with GocDB you will need an admin user. This is done by first registering as a user on GocDB by clicking the 'Register' link on the left menu bar at the bottom. Once you have registered yourself you will then need to set yourself as an admin. To do this you need to change the user record directly in your database. The users table has a field called 'isAdmin' which by default is set to 0. To change a user to admin set this to 1. Below is a sample of the SQL query used when using an Oracle database to set a user as admin.

UPDATE users SET isadmin=1 WHERE forename='John' AND surname='Doe' 

Once you have an admin user you can create Projects and NGI's and grant roles to other users over these entities to allow them to add to GocDB.


GocDB v5 comes with a suite of tests that can be run to validate the install and check that Doctrine and your chosen database are operating as expected. These tests require PHPUnit, the install instructions for this can be found in section 3.6. The tests can be found in the GocDB/tests/ folder.

Install the Oracle OCI drivers for PDO

To run tests you will also need to install the Oracle OCI8 PDO (PHP Data Object) drivers for PHP since the DBUnit tests use PDO for their execution to validate that the results that Doctrine is returning are true. To install the OCI8 drivers for pdo. See:

You can test that you have the OCI8 pdo drivers installed via your php_check.php(). There will be a section that lists your enabled pdo drivers, e.g. as below:

            |             PDO             |
            | PDO support	enabled   |
            | PDO drivers 	mysql,oci |

Deploying a Test Database

We STRONGLY recommend that you deploy a second database with different connection details that will be used for testing.

  • Create a second DB account/user for your test database (e.g. GOCDB5TEST).
  • Copy bootstrap_doctrine_TEMPLATE.php file found in tests/doctrine to bootstrap_doctrine.php (in the same dir).
  • Modify bootstrap_doctrine.php to specify your GOCDB5TEST account/user. Complete the section for your database and ensure that the other connection details are deleted or commented out.
  • Copy bootstrap_pdo_TEMPLATE.php to bootstrap_pdo.php. Complete the details for the connection details for your database and ensure that the other 2 connections are either deleted or commented out, see below:
Un-comment the area for your chosen database and fill in the details for your chosen database. 

     ///////////////////////SQLITE CONNECTION DETAILS/////////////////////////////////////////////
     // $sqliteFile = __DIR__ . '/../db.sqlite';
     // $pdo = new PDO("sqlite:" . $sqliteFile);
     // return new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdo, 'sqlite');
     ///////////////////////ORACLE CONNECTION DETAILS/////////////////////////////////////////////
     // $pdo = new PDO('oci:dbname=//localhost:1521/xe', 'DoctrineUnitTests', 'doc');      
     // return new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdo, 'USERS');
     ///////////////////////MYSQL CONNECTION DETAILS//////////////////////////////////////////////
     //  $pdo = new PDO('mysql:host=localhost;dbname=doctrine;charset=UTF8', 'doctrine', 'doc');
     //  return new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdo);

Running the Test Suite

A initial test suite is provided that will excercise core functions of GocDB and Doctrine. This suite can be ran using the command:

phpunit DoctrineTestSuite1.php

You will be prompted to continue as this operation will drop any tables in your test database and then recreate the schema ready to run the tests. These tests should return with no errors to demonstrate that GocDB and Doctrine are installed correctly and are working as expected.

Running Individual Tests

Individual tests can be run by calling:

phpunit <testNameFile>.php

It is advised that at the beginning of a testing session you drop and recreate the database by running the script.

Recreating the Test DB

You can run the following script found in the tests/doctrine folder to Drop and Recreate the test database whenever required:


Writing Tests

If you intend to develop new functionality for your instance of GocDB you can support this development by writing unit tests for the new features. A simple example of a test can be found in GocDB/tests/exampleTests. 'FirstTest.php' demonstrates how to create data and assert that it is as expected.

A good tutorial for getting started with PHPUnit can be found here.

Writing a Doctrine Test

When working with Doctrine there are a number of setup functions that needed to be included in your test file. A template file has been provided in GocDBSrc/tests/exampleTests called 'DoctrineTestTemplate.php'. When executing any tests based on this template two files need to be present in the same folder as the test being executed:


The first holds your connection details and the second will initialize the database with the correct tables ready for testing.

You can write multiple test functions at the bottom of this skeleton file.

Doctrine Test Example

'DoctrineTestExample.php' shows the following example test. In this test we will create a site, populate the site with some data and then assert that the data is correct.

This test will make use of the 'TestUtil.php' file which contains a few helper methods to quickly create objects. This file is located in GocDBSrc/test/doctrine. When following this tutorial execute 'DoctrineTestExample.php' from GocDBSrc/test/doctrine.

Creating the site:

    public function testDoctrineExample() {
        print __METHOD__ . "\n";

        //Create a site
    	$ourSite = TestUtil::createSampleSite("Our Example Site");

We now have a site and will add some extra information to the site utilizing setters methods defined in the site entity which can be found in GocDBSrc/lib/Doctrine/entites. We will add an email, telephone and location to the site:

	//Create a site
    	$ourSite = TestUtil::createSampleSite("Our Example Site");
	//Set some details of the site
	$ourSite->setLocation("United Kingdom");

We now must persist this object in memory by calling '$this->em->persist($outSite);'

However this now only exist in memory - it is not yet in the database. To check this we can query the database directly using the PDO connection we setup:

	//Get the site ID from the object
	$siteId = $ourSite->getId();   
	//Get a database connection	    	
    	$con = $this->getConnection();
	//Search the database for this site
	$sql = "SELECT 1 FROM sites WHERE ID = '$siteId'";
	$result = $con->createQueryTable('', $sql);

        //We expect this query to return no rows as the site does not exist in the database yet
	$this->assertEquals(0, $result->getRowCount());

When running the test at this point the outcome should be:

OK (1 test, 1 assertion)

Our assertion was correct, there were no sites with that ID in the database yet as it has not been committed, the site only exists in memory at the moment. To commit the site to the database we must call:


Now if we run the query again we expect one result:

	//Search the database for this site again
	$sql = "SELECT 1 FROM sites WHERE ID = '$siteId'";
	$result = $con->createQueryTable('', $sql);
	//We expect this query to return 1 rows as the site now exists in the database
	$this->assertEquals(1, $result->getRowCount());

This shows the process of creating an entity, using its get and set methods to enter and retrieve data and then committing it to the database. It also shows the process of using the PDO connection to check that the data exists in the database as we expect.