Personal tools
You are here: Home Documentation dCache Supercharged Companion DB
Document Actions

Supercharged Companion DB

by admin last modified 2008-09-03 14:58

Super-charge the performance of your companion database by switching from a normal DB backend to MySQL's memory engine

Introduction

The companion DB is a curious creature.  It's a "lazy cache" of the files in your dCache instance.  Whenever a pool gets a file, it registers with the PnfsManager (when the pool starts, it registers all files).  However, if a file replica is ever deleted from the pool, then it is not un-registered PnfsManager.  When the PoolManager needs to look up a file, it asks the PnfsManager to give it the cacheinfo for a particular PNFS ID.  The cacheinfo queries the Postgres DB, and asks for all pools with that PNFS ID.  Once the PoolManager receives the list of pools, it then contacts each one individually to confirm that the cache entry is correct.

So, the cache DB is not affected if it is flushed on occasion; in fact, it's a good idea to periodically register all the files on a pool with the "pnfs register" command.

Database Setup

Start off with a recent MySQL server (4.x or higher) on your PNFS node.  Create the database "companion" and populate it with the following table:
CREATE TABLE `cacheinfo` (
`pnfsid` varchar(24) default NULL,
`pool` varchar(64) default NULL,
`ctime` datetime default NULL,
UNIQUE KEY `uni_idx` (`pnfsid`,`pool`),
KEY `pnfs_idx` (`pnfsid`)
) ENGINE=HEAP DEFAULT CHARSET=latin1

Grant the user srmdcache full access to this table:

GRANT ALL ON companion.* to 'srmdcache'@'localhost' identified by 'srmdcache'

Change the username and password to reflect your current setup.

Next, download the JAR file for the MySQL database connector and place it in /opt/d-cache/classes.  I use the binary package mysql-connector-java-5.1.5; it contains the file mysql-connector-java-5.1.5-bin.jar; place that file in the classes directory.

In pnfsSetup in /opt/d-cache/config, add the JAR to the classpath like so:

classpath=/opt/d-cache/classes/mysql-connector-java-5.1.5-bin.jar:<previous contents of line>


PnfsManager Configuration

Next, we need to tell PnfsManager to connect to MySQL instead of Postgres.  This requires editing pnfs.batch in /opt/d-cache/config.  Replace the following lines:
       -cachelocation-provider-jdbcDrv=org.postgresql.Driver \
        -cachelocation-provider-dbURL=jdbc:postgresql://${companionDatabaseHost}/companion \
with the following:
        -cachelocation-provider-jdbcDrv=com.mysql.jdbc.Driver \
        -cachelocation-provider-dbURL=jdbc:mysql://root@${companionDatabaseHost}/companion \

Restart PNFS domain with /etc/init.d/dcache restart pnfs.

Powered by Plone, the Open Source Content Management System