Log of an installation of libexodus on Centos 5.3: Difference between revisions

From NEOSYS Dev Wiki
Jump to navigationJump to search
m (Reverted edits by Anecada (Talk) to last revision by Steve)
 
(29 intermediate revisions by 3 users not shown)
Line 2: Line 2:


  sudo yum update
  sudo yum update
  sudo yum install boost-devel postgresql-devel gcc-c++ subversion postgresql-server
 
  sudo yum install gcc-c++ boost-devel postgresql-devel postgresql-server
 
Centos needs you to start the database manually. Ubuntu doesnt.


  sudo /etc/init.d/postgresql start
  sudo /etc/init.d/postgresql start
Line 8: Line 11:
=== Exodus ===
=== Exodus ===


  cd ~
  wget http://exodusdb.googlecode.com/files/exodus-10.10.5.tar.gz
mkdir exodus
tar xvfz exodus-10.10.5.tar.gz
cd exodus
  cd exodus-10.10.5
svn co http://svn.neosys.com/svn/trunk
  cd trunk/exodus


  ./configure
  ./configure
  make
  make && sudo make install
sudo make install


sudo nano /etc/ld.so.conf
=== Setting up Postgres for Exodus ===
 
... and add the following line  (note: NO preceding word include)
 
/usr/local/lib
 
register the new libraries
 
sudo /sbin/ldconfig


make a pointer to the include files
==== Register the pgexodus plugin ====


sudo ln -s /usr/local/include/exodus-9.6/exodus /usr/local/include/exodus
Assume identity of a postgres superuser
 
 
 
=== Setting up Postgres for Exodus ===
 
become user postgres and get into postgres command prompt


  sudo su - postgres
  sudo su - postgres


psql
On Mac OSX only, ensure postgres can be found. Change 8.3 to your version) and check pg_config can run)


create a user and database for exodus. Use the given password for now.
PATH=/Library/PostgreSQL/8.3/bin/:$PATH
pg_config


CREATE ROLE exodus LOGIN
Log in to postgres as a postgres superuser and connect to database template1
  PASSWORD 'somesillysecret'
  CREATEDB CREATEROLE;
CREATE DATABASE exodus
  WITH ENCODING='UTF8'
    OWNER=exodus;


  \connect exodus
psql -U postgres -d template1
  \connect template1


{{postgres function installation}}
{{postgres function installation}}
Line 75: Line 58:


For more information see http://www.postgresql.org/docs/8.1/static/app-psql.html
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
Quit postgres command prompt
Line 80: Line 74:
  \q
  \q


Unless you are only going to run Exodus as user "exodus" from the local machine, grant login from 127.0.0.1 using username/unencrypted password (instead of only logged-in username without password)
==== Ensure Exodus can logon to postgres ====


For more info see http://developer.postgresql.org/pgdocs/postgres/auth-pg-hba-conf.html
===== Edit pg_hba.conf =====


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 "ident sameuser" which means the logged-in username without password) For more info see http://developer.postgresql.org/pgdocs/postgres/auth-pg-hba-conf.html
Redhat/Centos/MacOSX
  nano ~/data/pg_hba.conf
  nano ~/data/pg_hba.conf
or for Ubuntu
nano /etc/postgresql/8.3/main/pg_hba.conf


or for Ubuntu
Allow any postgres user to login with a password via interprocess tcp/ip.
sudo nano /etc/postgresql/8.3/main/pg_hba.conf
 
comment out the following line.


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
  #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.
and add the following:


local  all        postgres                          ident sameuser
  host    all        all        127.0.0.1/32          md5
  host    all        all        127.0.0.1         255.255.255.255  md5


quit postgres user
quit postgres user
Line 104: Line 101:
Reload Postgres
Reload Postgres


Redhat/Centos
  sudo /etc/init.d/postgresql reload
  sudo /etc/init.d/postgresql reload
or
or Ubuntu
  sudo /etc/init.d/postgresql-8.3 restart
  sudo /etc/init.d/postgresql-8.3 reload
or MacOSX
sudo su postgres
/Library/PostgreSQL/8.3/bin/pg_ctl reload -D /Library/PostgreSQL/8.3/data
exit


=== Testing ===
=== Testing ===


nano tester.cpp
{{exodus console first steps}}
 
<pre>
#include <exodus/exodus.h>
program() {
date().oconv("D").outputln();
print(oconv(date(),"D"));
createfile("exodustest");
}
</pre>
 
g++ tester.cpp -lexodus -I/usr/local/include/exodus
 
./a.out
 
27 JUN 2009
27 JUN 2009
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "exodustest_pkey" for table "exodustest"
 
nano testsym.cpp
 
<pre>
 
#include <exodus.h>
 
program() {
 
        createfile("dict_test_symbolics");
        write("F"^FM^0^FM^"ID","dict_test_symbolics","ID");
        write("S"^FM^FM^"Col1","dict_test_symbolics","SYMCOL1");
 
        createfile("test_symbolics");
        var rec=1000^FM^2000;
        write(rec,"test_symbolics","3000");
 
        select("select test_symbolics 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 (readnext(key1))
                stop("Cannot readnext (as expected");
}
 
 
</pre>
 
g++ testsym.cpp -lexodus -I/usr/local/include/exodus
 
./a.out
 
 
Expected result is which means everything is working and we can implement symbolic dictionaries in exodus.
 
<pre>
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)
</pre>

Latest revision as of 14:01, 24 November 2010

Preparation

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

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

sudo /etc/init.d/postgresql start

Exodus

wget http://exodusdb.googlecode.com/files/exodus-10.10.5.tar.gz
tar xvfz exodus-10.10.5.tar.gz
cd exodus-10.10.5
./configure
make && sudo make install

Setting up Postgres for Exodus

Register the pgexodus plugin

Assume identity of a postgres superuser

sudo su - postgres

On Mac OSX only, 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 as a postgres superuser and connect to database template1

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

Edit pg_hba.conf

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 "ident sameuser" which means the logged-in username without password) For more info see http://developer.postgresql.org/pgdocs/postgres/auth-pg-hba-conf.html

Redhat/Centos/MacOSX

nano ~/data/pg_hba.conf

or for Ubuntu

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

Allow any postgres user to login with a password via interprocess tcp/ip.

comment out the following line.

#host    all         all         127.0.0.1/32          ident sameuser

and add the following:

host    all         all         127.0.0.1/32           md5

quit postgres user

exit

Reload Postgres

Redhat/Centos

sudo /etc/init.d/postgresql reload

or Ubuntu

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

or MacOSX

sudo su postgres
/Library/PostgreSQL/8.3/bin/pg_ctl reload -D /Library/PostgreSQL/8.3/data
exit

Testing

Try the following commands.

Command Comment
EDITING AND COMPILING
edic hello edic=edit+compile+catalog. Creates a skeleton hello.cpp file using nano editor. edic will only compile on exit if saved, so make some change before you exit.
hello Run it
compile hello compile without editing
edic testsort Browse a sample exodus program showing all fundamental database operations including dictionaries and list.
compile testsort compile the preinstalled test program
testsort Run it to generate some data and inspect the output
DATABASE OPERATIONS
listfiles quick tool avoiding need to use any database client
list myclients text output - no page/column headers just yet sorry
list myclients {H} html output (port of a fully blown LIST replacement in heavy production use since 2000)
list dict_myclients NB the underscore after "dict" is *required*. "dict(SPACE)myclients" wont work
list dict_voc if you understand this then you understand your pick
edir myclients SB001 you can edit data or dictionaries directly. edir="edit record"
delete myclients SB001 useful command line tool
createfile tempfile ditto
deletefile tempfile ditto
createindex myclients CLIENT_TYPE speeds up select commands on the indexed fields in the traditional way
deleteindex myclients CLIENT_TYPE filenames are case insensitive, keys and fieldnames are CASE SENSITIVE

If you get the following error then you have not completed the installation of the Exodus plugin for Postgres.

PGRES_FATAL_ERROR: ERROR: function exodus_extract_text(bytea, integer, integer, integer) does not exist