How to start Titan graph server and connect with gremlin?

Mermoz picture Mermoz · May 6, 2013 · Viewed 11.1k times · Source

I've been playing with Titan graph server for a while now. And my feeling is that, despite an extensive documentation, there is a lack of Getting started from scratch tutorial.

My final goal is to have a titan running on cassandra and query with StartTheShift/thunderdome.

I have seen few ways of starting Titan:

Using Rexster

from this link, I was able to run a titan server with the following steps:

  1. download rexster-server 2.3
  2. download titan 0.3.0
  3. copy all files from titan-all-0.3.0/libs to rexster-server-2.3.0/ext/titan
  4. edit rexster-server-2.3.0/rexster.xml and add (between a ):

    <graph>
        <graph-name>geograph</graph-name>
        <graph-type>com.thinkaurelius.titan.tinkerpop.rexster.TitanGraphConfiguration</graph-type>
        <graph-read-only>false</graph-read-only>
        <graph-location>/Users/vallette/projects/DATA/gdb</graph-location>
        <properties>
              <storage.backend>local</storage.backend>
              <storage.directory>/Users/vallette/projects/DATA/gdb</storage.directory>
              <buffer-size>100</buffer-size>
        </properties>
        <extensions>
          <allows>
            <allow>tp:gremlin</allow>
          </allows>
        </extensions>
    </graph>
    

for a berkeleydb or:

    <graph>
      <graph-name>geograph</graph-name>
      <graph-type>com.thinkaurelius.titan.tinkerpop.rexster.TitanGraphConfiguration</graph-type>
      <graph-location></graph-location>
      <graph-read-only>false</graph-read-only>
      <properties>
            <storage.backend>cassandra</storage.backend>
            <storage.hostname>77.77.77.77</storage.hostname>
      </properties>
      <extensions>
        <allows>
          <allow>tp:gremlin</allow>
        </allows>
      </extensions>
    </graph>

for a cassandra db.

  1. launch the server with ./bin/rexster.sh -s -c rexster.xml
  2. dowload rexster console and run it with bin/rexster-console.sh
  3. you can now connect to your graph with g = rexster.getGraph("geograph")

The problem with this method is that you are connected via rexster and not gremlin so you do not have autocompletion. The advantage is that you can name your database (here geograph).

Using Titan server with cassandra

  1. start the server with ./bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties
  2. create a file called cassandra.local with

    storage.backend=cassandrathrift
    storage.hostname=127.0.0.1
    
  3. start titan gremlin and connect with g = TitanFactory.open("cassandra-es.local")

this works fine.

Using titan server with BerkeleyDB

From this link:

  1. download titan 0.3.0
  2. start the server with ./bin/titan.sh config/titan-server-rexster.xml config/titan-server-berkeleydb.properties
  3. launch titan gremlin: ./bin/gremlin.sh
  4. but once I try to connect to the database (graph) in gremlin with g = TitanFactory.open('graph') it creates a new database called graph in the directory I'm in. If i execute this where my directory (filled) is I get:

    Could not instantiate implementation: com.thinkaurelius.titan.diskstorage.berkeleyje.BerkeleyJEStoreManager

Could someone clarify these process, and tell me what I'm doing wrong. Thanks

Answer

Tim Ludwinski picture Tim Ludwinski · Sep 20, 2013

According to the documentation TitanFactory.open() takes either the name of a config file or the name of a directory to open or create a database in.

If what steven says is true, there would be two ways to connect to the database with a BerkelyDB backend:

  1. Start the database through bin/titan.sh. Connect to the database through the rexster console.

  2. DON'T start the database using bin/titan.sh. Use the gremlin console instead: TitanFactory.open("database-location"). This will open the database. But this does not have a rexster server. Nothing else will be able to access the database but the gremlin console.