Log of an installation of libexodus on Centos 5.3

From NEOSYS Dev Wiki
Jump to navigationJump to search

Preparation

sudo yum update
sudo yum install boost-devel postgresql-devel gcc-c++ subversion postgresql-server

Centos needs you to start the database manually. Ubuntu doesnt.

sudo /etc/init.d/postgresql start

Exodus

For the latest version of the software:

cd ~
mkdir exodus
cd exodus
svn co http://svn.neosys.com/svn/trunk
cd trunk

Or for not the latest:

wget http://www.neosys.com/support/exodus_all-9.6.tar.gz
tar xvfz exodus_all-9.6.tar.gz
cd exodus_all-9.6

Classic installation steps

./configure
make
sudo make install

Setting up Postgres for Exodus

Register the exodus functions

(on Mac OSX, ensure postgres can be found. Change 8.3 to your version) and check pg_config can run)

PATH=/Library/PostgreSQL/8.3/bin/:$PATH
pg_config

log in to postgres template1 database as a superuser

sudo su - postgres
psql -U postgres -d template1
\connect template1


-- cut and paste the following SQL to register the functions into postgres --

CREATE OR REPLACE FUNCTION exodus_call(bytea, bytea, bytea, bytea, bytea, int4, int4) RETURNS bytea AS 'pgexodus', 'exodus_call' LANGUAGE C IMMUTABLE;

CREATE OR REPLACE FUNCTION exodus_extract_bytea(bytea, int4, int4, int4) RETURNS bytea AS 'pgexodus', 'exodus_extract_bytea' LANGUAGE C IMMUTABLE;

CREATE OR REPLACE FUNCTION exodus_extract_text(bytea, int4, int4, int4) RETURNS text AS 'pgexodus', 'exodus_extract_text' LANGUAGE C IMMUTABLE;

CREATE OR REPLACE FUNCTION exodus_extract_sort(bytea, int4, int4, int4) RETURNS text AS 'pgexodus', 'exodus_extract_sort' LANGUAGE C IMMUTABLE;

-- Remaining functions are STRICT therefore never get called with NULLS -- also return NULL if passed zero length strings

CREATE OR REPLACE FUNCTION exodus_extract_text2(bytea, int4, int4, int4) RETURNS text AS 'pgexodus', 'exodus_extract_text2' LANGUAGE C IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION exodus_extract_date(bytea, int4, int4, int4) RETURNS date AS 'pgexodus', 'exodus_extract_date' LANGUAGE C IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION exodus_extract_time(bytea, int4, int4, int4) RETURNS time AS 'pgexodus', 'exodus_extract_time' LANGUAGE C IMMUTABLE STRICT;

CREATE OR REPLACE FUNCTION exodus_extract_datetime(bytea, int4, int4, int4) RETURNS timestamp AS 'pgexodus', 'exodus_extract_datetime' LANGUAGE C IMMUTABLE STRICT;

Check the functions loaded properly (count them)

\df exodus*
                                                  List of functions
 Schema |          Name           |      Result data type       |                 Argument data types
--------+-------------------------+-----------------------------+-----------------------------------------------------
 public | exodus_call             | bytea                       | bytea, bytea, bytea, bytea, bytea, integer, integer
 public | exodus_extract_bytea    | bytea                       | bytea, integer, integer, integer
 public | exodus_extract_date     | date                        | bytea, integer, integer, integer
 public | exodus_extract_datetime | timestamp without time zone | bytea, integer, integer, integer
 public | exodus_extract_sort     | text                        | bytea, integer, integer, integer
 public | exodus_extract_text     | text                        | bytea, integer, integer, integer
 public | exodus_extract_text2    | text                        | bytea, integer, integer, integer
 public | exodus_extract_time     | time without time zone      | bytea, integer, integer, integer
(8 rows)

For more information see http://www.postgresql.org/docs/8.1/static/app-psql.html

Create a user and database for exodus

Use the example password for now to avoid further configuration in exodus.

CREATE ROLE exodus LOGIN
 PASSWORD 'somesillysecret'
 CREATEDB CREATEROLE;
CREATE DATABASE exodus
 WITH ENCODING='UTF8'
   OWNER=exodus;

Quit postgres command prompt

\q

Ensure Exodus can logon to postgres

Unless you are only going to run Exodus as user "exodus" from the local machine, grant login from 127.0.0.1 using username/encrypted password (instead of only logged-in username without password) For more info see http://developer.postgresql.org/pgdocs/postgres/auth-pg-hba-conf.html

Centos

nano ~/data/pg_hba.conf

or for Ubuntu

nano /etc/postgresql/8.3/main/pg_hba.conf

comment out the following lines. NB DONT comment out any other similar lines esp. ones containining "postgres"

#local   all         all                               ident sameuser
#host    all         all         127.0.0.1/32          ident sameuser

and add these lines which allows the 'postgres' user local access through ident authentication, which is needed for cron scripts. The second line, allows anyone to connect locally on 127.0.0.1 if they can provide a valid username and password.

local   all         postgres                          ident sameuser
host    all         all         127.0.0.1         255.255.255.255   md5

quit postgres user

exit

Reload Postgres

Centos

sudo /etc/init.d/postgresql reload

or Ubuntu

sudo /etc/init.d/postgresql-8.3 reload

Testing

Test exodus library

nano test1.cpp
#include <exodus/exodus.h>
program() {
	date().oconv("D").outputln();
	print(oconv(date(),"D"));
}
g++ test1.cpp -lexodus
./a.out
27 JUN 2009
27 JUN 2009

Test database connection

nano test2.cpp
#include <exodus/exodus.h>
program() {
	createfile("exodustest");
}
g++ test2.cpp -lexodus
./a.out
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "exodustest_pkey" for table "exodustest"

Test symbolic dictionaries (call backs)

nano test3.cpp

#include <exodus/exodus.h>

program() {

        var testfilename="test_symbolics";
        createfile("dict_"^testfilename);
        write("F"^FM^0^FM^"ID","dict_"^testfilename,"ID");
        write("S"^FM^FM^"Col1","dict_"^testfilename,"SYMCOL1");

        createfile(testfilename);
        write(1000^FM^2000,testfilename,"3000");

        select("select "^testfilename^" with SYMCOL1 = 3000 or with ID = 3000");

        //should fail since have not installed a function to handle symbolics in this test
        //but it shows that everything else is working
        var key1;
        if (not readnext(key1))
                stop("Cannot readnext (as expected)");
}


g++ test3.cpp -lexodus
./a.out


Expected result is which means everything is working and we can implement symbolic dictionaries in exodus.

NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "dict_test_symbolics_pkey" for table "dict_test_symbolics"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "test_symbolics_pkey" for table "test_symbolics"
PGRES_FATAL_ERROR: ERROR:  pgexodus exodus_call failed. (MVCipc() TEST_SYMBOLICS unknown filename)
Cannot readnext (as expected)