Hyrax - BES Configuration

From OPeNDAP Documentation
Revision as of 22:30, 23 June 2008 by PatrickWest (talk | contribs) (Pointing to data)

Building the BES from and it's data handlers source or installing from an RPM will provide the default installtion with data and a valid configuration. This is suitable for testing. The following details how you go about customizing it for your data.


1 Administration & Logging

The BES.ServerAdministrator parameter is the address used in various mail messages returned to clients. Set this so that whoever gets the email will be able to fix problems ad/or respond to user questions. Also set the log file and log level. If the BES.LogName is set to a relative path it will be treated as relative to the directory where the BES is started. That is, if the BES is installed in /usr/local/bin but you start it in your home directory using the parameter value below, the log file will be bes.log in your home directory.

BES.ServerAdministrator=webmaster@some.place.edu
BES.LogName=./bes.log
BES.LogVerbose=no

Because the BES is a server in its own right, you will need to tell it which network port and interface to use. Assuming you are running the BES and OLFS (i.e., all of Hyrax) on one machine, here's what you should do:

2 User and Group parameters

The BES must be started as root. One of the things that the BES does first is to start up a listener to listen for requests to the BES. This listener is started as root, but then the user and group of the process is set using parameters in the BES configuration file.

BES.User=user_name
BES.Group=group_name

You can also set these to a user id and a group id. For example:

BES.User=#172
BES.Group=#14

3 Setting the networking parameters

BES.ServerPort=10002
# BES.ServerUnixSocket=/tmp/opendap.socket

The BES.ServerPort tells the BES which TCP/IP port to use when listening for commands. Unless you need to use a different port, use the default. Ports with numbers less than 1024 are special, otherwise you can use any number under 65536. That said, stick with the default unless you know you need to change it.

In the default bes.conf file we have commented the ServerUnixSocket parameter since doing so now disables I/O over that device. If you need UNIX socket I/O, uncomment this line, otherwise leave it commented since the fewer open network I/O ports, the easier it is to make sure the server is secure.

If both ServerPort and ServerUnixSocket are defined, the BES listens on both the TCP port and the Unix Socket. Local clients, on the same machine as the BES, can use the unix socket for a faster connection. Otherwise, clients on other machines will connect to the BES using the BES.ServerPort value. Note that the OLFS always uses only the TCP socket, even if the UNIX socket is present.

4 Debugging Tip

Use the BES.ProcessManagerMethod parameter to control whether the BES acts like a normal Unix server or not. The default value of multiple causes the BES to accept many connections at once, like a typical server. The value single causes it to accept a single connection, process the commands sent to it and exit, greatly simplifying trouble shooting.

BES.ProcessManagerMethod=multiple

5 Controlling how compressed files are treated

The bz2, gz, and Z file compression methods are understood by the BES.

When the BES is asked to serve a file that has been compressed, it first must decompress it and then pass it to the correct data handler (except for those formats which support 'internal' compression such as HDF4). The BES.CacheDir parameter tells the BES where to store the uncompressed file. Note that the default value of /tmp is probably less safe than a directory that's only used by the BES for just this purpose. You might set this to <prefix>/var/bes/cache, for example.

The BES.CachePrefix parameter is used to set a prefix for the cached files so that when a directory like /tmp is used, it's easy for the BES to recognize which files are its responsibility.

The BES.CacheSize parameter sets the size of the cache in megabytes. When the size of the cached files exceeds this value, the cache will be purged using a last-accessed-first-removed approach. Because it's usually impossible to determine the sizes of data files before decompressing them, there may be times when the cache holds more data than this value. Ideally this value should be several times the size of the largest file you plan to serve.

5.1 Tuning the cache to your data

The two parameters BES.Uncompress.Retry and BES.Uncompress.NumTries are used, along with BES.CacheSize, to tune the performance of the cache. The BES cache directory is locked to prevent the different beslistener processes from simultaneously removing files and leaving the cache in an inconsistent state. Use the Retry and NumTries parameters to tune this behavior. Generally, NumTries should be set to about 10. The units of Retry are microseconds. To tune the NumTries and Retry, use the formula

Retry = (0.2s/Average_file_sizeMB)/NumTries

If your average file size is 10MB and you've settled on a NumTries of 10, the set Retry to (0.2s/10MB)/10 = 0.002s or 2000 microseconds. If you have really large files (e.g., decompressed they are 500MB), try setting NumTries to 100.

BES.CacheDir=/tmp
BES.CachePrefix=bes_cache
BES.CacheSize=500
BES.Uncompress.Retry=2000
BES.Uncompress.NumTries=10

6 Loading Handlers

Virtually all of the BESs functions are contained in modules that are loaded when the server starts up. Each module is a shared-object library. If you're curious about how these are built, take a look at any of the data handlers (e.g., the dap-server software has several handlers and those are used by almost every BES).

There are two steps to the configuration:

  1. List the modules in the order you want it loaded using the BES.modules parameter
  2. Use the BES.module.module name parameter to tie the name used in BES.modules with a specific shared-object module file. Use absolute paths.

Here's an example:

BES.modules=dap,cmd,ascii,usage,www,nc,h4,ff
BES.module.dap=/usr/local/lib/bes/libdap_module.so
BES.module.cmd=/usr/local/lib/bes/libdap_cmd_module.so
BES.module.ascii=/usr/local/lib/bes/libascii_module.so
BES.module.usage=/usr/local/lib/bes/libusage_module.so
BES.module.www=/usr/local/lib/bes/libwww_module.so
BES.module.nc=/usr/local/lib/bes/libnc_module.so
BES.module.h4=/usr/local/lib/bes/libhdf4_module.so
BES.module.ff=/usr/local/lib/bes/libff_module.so

In this example configuration the BES loads the following modules:

dap 
The DAP implementation
cmd 
The BES command set
ascii 
A handler to build the ASCII data response using the data response from any one of the data handlers
usage 
A handler which retrieves metadata from a data handler and formats it as a text/plain response
www 
A handler which retrieves metadata from a data handler and builds the HTML form interface for that data source
nc 
The data handler for NetCDF3 files
h4 
The data handler for HDF4 files
ff 
The data handler for files which can be read using FreeForm

7 Pointing to data

There are two parameters that can be used to tell the BES where your data are stored. Which one you use depends on whether you are setting up the BES to work as part of Hyrax (and thus with THREDDS catalogs) or as a standalone server. In either case set the value of the ..RootDirectory parameter to point to the root directory of your data files (only one may be specified). Use BES.Catalog.catalog.RootDirectory if the BES is being used as part of Hyrax and BES.Data.RootDirectory if not. So, if you are setting up Hyrax, set the value of BES.Catalog.catalog.RootDirectory but be sure to set BES.Data.RootDirectory to some value or the BES will not start. (This will be fixed soon jimg 23:12, 22 February 2007 (PST))

BES.Catalog.catalog.RootDirectory=/full/path/data/root/directory
BES.Data.RootDirectory=/full/path/data/root/directory

Next configure the mapping between data source names and data handlers. When the BES is asked to perform some commands on a particular data source, it uses regular expressions to figure out which data handler should be used to carry out the commands. The value of the BES.Catalog.catalog.TypeMatch parameter holds the set of regular expressions. The value of this parameter is a list of handlers and expressions in the form handler:expression;. Note that these regular expressions are like those used by grep on Unix and it's somewhat cryptic, but once you see the pattern, it's not that bad. Below, the TypeMatch parameter is being told that any data source with a name that ends in .nc should be handled by the nc (netcdf) handler (see BES.module.nc above), any file with a .hdf, .HDF or .eos suffix should be processed using the HDF4 handler (note that case matters) and that data sources ending in .dat should use the FreeForm handler.

BES.Catalog.catalog.TypeMatch=nc:.*\.nc;h4:.*\.(hdf|HDF|eos);ff:.*\.dat;

If you fail to configure this correctly, the BES will return error messages stating that the type information has to be provided. However, it won't tell you this when it starts, only when the OLFS (or some other software) actually makes a data request. This is because it's possible to use BES commands in place of these regular expressions, although the Hyrax won't.

Finally, you can configure the types of information that the BES sends back when a client requests catalog information. The Include and Exclude parameters provide this mechanism, also using a list of regular expressions (with each element of the list separated by a semicolon). In the example below, files that begin with a dot are excluded.

The Include expressions are applied to the node first, followed by the Exclude expressions. For collections of nodes, only the Exclude expressions are applied.

BES.Catalog.catalog.Include=;
BES.Catalog.catalog.Exclude=^\..*;

If you would like for symbolic links to be followed when retrieving data and for viewing catalog entries, then you need to set the following two parameters. The BES.FollowSymLinks parameter is for non-catalog containers and is used in conjunction with the BES.RootDirectory parameter above. It is NOT a general setting. The BES.Catalog.catalog.FollowSymLinks is for catalog requests and data containers in the catalog and is used in conjunction with the BES.Catalog.catalog.RootDirectory parameter above. The default is set to No in the installed configuration file. To allow for symbolic links to be followed you need to set this to Yes.

BES.FollowSymLinks=No|Yes
BES.Catalog.catalog.FollowSymLinks=No|Yes

8 Parameters for Specific Handlers

Parameters for specific modules can be added to the BES configuration file. For example, each of the main data handlers (dap-server, netcdf, freeform, and hdf4) have scripts that modify the BES configuration file and add information to it, usually called bes-<handler>-data.sh where hander is something like dap-server, nc, ff, hdf4. The HDF4 configuration script, for example, adds the name of a cache directory.

The section to add handler specific parameters is delimited by the comment:

#-----------------------------------------------------------------------#
#                                                                       #
# Data Handler Specific key/value parameters                            #
#                                                                       #
#-----------------------------------------------------------------------#