TITAN DB SETUP WITH CASSANDRA

CONNECT AND CONFIGURATION OF TITAN-DB WITH CASSANDRA:-
Step 1:
Download Cassandra Version: apache-cassandra-3.5 .
Downlaod TitanDB Version: titan-1.0.0-hadoop1.
Step 2 :
Extract both downloads ,say in :-
/var/lib/cassandra and /var/lib/titan respectively.
Step 3: Configure cassandra:
If you’ve installed Cassandra with a deb or rpm package, the directories that Cassandra will use should already be created an have the correct permissions. Otherwise, you will want to check the following config settings from conf/cassandra.yaml: data_file_directories (/var/lib/cassandra/data), commitlog_directory (/var/lib/cassandra/commitlog), and saved_caches_directory (/var/lib/cassandra/saved_caches). Make sure these directories exist and can be written to.
By default, Cassandra will write its logs in /var/log/cassandra/. Make sure this directory exists and is writeable, or change this line in conf/log4j-server.properies:
log4j.appender.R.File=/var/log/cassandra/system.log
Note that in Cassandra 2.1+, the logger in use is logback, so change this logging directory in your conf/logback.xml file such as:
<file>/var/log/cassandra/system.log</file>
JVM-level settings such as heap size can be set in conf/cassandra-env.sh.
Step 3: Start Cassandra
And now for the moment of truth, start up Cassandra by invoking ‘bin/cassandra -f’ from the command line1. The service should start in the foreground and log gratuitously to the console. Assuming you don’t see messages with scary words like “error”, or “fatal”, or anything that looks like a Java stack trace, then everything should be working.
Press “Control-C” to stop Cassandra.
Step 4:-
Configure Titan to run backend as cassandra:-
you can use titan with cassandra in two ways :-
4.1) The default inbuilt cassandra and cassandrathrift – DB available with titan, where it will run the node tool and elastic search(for index storage back end db) automatically :-
:To run titan using the default configuration you need to run the :-
bin/titan.sh start
Forking Cassandra…
Running `nodetool statusthrift`. OK (returned exit status 0 and printed string “running”).
Forking Elasticsearch…
Connecting to Elasticsearch (127.0.0.1:9300)…. OK (connected to 127.0.0.1:9300).
Forking Gremlin-Server…
Connecting to Gremlin-Server (127.0.0.1:8182)…. OK (connected to 127.0.0.1:8182).
Run gremlin.sh to connect.
Then Connect to gremlin :-
bin/gremlin.sh
\,,,/
(o o)
—–oOOo-(3)-oOOo—–
plugin activated: aurelius.titan
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
11:05:19 INFO org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph – HADOOP_GREMLIN_LIBS is set to: /var/lib/titan/titan-1.0.0-hadoop1/lib
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.tinkergraph
gremlin> Gremlin.version()
==>3.0.1-incubating
gremlin> Titan.version()
==>1.0.0
4.2)Second way is to Configure your install cassandra with titan to use as backend.
To configure your installed Cassandra you need to edit the properties file present in conf folder.
Edit conf/titan-cassandra-es.properties to be as follows:
gremlin.graph=com.thinkaurelius.titan.core.TitanFactory
# Other values: cassandrathrift, astyanax (synonym: cassandra), embeddedcassandra, inmemory
storage.backend=cassandra
storage.hostname=127.0.0.1
# Index backend
index.search.backend=elasticsearch
index.search.directory=/tmp/es
index.search.elasticsearch.local-mode=true
index.search.elasticsearch.client-only=false
Start Cassandra
Go in cassandra director till bin path :-
In another command window start Cassandra using cassandra -f command.
➜ ~ cassandra -f
Then we need to start the NODETOOL Server :-
Go in cassandra director till bin path :-
>bin/nodetool statusthrift
not running
>/var/lib/cassandra/apache-cassandra-3.5$ bin/nodetool enablethrift
>/var/lib/cassandra/apache-cassandra-3.5$ bin/nodetool statusthrift
running
Start Your Titan Server :-
YOU DONT NEED TO START THE THE TITAN SERVER THIS TIME ,
AS MANUALLY YOU HAVE STARTED CASSANDRA , NODETOOL , AND IF REQUIRED(ELASTIC SEARCH/SOLR).
Connect with titan Db using the Gremlin Console :-
bin/gremlin.sh
\,,,/
(o o)
—–oOOo-(3)-oOOo—–
plugin activated: aurelius.titan
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.tinkergraph
gremlin> Gremlin.version()
==>3.0.1-incubating
gremlin> Titan.version()
==>1.0.0
//HERE YOU ARE SPECIFYING THAT YOU WANT TO CREATE A GRAPH AND ITS KEYSPACE IN CASSANDRA
gremlin> g = TitanFactory.open(‘conf/titan-cassandra-es.properties’)
==>standardtitangraph[cassandra:[127.0.0.1]]
/********* LETS SEE THE RESULT IN CASSANDRA ************/
Check the cassandra log or on cassandra console , and you will see that a titan keyspace is created .:-
cqlsh:titan> describe keyspaces;
titan system_auth mykeyspace system_traces
system_schema system system_distributed
cqlsh:>use titan;
cqlsh:titan>
cqlsh:titan> describe tables;
titan_ids edgestore system_properties_lock_
edgestore_lock_ graphindex_lock_ graphindex
txlog systemlog system_properties
/********* NOW LETS RETURN BACK TO GREMLIN SERVER ************/
gremlin> g1 = g.traversal()
==>graphtraversalsource[standardtitangraph[cassandra:[127.0.0.1]], standard]
gremlin> g1.V()
gremlin> g1.V().count()
==>0
Create Verties:-
/********* LETS SEE THE RESULT IN CASSANDRA ************/
Check the cassandra log or on cassandra console , and you will see that a titan keyspace is created .:-
cqlsh:titan> describe keyspaces;
titan system_auth mykeyspace system_traces
system_schema system system_distributed
cqlsh:>use titan;
cqlsh:titan>
cqlsh:titan> describe tables;
cqlsh:titan> select * from titan_ids;
SOme Test Analysis on gremlin using the Built-In-Graphs
gremlin> g = TinkerFactory.createClassic()
==>tinkergraph[vertices:6 edges:6]
gremlin> input = g.V(2,3,4).toList()
==>v[2]
==>v[3]
==>v[4]
gremlin> sm = g.of().inject(input).unfold().in().groupCount().next().sort { -it.getValue() }
==>v[1]=3
==>v[4]=1
==>v[6]=1
gremlin> m = sm.iterator().next().getValue()
==>3
gremlin> result = sm.grep { it.getValue() == m }*.getKey()
==>v[1]
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TO Display out from titan in json format:-
gremlin> graph = TitanFactory.open(‘conf/titan-cassandra-es.properties’)
==>standardtitangraph[cassandra:[127.0.0.1]]
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> f = new FileOutputStream(“vertex-1.json”)
==>java.io.FileOutputStream@702b55af
gremlin> graph.io(graphson()).writer().create().writeVertex(f, g.V(4120).next(), BOTH)
==>null
gremlin> f.close()
==>null
OUTPUT:_
check the output more clearly at:-
http://jsonviewer.stack.hu/
OR
///in xml format and view in cytoScape
g = TitanFactory.open(‘cassandra:127.0.0.1’)
os = new FileOutputStream(“UserGraph.xml”)
g.io(graphml()).writer().normalize(true).create().writeGraph(os, g)
Reblogged this on pranjut.
Reblogged this on Bharat Singh.
I am trying to do this setup on windows. ( downloaded and extracted 1.titan-cassandra-0.4.4.zip 2.apache-cassandra-3.7-bin.tar.gz)
Steps :
1.Started cassandra.bat from apache-cassandra-3.7/bin
2.nodetool.bat enablethrift
3.Started Gremlin.bat
\,,,/
(o o)
—–oOOo-(_)-oOOo—–
gremlin> Gremlin.version()
==>2.4.0
gremlin> Titan.version()
==>0.4.4
gremlin> conf = new BaseConfiguration()
==>org.apache.commons.configuration.BaseConfiguration@59a008ba
gremlin> conf.setProperty(‘storage.backend’,’cassandra’)
==>null
gremlin> conf.setProperty(‘storage.hostname’,’localhost’)
==>null
gremlin> conf.setProperty(‘storage.keyspace’,’titan1′)
==>null
gremlin> g = TitanFactory.open(conf)
Could not instantiate implementation: com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager
Display stack trace? [yN] N
gremlin> g = TitanFactory.open(conf)
==>titangraph[cassandra:localhost]
gremlin> g1 = g.traversal()
No signature of method: groovy.lang.MissingMethodException.traversal() is applicable for argument types: () values: []
Display stack trace? [yN]
Cassandra Result :
cqlsh> describe keyspaces;
system_auth titan system_distributed titan1
system_schema system system_traces
cqlsh> use titan1;
cqlsh:titan1> show tables;
Improper show command.
cqlsh:titan1> describe tables;
titan_ids vertexindex edgestore vertexindex_lock_
edgestore_lock_ edgeindex system_properties
cqlsh:titan1>
Anything i am missed ? Can you please me resolving the above error
I think its the problem of your version , I tried with the following versions :-
Download Cassandra Version: apache-cassandra-3.5 .
Download TitanDB Version: titan-1.0.0-hadoop1.
Please check the version compatibility file :
http://s3.thinkaurelius.com/docs/titan/1.0.0/version-compat.html
Hi,
I am trying to install on Windows.
Downloaded
1.apache-cassandra-3.7
2.titan-cassandra-0.4.4
Steps done:
1. Started Cassandra ( cassandra.bat)
2. nodetool.bat enablethrift
3.Started Gremlin.bat
\,,,/
(o o)
—–oOOo-(_)-oOOo—–
gremlin> Gremlin.version()
==>2.4.0
gremlin> Titan.version()
==>0.4.4
gremlin> conf = new BaseConfiguration()
==>org.apache.commons.configuration.BaseConfiguration@59a008ba
gremlin> conf.setProperty(‘storage.backend’,’cassandra’)
==>null
gremlin> conf.setProperty(‘storage.hostname’,’localhost’)
==>null
gremlin> conf.setProperty(‘storage.keyspace’,’titan1′)
==>null
gremlin> g = TitanFactory.open(conf)
Could not instantiate implementation: com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager
Display stack trace? [yN] N
gremlin> g = TitanFactory.open(conf)
==>titangraph[cassandra:localhost]
gremlin> g1 = g.traversal()
No signature of method: groovy.lang.MissingMethodException.traversal() is applicable for argument types: () values: []
Display stack trace? [yN] y
groovy.lang.MissingMethodException: No signature of method: groovy.lang.MissingMethodException.traversal() is applicable for argument types: () values: []
Anything i missed to do.
Can you help in resolving this issue