Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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 periodically replicated to SLAC.  The JLAB database is accessible only internally within jlab.org whereas the SLAC one is public and can be accessed from anywhere over the internet as long as the port is not blocked for outbound traffic

Should you want to run the HPS software without an internet connection available, then this database needs to be installed locally.  These instructions will cover how to install MySQL on your machine, configure a database and the accounts for HPS, replicate the JLAB database to your machine, and finally how to configure the software to use this database rather than the default onelocal copy of the database.

Setting Up MySQL

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

For instance, on Redhat using yum, you would start by installing the necessary packages.

No Format
sudo yum install mysql-server mysql

The server should then be started up.

No Format
service mysqld start

You should login will need to login to the MySQL console client as the root user.

No Format
mysql -u root

And then the root password should be set for localhost.

No Format
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new-password');
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('new-password');

The root account is like the Unix "superuser" with complete privileges on all databases, so take care as to how this account is configured for security.  In general, you should prefer to use other accounts for your local work, but root can will be used in these instructions for operations such as creating new databases.

...

Creating the

...

Conditions Database and User

...

Account

From the root account, you should create the (initially empty) database for the conditions system from the console after the initial installation.

...

You should also create a read-only account that will be used to run jobs., as root should not be used for this!

No Format
CREATE USER 'hpsuser'@'localhost' IDENTIFIED BY 'mypassword';
GRANT SELECT ON hps_conditions.* TO 'hpsuser'@'localhost';

...

You will need to be logged into a JLAB machine like jlabl3 for this step. In order to do this , and 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.

No Format
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 (mine is used here as an example) and the -p argument must specify the password.

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

If you do not have an account on the JLAB database and do not wish to have one created for you, then you must ask one of the HPS database administrators to create this file for you.

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.

...

The local database will not be used by default .You so you need to create a config file, e.g. local.prop, with the connection parameters in it.

...

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

No Format
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 [className] [args]

or if using a runnable jar

No Format
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 from the job, you should see something like the following.

No Format
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 But the actual settings printed there should match the ones for your local database, e.g. the host should be localhost and not the SLAC or JLAB host.

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 or other users with the correct privilegesSo in 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 then replicating it to the public SLAC database, rather than having others connect directly to your database instance.