How to install Strabon for Linux?

How to install Strabon for Linux (Ubuntu 14.04 LTS)? Strabon installation gave me a rough time, so I decided to write this quick guide, Jan. 2016. This is not an attempt to discard Strabon’s guide. Refer there for comments on what you are doing, since I am going to list what I executed only. I assume you already have Java installed.

This page is dedicated to Emmanouil Kapernaros, which helped with the installation on Thursday, with the deadline approaching fast on Sunday. Got him a big chocolate for that!🙂

sudo apt-get install maven
sudo apt-get install mercurial
sudo apt-get install postgresql-9.3
sudo apt-get install postgresql-9.3-postgis-2.1
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
sudo apt-get install postgresql-server-dev-9.3
// Now type in the terminal pg_config --sharedir which gave me /usr/share/postgresql/9.3, so do
POSTGIS_SQL_PATH=/usr/share/postgresql/9.3/contrib/postgis-2.1
sudo -u postgres createdb -E UTF8 -T template0 template_postgis
sudo -u postgres createlang -d  template_postgis plpgsql
sudo -u postgres psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
sudo -u postgres psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
sudo -u postgres psql -d template_postgis -c "VACUUM FULL;"
sudo -u postgres psql -d template_postgis -c "VACUUM FREEZE;"
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datallowconn='false' WHERE datname='template_postgis';"
sudo -u postgres createdb endpoint -T template_postgis
sudo pico /etc/postgresql/9.3/main/postgresql.conf
// and now append (for a machine with 3.8 GiB memory
shared_buffers       =  3GB
effective_cache_size =  3GB
maintenance_work_mem =  1GB
work_mem             =  2GB
geqo_threshold = 15 # keep this value larger that the following two parameters
from_collapse_limit = 14
join_collapse_limit = 14
### Misc
default_statistics_target    = 10000
constraint_exclusion         = on
checkpoint_completion_target = 0.9
wal_buffers                  = 32MB
checkpoint_segments          = 64
### Connections
max_connections              = 10
// now go to /etc/sysctl.conf and append:
kernel.shmmax = 3758096384
kernel.shmall = 3758096384
kernel.shmmni = 4096
// now execute:
sudo sysctl -p
sudo /etc/init.d/postgresql restart
sudo -u postgres psql -c 'VACUUM ANALYZE;' endpoint
sudo apt-get update
sudo apt-get install tomcat7
sudo pico /etc/default/tomcat7
// and find JAVA_OPTS (with ctrl+w) and replace it with:
JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC"
sudo service tomcat7 restart
// open localhost:8080 in a browser, it should say "It works!"
sudo pico /etc/tomcat7/tomcat-users.xml
// between tomcat-users, insert
<user username="endpoint" password="endpoint" roles="manager"/>
// after exiting the file, do:
sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7/webapps/ROOT
////////////////////////////
// Now either you build Strabon (<a href="http://www.strabon.di.uoa.gr/installation-endpoint" target="_blank">Initial install</a>), or you ask for an already compiled .war file
// Now open <your_path>/WEB-INF/connection.properties. My path was (I built from source):
// Strabon/Strabon/endpoint/WebContent and we open in a browser:
// localhost:8080/<name_of_war>, strabonendpoint in my case, navigate to
// Explore/Modify operations -> Configuration and we fill the form according to the connection.properties
// file, we click Connect and will be re-directed to the Query section.
////////////////////////////
// That's it, BUT, let's check:
// Go to linkedopendata.gr/dataset and click on the tar of Rivers and Lakes of Greece. Then
// go to Strabon, navigate to Explore/Modify operations -> Store and fill the URI input with:
// file:///<path_to_file>/rivers_lakes.rdf we press Store and after several minutes
// you should see a Data stored successfully!
// Notice that we do not need to store the data everytime we start Strabon.
////////////////////////////
// Go to Discovery Queries and click on the "Find the number of triples that appear in the dataset."
// query, which returns 24550 (well the dataset might change by the time you read this!)
// Now let's check if display on map works fine. Copy this query:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX strdf: <http://strdf.di.uoa.gr/ontology#>
PREFIX geos: <http://www.opengis.net/ont/geosparql#>
PREFIX rlo: <http://geo.linkedopendata.gr/water-bodies/ontology/>

SELECT ?l_geo_wkt
WHERE {
  ?l rdf:type rlo:Λίμνη .
  ?l rlo:είναι_το_υδάτινο_σώμα ?l_id .
  ?l_id geos:hasGeometry ?l_geo .
  ?l_geo geos:asWKT ?l_geo_wkt .
  ?l1 rdf:type rlo:Λίμνη .
  ?l1 rlo:είναι_το_υδάτινο_σώμα ?l_id1 .
  ?l_id1 geos:hasGeometry ?l_geo1 .
  ?l_geo1 geos:asWKT ?l_geo_wkt1 .
  FILTER(strdf:disjoint(?l_geo_wkt1, ?l_geo_wkt))
}
LIMIT 5

// and select Output Format: KML and View Result: On a map (localhost).
// On execution, it should display a map and we are all happy!

Throughout the course, another student collected these tips:

1) Όταν σας βγάζει  πρόβλημα σχετικά με τη μνήμη (κατά το store ή  το query) πηγαίνετε στο /var/lib/tomcat7/bin/catalina.sh και στο τέλος  γράψτε: CATALINA_OPTS="-Xms512M -Xmx4096M".  Το πρώτο όρισμα είναι η ελάχιστη μνήμη και το δεύτερο ο  μέγιστη, οπότε  θέστε τα αντίστοιχα ορίσματα ανάλογα με τη διαθέσιμη μνήμη που έχετε.

Παρόμοια λύση:
Το πρόβλημα λύθηκε δημιουργώντας το /usr/share/tomcat7/bin/setenv.sh με περιεχόμενο JAVA_OPTS="-Xms1024m -Xmx2048m".

2)  Όταν σας βγάζει μήνυμα λάθους the connection was reset, κάνετε restart  τον tomcat. (Αν είστε σε ubuntu μπορείτε να κάνετε sudo service tomcat  restart). Αν το μήνυμα λάθους αφορά connection της postgres, κάνετε  restart και την postgres.  

3) Το μήνυμα που  σας βγάζει ότι αν δεν έχετε κάνει log in δεν μπορείτε να κάνετε update  εκτός αν τρέχετε σε localhost, δεν σας αφορά, γιατί τρέχετε σε localhost  🙂 

4) Σε περίπτωση που σας βγάζει τους ελληνικούς χαρακτήρες με περίεργη κωδικοποίηση, 
κοιτάξτε το section known issues εδώ: http://hg.strabon.di.uoa.gr/Strabon/file/ba8fb069b2ca/README ή και εδώ: http://cgi.di.uoa.gr/~pms509/past_projects/2014-2015/Strabon_Installation_Windows.txt

5)  Η postgres έχει by default έναν χρήστη με όνομα postgres που μπορεί να  διαχειρίζεται βάσεις. Άρα σε κάθε εντολή postgres θα πρέπει πρώτα να  κάνετε sudo -u postgres και μετά createdb/dropdb/psql κλπ. Αλλιώς,  μπορείτε να φτιάξετε χρήστη με το username σας (για να μην αλλάζετε  χρήστη).

6) Όταν κάνετε store αρχείο από τον  τοπικό σας δίσκο (με file:///) ή που έχετε ανεβάσει εσείς σε κάποιον  server, φτιάξτε τα δικαιώματα του αρχείου ανάλογα. 

7) Σε error
org.openrdf.sail.rdbms.exceptions.RdbmsQueryEvaluationException:
org.postgresql.util.PSQLException: FATAL: terminating connection due to
administrator command SELECT t0.subj, CASE WHEN u_s.value IS NOT NULL THEN
u_s.value WHEN b_s.value IS NOT NULL THEN b_s.value WHEN lu_s.value IS NOT
NULL THEN lu_s.value END, t0.pred, CASE WHEN u_p.value IS NOT NULL THEN
u_p.value WHEN lu_p.value IS NOT NULL THEN lu_p.value END, t0.obj, CASE
WHEN u_o.value IS NOT NULL THEN u_o.value WHEN b_o.value IS NOT NULL THEN
b_o.value WHEN l_o.value IS NOT NULL THEN l_o.value WHEN ll_o.value IS NOT
NULL THEN ll_o.value WHEN lu_o.value IS NOT NULL THEN lu_o.value END,
g_o.value, d_o.value FROM (SELECT 0 AS ctx, 0 AS subj, 0 AS pred, 0 AS obj
WHERE 1=0) t0 LEFT JOIN uri_values u_s ON (u_s.id = t0.subj) LEFT JOIN
bnode_values b_s ON (b_s.id = t0.subj) LEFT JOIN long_uri_values lu_s ON
(lu_s.id = t0.subj) LEFT JOIN uri_values u_p ON (u_p.id = t0.pred) LEFT
JOIN long_uri_values lu_p ON (lu_p.id = t0.pred) LEFT JOIN uri_values u_o
ON (u_o.id = t0.obj) LEFT JOIN bnode_values b_o ON (b_o.id = t0.obj) LEFT
JOIN label_values l_o ON (l_o.id = t0.obj) LEFT JOIN long_label_values
ll_o ON (ll_o.id = t0.obj) LEFT JOIN long_uri_values lu_o ON (lu_o.id =
t0.obj) LEFT JOIN datatype_values d_o ON (d_o.id = t0.obj) LEFT JOIN
language_values g_o ON (g_o.id = t0.obj)

Τρέχουμε :
sudo service postgres restart
sudo service tomcat7 restart

8) Για να εμφανίσουμε αποτελέσματα σε χάρτη:
Επιλέγουμε format KML, show on map (localhost). 
Εάν παίρνουμε κενό tab ως αποτέλεσμα:
sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7/webapps/ROOT

9) Κάνουμε store ΧΩΡΙΣ inference. Χρσιμοποιούμε filter functions αντί για predicates για γεωμετρικούς υπολογισμούς.

Have questions? Comments? Did you find a bug? Let me know!😀
Page created by G. (George) Samaras (DIT)