How to install PLJava and integrate it with PostgreSQL

Here you'll find a place for solutions and hints.

Please use one of the support subforums below for questions or if you have any issues and need support.

How to install PLJava and integrate it with PostgreSQL

Postby SobRogue » May 7th, '15, 17:13

edit doktor5000: Howto split out from original thread viewtopic.php?f=8&t=9721

Hello,

As it turns out, there was something funny going on with the install I had (probably self-inflicted…). Anyway, a fresh install, seems to have fixed all the problems. But for completeness I thought I’d document the PLJava install process –as I was not able to find much on the topic here. (I apologize for any poor practices or bad assumptions –as I’m still relatively new to linux)

The install is as followed:
-Install Oracle JDK (It is recommended for PLJava –OpenJDK might work but I haven’t tested)
-Install/Configure PostGreSQL
-Install PLJava Dependencies (gcc, gcc-c++, and Maven)
-Package/Deploy PLJava on Database

1) Install Oracle JDK
a. Download appropriate Oracle JDK binary (I used the tar.gz)
b. Unzip to location
Code: Select all
tar –zxvf jdk1.7.0_75 /usr/lib/jvm/jdk1.7.0_75

c. Add/Update defaults to use Oracle JDK instead of OpenJDK
Code: Select all
Update –-install /usr/bin/java java /usr/lib/jvm.jdk1.7.0_75/bin/java 1
Update -–install /usr/bin/javac javac /usr/lib/jvm.jdk1.7.0_75/bin/javac 1
Update –-install /usr/bin/jar jar /usr/lib/jvm.jdk1.7.0_75/bin/jar 1
Update –-install /usr/bin/javaws javaws /usr/lib/jvm.jdk1.7.0_75/bin/javaws 1
Update –-config java -->(Select Oracle JDK dir as default)

d. Verify that java is set to Oracle JDK
Code: Select all
java –version

Should get something like-
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b15)
Java HotSpot(TM) Client VM (build 24.79-b02, mixed mode)

e. Create link to JRE libraries
i.Create /etc/ld.so.conf.d/postgres.conf
Code: Select all
vim /etc/ld.so.conf.d/postgres.conf

Add the following (depending on bitness)
32bit:
/usr/lib/jvm/jdk1.7.0_79/jre/lib
/usr/lib/jvm/jdk1.7.0_79/jre/lib/i386/server

64bit:
/usr/lib/jvm/jdk1.7.0_79/jre/lib
/usr/lib/jvm/jdk1.7.0_79/jre/lib/amd64/server




2)Install PostGreSQL
a.I used the “Mageia Software-Manager” with the default repos that ship
b.Search for ‘postgresql9.3’ (the ‘Select All’ option was used, and select/install the following packages:
i.postgresql9.3
ii.postgresql9.3-devel
iii.postgresql9.3-server
iv.pgadmin3
v.Naturally I accepted/installed all dependency’s too.
I imagine it would be the same as-
Code: Select all
urpmi postgresql9.3 postgresql9.3-devel postgresql9.3-server pgadmin3

c. Note the default directories (atleast for me) where-
Data => /var/lib/pgsql/data
Lib => /usr/lib/postgres

d. Update posgres.conf to allow all users to connect (or limit to your choice)
Code: Select all
vim /var/lib/pgsql/data/postgresql.conf

ii. Update:
#listen_addresses = ‘localhost’
to
listen_addresses = ‘*’

e. Update pg_hba.conf to allow all users to connect (or limit to your choice)
Code: Select all
vim /var/lib/pgsql/data/pg_hba.conf

ii. Add the following line under “# IPv4 local connections: “ (This will allow all to connect)
host all all 0.0.0.0/0 md5




3) Install PLJava Prerequisite

Once again I used the “Mageia Software-Manager”
a. Search for ‘gcc’ (with both options set to ‘All’, and select/install the following packages:
i. gcc
ii. gcc-c++
iii. gcc-cpp
iv. Plus dependencies
Or-
Code: Select all
urpmi gcc gcc-c++ gcc-cpp

b. For Maven, I downloaded and extracted maven to some location
Say:
/home/apache-maven-3.3.3/




4) Compile/Install PLJava
a. Download and Unzip the PLJava project from https://github.com/tada/pljava/archive/master.zip, to some location
i. I placed it here:
/home/pljava-master/


b. Package PLJava using Maven
i. Navigate to the pljava-master dir and run:
Code: Select all
/home/apache-maven-3.3.3/bin/mvn package

(It will spew lots of stuff –even looks like some exceptions are thrown -but the end should list 4-5 successful steps)

c. The above command should create a tar inside
/home/pljava-master/packaging/target/pljava-pg9.3-${naraol}.tar.gz


d. Unzip this file (I did it the same directory) -It should create/contain a pljava folder

e. Move pljava.jar and pljava.so from inside this newly created pljava folder, into the postgres lib directory
Code: Select all
   mv /home/pljava-master/packaging/target/pljava/pljava.jar /usr/lib/postgresql/pljava.jar
   mv /home/pljava-master/packaging/target/pljava/pljava.so /usr/lib/postgresql/pljava.so


f. Change permission of these to match other files here
Code: Select all
   Chmod 755 /usr/lib/postgresql/pljava.jar
   Chmod 755 /usr/lib/postgresql/pljava.so


g. Update the postgres.conf with pljava classpath
Code: Select all
vim /var/lib/pgsql/data/postgresql.conf

i. Add the following line to end of file:
pljava.classpath = '/usr/lib/postgresql/pljava.jar'


h. Restart Postgres for these changes to take effect
I’m not sure what the Posgres credentials are, so I use root to get to the postgres user.
Code: Select all
su
su Postgres
pg_ctl restart

i. Press return a few times to leave the final restart message

i. Install PLJava on a database -->choose a database to install PLJava onto, for the purpose of this write-up I will use the ‘postgres’ since it exists from install

j. Locate the install.sql, found in the unzipped pljava folder (it might be worthwhile to move this –as you will need it to install PLJava on any subsequent DB)
i. If you are running as Postgres user:
Code: Select all
psql –d postgres –f /home/pljava-master/packaging/target/pljava/install.sql

ii. Otherwise:
Code: Select all
su postgres –c “psql –d [YourDBHere] –f /home/pljava-master/packaging/target/pljava/install.sql


k. You should see a list of tables created, but without the errors I initially reported above.

l. To validate, a new schema, called sqlj should have been created in the database chosen.

I hope this helps, and I apologize if it is too in depth, but I figured more details would be better.
Last edited by SobRogue on May 7th, '15, 23:00, edited 2 times in total.
SobRogue
 
Posts: 4
Joined: Apr 16th, '15, 22:33

Re: How to install PLJava and integrate it with PostgreSQL

Postby doktor5000 » May 7th, '15, 21:03

Thanks for sharing :D
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17659
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany


Return to The magician suggests...

Who is online

Users browsing this forum: No registered users and 1 guest

cron