Setting up BaBar Book Keeping database for local use
These are instructions for setting up a BaBar book keeping database for
local use by one person.
Sorry this, should all be scripted to make your life easier, but until then,
this is how to go about doing it, skip ahead to the sections that you care about:
Setting up the server and needed software
The first thing to do is get the local database server and database setup.
For now these instruction will be for MySQL, but Oracle databases are also
support in the book keeping tools, and most of what is done here also applies.
First get the needed software installed, MySQL database and the perl DBI
modules. The preferred way of doing this is for using a RedHat distribution,
and using the RPM's off the RedHat install disks.
Needed rpms for MySQL install:
rpm -ivh mysql*.rpm
rpm -ivh perl-DBI*.rpm
rpm -ivh perl-DBD-MySQL*.rpm
To be able to mirror or connect to the SLAC database you will also need the perl
Storable, and PlRPC client modules. For RedHat 7.2 the Storable is a separate
rpm, but the Storable module comes installed with perl on RedHat EL3. The PlRPC
perl module you can get from CPAN, this one doesn't come with the RedHat install.
For RedHat 7.2 only:
rpm -ivh perl-Storable*.rpm
Last module to get RPC::PlClient:
perl -MCPAN -e 'install RPC::PlClient'
Or get all the perl modules in one go:
perl -MCPAN -e 'install Bundle::DBI'
Once the software is installed you will need to start the server.
Start the MySQL server as root:
/etc/init.d/mysql start
Setting up the database, permissions, and usernames
Once the server is going, you will need to set the root user password and create
the new database. You can do both of these things with the util
mysql_setpermission.
Set root user permissions, create database, username and password:
mysql_setpermission -u root
Use the first option to set the root password. You will then need to create
the database, you can do this with option 2. Make a database, it can be of
any name, but the suggested name is 'bbkr14'. The user for the database can
also be of any name, give it a password and only serve it to the host
'localhost'. This user can only select from the database, you need to give
this user move privilege to the new database, or create another user which
can insert and update the dataset. To do this use option 4, use the same
database name, and either the same user or a new user. Again give it a
password and serve to 'localhost'.
Note:The database schema in BbkTools in analysis-21 and release
14.5.2 and before hardcoded the use of the database name 'bbrora', this is ok,
but BbkTools after these tags will allow any database name to be used.
Setting up the tables for use in the running database:
Now that the database is setup, the tables will need to get created. The schema
of the tables is in the BbkTools package, and these just need to be run by the
mysql shell.
Create the needed tables:
% mysql -u [username] -p [databasename] < BbkTools/bbk_table_schema.mysql
% mysql -u [username] -p [databasename] < BbkTools/data_table_schema.mysql
And replace the '[username]' and '[databasename]' with the ones you setup, and
give the password you used. Now the book keeping database should be setup.
Setting up connections to the local database for the BbkTools:
Now you need to setup the connection for the book keeping tools. You need to
create the file "~/.bbk/sites/local/connect" in you home dir. The file should
then look like:
Create the file ~/.bbk/sites/local/connect
type=MySQL
connection=Network
server=localhost
database=[databasename]
driver=dbi:mysql:[databasename]:localhost
Again replace the '[databasename]' with the one you setup. This will setup the
connection to the database, now the connection to the username needs to be
set. Make a sub dir of the local site, "~/.bbk/sites/local/local", and then
you need to put the password for the username you setup into a file in this
sub-dir, like this:
Setting the access to the user for the tools:
echo [password] > ~/.bbk/sites/local/local/[username]
And finally we should set the correct access rights on these local files.
Change access to local connections:
chmod 600 ~/.bbk/sites/local/connect
chmod 600 ~/.bbk/sites/local/local/[username]
Testing that the BbkTools work with the local database:
And that should setup the connection to the tools. You can then test this
connection by seeing if you can get an sql shell with the tools. Try:
BbkSqlShell --dbsite local --dbuser [username]
If you are setup, then you should get a shell prompt without any errors, if
this works, just exit, and go on to using the tools. If not, you can try again
with the '--debug' option, and see if something wrong stands out. If not then
see if the database is still being served, and try to get an sql shell with
the mysql util, "mysql -u [username] -p [databasename]". If that works, and
the BbkSqlShell does not, then copy the "--debug" output of the BbkSqlShell to
a question on the Book Keeping HyperNews forum.
Comments to: Douglas Smith
|