How to start Titan graph server and connect with g

2019-02-02 11:32发布

问题:

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

回答1:

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.



回答2:

With Titan Server/BerkeleyDB, you should attempt to connect via RexPro or REST (Thunderdome should connect over REST). You can't open another Titan-based connection to BerkeleyDB as Titan Server already owns that.

This is different than Titan Server/Cassandra where connectivity occurs over RexPro or REST, but also through embedded Cassandra which enables connectivity over thrift via TitanFactory.open('graph')



回答3:

It's also possible to access Titan from python using these two libraries:

https://github.com/StartTheShift/thunderdome

and

https://github.com/espeed/bulbs.

Thunderdome is currently Titan-specific, and bulbs is generic. A (possibly biased) comparison between Thunderdome and Bulbs is given on Thunderdome's wiki: https://github.com/StartTheShift/thunderdome/wiki/Bulbs-VS-thunderdome

If you need autocompletion, you can use iPython and enable autocompletion in your iPython config.