Database connectivity
This section provides instructions to configure clients to connect to the Sensys DB. This is required for clients that will need to communicate with the database (e.g. clients that need to run Sensys with the DB component enabled, like an aggregator node).
Sensys provides support for two database connection methods:
- Connecting via the PostgreSQL client library
- Connecting via ODBC
Connecting via the PostgreSQL Client Library
Software Requirements
Package | Version | Req. | Notes |
---|---|---|---|
PostgreSQL Client | 9.2 or higher | Yes | Required on database clients |
PostgreSQL shared libraries | 9.2 or higher | Yes | Installed as a dependency |
The PostgreSQL client library is going to be required for Sensys nodes that need to connect to the database. This is usually for nodes with the aggregator role.
Configuring the Sensys DB postgres Component
Once the PostgreSQL client package is installed, clients should be able to link to the PostgreSQL libraries and use the native API to communicate with the database. In the case of Sensys, the following MCA parameters are required to tell the Sensys postgres
component how to connect to the database:
- db_postgres_uri: the URI for the host where the PostgreSQL server process is running. This can be specified in the following format:
<host>:<port>
. The port is optional. If left blank, it will use the PostgreSQL default port. - db_postgres_database: the name of the database (e.g. orcmdb).
- db_postgres_user: the user and password in the following format:
<user>:<password>
.
Connecting via ODBC
To complete the following steps, the following files are needed (found in the Sensys repository in the contrib/database
directory):
- psql_odbc_driver.ini
- orcmdb_psql.ini
Software Requirements
Package | Version | Req. | Notes |
---|---|---|---|
unixODBC | 2.2.14 or higher | Yes | Required on the database clients |
PostgreSQL ODBC driver | 09.03.0210 or higher | Yes | Required on the database clients |
PostgreSQL Client | 9.2 or higher | No | Optional on management machines |
Note: The PostgreSQL client may be installed on any machine for administrative tasks: testing the database connection, data and schema management, etc.
These client packages are generally required on nodes with the role of aggregator.
Installation Overview
Configuring the clients for connecting to the database requires:
- Installing an ODBC driver manager
- Installing the ODBC driver for the desired DBMS
- Configuring a DSN
Before installing the DBMS ODBC driver, it’s necessary to install the ODBC driver manager: unixODBC. The unixODBC package provides the necessary functionality to allow clients to connect to a database via ODBC. In addition, for developing and building applications that will use ODBC, the unixODBC development package is necessary. So the development package is necessary for building Sensys with ODBC support.
After installing the unixODBC driver manager, execute the following command: odbcinst –j
. Note where unixODBC installed the configuration files for: drivers, system data sources and user data sources. These files will be needed in the following sections.
Please refer to the unixODBC web page for installation instructions.
Note: unixODBC already provides a driver for PostgreSQL. However, it’s recommended to install the latest drivers provided by the respective vendors.
ODBC Installation for PostgreSQL
- Get ODBC configuration information:
- Execute:
odbcinst -j
- Note where unixODBC installed the configuration files for: drivers, system data sources and user data sources. These files will be needed in the following steps.
- Execute:
- Install the PostgresSQL ODBC driver
- Please refer to the PostgreSQL installation wiki for availability of a package for the ODBC driver.
- Alternatively, the ODBC driver can be built from source
- The source code can be downloaded from the PostgresSQL downloads web page
- Please refer to the installation instructions provided with the source code. Usually, the steps are:
$ ./configure $ make % make install
- After completing the installation, note the directory where the driver (.so file) was installed
- Register the PostgreSQL ODBC driver
- Edit the
psql_odbc_driver.ini
file and fill in the required parameters:- Driver: specify the absolute path where the PostgrSQL ODBC driver (.so file) was installed
- Execute the following command:
odbcinst –i –d –f psql_odbc_driver.ini
- Open the ODBC driver configuration file and verify the driver was configured correctly
- Edit the
- Configure a DSN to connect to the Sensys DB
- Note: the DSN may be configured at the user level (visible only to the current user) or at the system level (visible to all users that log in to the machine).
- Edit the
orcmdb_psql.ini
file and fill in the required parameters:- Driver: specify the exact name of the driver as configured in the ODBC driver configuration file
- Server: specify the hostname or IP address of the server where the database was installed
- Configure the DSN:
$ odbcinst –i –s –f orcmdb_psql.ini –l
- Note:
- This will configure the DSN at the system level (visible to all users)
- To configure the DSN at the user level (visible only to the current user):
$ odbcinst –i –s –f orcmdb_psql.ini –h
- Note:
- Open the respective DSN configuration file to verify the DSN was configured correctly
- Verify the installation
- Use the
isql
command-line utility provided by unixODBC to connect to the database:$ isql orcmdb_psql orcmuser <orcmuser’s password>
- Try executing an SQL command:
select * from data_sample
- The table will most likely be empty, but the query should at least succeed
- Use the
Configuring the Sensys DB odbc Component
The odbc component requires the following MCA parameters to be defined:
- db_odbc_dsn: the DSN name configured in the previous section.
- db_odbc_user: the user and password in the following format:
<user>:<password>
. - db_odbc_table: the database table that the DB component operations will use. At the moment this parameter has no effect for RAS monitoring operation. Please set to:
data_sample
.
Setting MCA Parameters
These MCA parameters may be specified in:
- The
openmpi-mca-params.conf
file - The
orcm-site.xml
file - The command line via the
-omca
command-line parameters
For more details on setting MCA paramters, please refer to: Setting MCA parameters.