Database Distro Specific Examples
PostgreSQL Installation
Centos 6
Edit /etc/yum.repos.d/CentOS-Base.repo
and add exclude=postgresql*
for [base]
and [updates]
section.
% yum localinstall https://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-7.noarch.rpm
% yum install postgresql92-server
Centos 7
Edit /etc/yum.repos.d/CentOS-Base.repo
and add exclude=postgresql*
for [base]
and [updates]
section.
% yum localinstall https://yum.postgresql.org/9.2/redhat/rhel-7-x86_64/pgdg-centos92-9.2-2.noarch.rpm
% yum install postgresql92-server
SuSE
% zypper in postgresql92-server
To remove:
% rm -rf /var/lib/pgsql
Centos 6/7
% yum remove postgresql92-server
SuSE
% zypper remove postgresql92-server
PostgreSQL Configuration
Centos 6
% service postgresql-9.2 initdb
Centos 7
% /usr/pgsql-9.2/bin/postgresql92-setup initdb
SuSE
$ su - postgres
% initdb
Edit /var/lib/pgsql/9.2/data/pg_hba.conf
and add: local all orcmuser trust
(must be before other entries).
% service postgresql-9.2 start
Failed to start? Check /var/lib/pgsql/9.2/pgstartup.log
or /var/lib/pgsql/9.2/data/pg_log/*.log
for details. Make sure an existing postgres process is not already running.
PostgreSQL DB and User Setup
$ su - postgres
$ dropdb orcmdb
$ dropuser orcmuser
$ createuser orcmuser
$ createdb --owner orcmuser orcmdb
NOTE: the 'drop' commands were included to remove a preexisting installation (they're not necessary if this is the first installation).
Client Access Setup
Edit /var/lib/pgsql/9.2/data/pg_hba.conf
and add host all all 127.0.0.1/32 trust
(for IPv4) and host all all ::1/128 trust
for IPv6.
% service postgresql-9.2 restart
To use the PostgreSQL native client library:
% yum install postgresql92
$ psql --dbname=orcmdb --username=orcmuser # Try `select * from data_sample_raw;`.
To use ODBC:
% yum install postgresql92-odbc
Edit psql_odbc_driver.ini
and specify the path where the PostgreSQL ODBC driver was installed. Use the following command to find it: rpm -ql postgresql92-odbc | grep psqlodbc.so
.
% odbcinst -i -d -f psql_odbc_driver.ini
Edit orcmdb_psql.ini
and specify the host where the PostgreSQL service is running and specify the name of the driver configuration (the key name from the .ini file from the previous step).
% odbcinst -i -s -f orcmdb_psql.ini -h
% odbcinst -s -q # List Data Source Names (DSNs)
% isql -v orcmdb_psql orcmuser # Test ODBC access to the DB. Try `select * from data_samples_view;`.
Look in /var/lib/pgsql/9.2/data/pg_log/postgresql-*.log
for access logs to the DB.
NOTE: for simplicity, these steps are configuring the authentication method for the database as trust
. This is a good approach to start with to make it easier to get everything up and running. However, once the basic setup is completed, it's highly recommended to configure a more secure authentication method.
Run Sensys
To use the Sensys postgres component:
% orcmd --omca sensor heartbeat,coretemp --omca db_base_verbose 100 --omca db_postgres_uri localhost --omca db_postgres_database orcmdb --omca db_postgres_user orcmuser:orc
To use the Sensys odbc component:
% orcmd --omca sensor heartbeat,coretemp --omca db_base_verbose 100 --omca db_odbc_dsn orcmdb_psql --omca db_odbc_user orcmuser:orc --omca db_odbc_table data_sample
NOTE: because the trust
authentication method was configured in the previous step, the password here is irrelevant. However, after the basic setup is up and running, it is highly recommended to at least configure the password
authentication method, in which case the correct password should be used here.
Query the DB
First, initiate a psql session:
$ psql -d orcmdb -U orcmuser [-W]
Querying RAS monitoring data:
psql> select * from data_samples_view;
Deleting the data from RAS monitoring:
psql> delete from data_sample_raw;
Getting the number of sample data rows from RAS monitoring:
psql> select count(*) from data_sample_raw;
Querying node feature data (inventory):
psql> select * from node_features_view;
Enabling Network Access to the DB
Edit /var/lib/pgsql/9.2/data/postgresql.conf
and set: listen_addresses = '*'
.
Adding a password
Edit /var/lib/pgsql/9.2/data/pg_hba.conf
and set the authentication method to password
instead of trust
:
From within a psql session (logged in as orcmuser):
psql> alter user orcmuser with password '<choose a password>';