You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Overview

The HPS conditions database contains time-dependent detector information for use by reconstruction and analysis software.  The primary database is hosted at JLAB and there is a replicated copy of it that also runs at SLAC.  The JLAB database is accessible only internally within jlab.org whereas the SLAC one is public.

Setting Up MySQL

The details of installing MySQL itself will not be covered, but complete instructions can be found in the documentation e.g. MySQL Linux Installation.

After installation, the server should be started as a daemon process, and you will need to create an account that is capable of loading the database.

You should create the database for the conditions system from the console after the initial installation.

mysql> create database hps_conditions;

Now an account needs to be granted privileges for this database.

GRANT ALL ON hps_conditions.* TO 'hpsadmin'@'localhost';

This hpsadmin account will be used to load the data from the JLAB database into your local installation.

You should also create a read-only account.

GRANT SELECT ON hps_conditions.* TO 'hpsuser'@'localhost';

The restricted hpsuser account will be used to run local reconstruction or analysis jobs.

Creating a Database Dump

You must acquire a SQL dump from the JLAB database which will be loaded locally.

You will need to be logged into a JLAB machine like jlabl3 for this step. 

In order to do this you must also have a MySQL account with the correct privileges, or you must ask one of the HPS database administrators to create this file for you.

mysqldump -h jmysql.jlab.org -ujeremym -pXXXXXXXX --disable-lock-tables hps_conditions &> jlab_conditions_db.sql

The -u argument should have the actual database user account and the -p argument must specify the password.

Now the file jlab_conditions_db.sql should contain a complete copy of the table structure and all the data in SQL format.

Loading the SQL File

Next, assuming you have transferred the SQL file to your local computer, you can use the command line tool to load it into a local database.

mysql -D hps_conditions -h localhost -P 3306 -u hpsadmin -pXXXXXXXX < jlab_conditions_db.backup.sql

Now the JLAB database should be installed on your computer.

Using the Local Database

The local database will not be used by default.

You need to create a config file e.g. local.prop with the connection parameters in it.

user: hpsuser
password: XXXXXXXX
database: hps_conditions
hostname: localhost

Finally, a Java system property needs to be set when you run any of the command line tools for HPS.

java -Dorg.hps.conditions.connection.file=local.prop -cp ~/.m2/repository/org/hps/hps-distribution/3.1-SNAPSHOT/hps-distribution-3.1-SNAPSHOT-bin.jar [args]

or if using a runnable jar

java -Dorg.hps.conditions.connection.file=local.prop -jar ~/.m2/repository/org/hps/hps-distribution/3.1-SNAPSHOT/hps-distribution-3.1-SNAPSHOT-bin.jar [args]

In the log messages printed out with the job, you should see something like the following.

Thu Jan 22 13:18:33 PST 2015 :: DatabaseConditionsManager :: INFO :: opening connection to jdbc:mysql://mysql-node03.slac.stanford.edu:3306/
Thu Jan 22 13:18:33 PST 2015 :: DatabaseConditionsManager :: INFO :: host mysql-node03.slac.stanford.edu
Thu Jan 22 13:18:33 PST 2015 :: DatabaseConditionsManager :: INFO :: port 3306
Thu Jan 22 13:18:33 PST 2015 :: DatabaseConditionsManager :: INFO :: user rd_hps_cond_ro
Thu Jan 22 13:18:33 PST 2015 :: DatabaseConditionsManager :: INFO :: database rd_hps_cond
Thu Jan 22 13:18:33 PST 2015 :: DatabaseConditionsManager :: INFO :: connection opened

The actual settings printed there should match the ones for your local database.

Guidelines for Usage

In general, you should prefer not to make a alterations or additions to the local database.  These procedures are instead designed for running reconstruction and analysis without an internet connection on your local machine.  Any official changes to be used in production, such as recon passes run at JLAB, must be made on the JLAB database through the HPS database administrators.  So in order for others to use any conditions you might like to add to the system, the best approach will be adding that information to the primary database and replicating it to the public SLAC database, rather than having others connect directly to your database instance.

  • No labels