Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

gremlin - JanusGraph : Please add a key named "ConfigurationManagementGraph" to the "graphs"

I get the this error in gremlin console

cegprakash@cegprakash:~/workspace/janusgraph-0.2.1-hadoop2$ ./bin/gremlin.sh 

         ,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: janusgraph.imports
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/cegprakash/workspace/janusgraph-0.2.1-hadoop2/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/cegprakash/workspace/janusgraph-0.2.1-hadoop2/lib/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
19:10:12 WARN  org.apache.hadoop.util.NativeCodeLoader  - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.spark
plugin activated: tinkerpop.tinkergraph
gremlin> def graph=ConfiguredGraphFactory.create("mygraph")
org.janusgraph.graphdb.management.utils.ConfigurationManagementGraphNotEnabledException: Please add a key named "ConfigurationManagementGraph" to the "graphs" property in your YAML file and restart the server to be able to use the functionality of the ConfigurationManagementGraph class.
Type ':help' or ':h' for help.
Display stack trace? [yN]

Edit: I also followed Jason Plurad's steps in the answer.

conf/gremlin-server/gremlin-server.yaml

host: 0.0.0.0
port: 8182
scriptEvaluationTimeout: 30000
channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
graphs: {
  ConfigurationManagementGraph: conf/janusgraph-cassandra-configurationgraph.properties
}
plugins:
  - janusgraph.imports
scriptEngines: {
  gremlin-groovy: {
    imports: [java.lang.Math],
    staticImports: [java.lang.Math.PI],
    scripts: [scripts/empty-sample.groovy]}}
serializers:
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: {ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistryV1d0] }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistryV1d0] }}
processors:
  - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
  - { className: org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor, config: { cacheExpirationTime: 600000, cacheMaxSize: 1000 }}
metrics: {
  consoleReporter: {enabled: true, interval: 180000},
  csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},
  jmxReporter: {enabled: true},
  slf4jReporter: {enabled: true, interval: 180000},
  gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
  graphiteReporter: {enabled: false, interval: 180000}}
maxInitialLineLength: 4096
maxHeaderSize: 8192
maxChunkSize: 8192
maxContentLength: 65536
maxAccumulationBufferComponents: 1024
resultIterationBatchSize: 64
writeBufferLowWaterMark: 32768
writeBufferHighWaterMark: 65536

Here is my janusgraph-cassandra-configurationgraph.properties file

gremlin.graph=org.janusgraph.core.ConfiguredGraphFactory
graph.graphname=ConfigurationManagementGraph
storage.backend=cassandrathrift
storage.hostname=127.0.0.1
cache.db-cache = true
cache.db-cache-clean-wait = 20
cache.db-cache-time = 180000
cache.db-cache-size = 0.5

Then I did

./bin/janusgraph.sh clean
Are you sure you want to delete all stored data and logs? [y/N] y
Deleted data in /home/cegprakash/workspace/janusgraph-0.2.1-hadoop2/db
Deleted logs in /home/cegprakash/workspace/janusgraph-0.2.1-hadoop2/log

followed by

cegprakash@cegprakash:~/workspace/janusgraph-0.2.1-hadoop2$ ./bin/janusgraph.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:9200)....... OK (connected to 127.0.0.1:9200).
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.

followed by

cegprakash@cegprakash:~/workspace/janusgraph-0.2.1-hadoop2$ ./bin/gremlin.sh 

         ,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: janusgraph.imports
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/cegprakash/workspace/janusgraph-0.2.1-hadoop2/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/cegprakash/workspace/janusgraph-0.2.1-hadoop2/lib/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
19:35:47 WARN  org.apache.hadoop.util.NativeCodeLoader  - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.spark
plugin activated: tinkerpop.tinkergraph
gremlin> :remote connect tinkerpop.server conf/remote.yaml session
==>Configured localhost/127.0.0.1:8182-[14455470-addc-49ed-ae54-a30de1fd8ae8]
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [localhost/127.0.0.1:8182]-[14455470-addc-49ed-ae54-a30de1fd8ae8] - type ':remote console' to return to local mode
gremlin> def graph=ConfiguredGraphFactory.create("mygraph")
Please add a key named "ConfigurationManagementGraph" to the "graphs" property in your YAML file and restart the server to be able to use the functionality of the ConfigurationManagementGraph class.
Type ':help' or ':h' for help.
Display stack trace? [yN]
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There are a few things that you may have missed or perhaps are not clear in the ConfiguredGraphFactory docs:

ConfiguredGraphFactory is used with a Gremlin Server, so you need to first make a remote connection. You should establish a sessioned remote connection, otherwise all of your template commands must be done in a single line request. When you interact with the ConfiguredGraphFactory from the Gremlin Console, you need to make sure you are sending your requests to the remote server. Typically you would do this by prepending your statements with :>. Alternatively, you could enter the remote console mode with :remote console which sends all commands to the remote server.

You didn't include the details of your janusgraph-cassandra.properties, but it would probably be best if you start with the configuration files that are packaged in the distribution. By default, the pre-packaged distrubtion does not use the ConfiguredGraphFactory, so here are some steps you can take to try it out.

# clean out any previous runs
bin/janusgraph.sh clean
Are you sure you want to delete all stored data and logs? [y/N] y
Deleted data in /opt/janusgraph-0.2.1-hadoop2/db
Deleted logs in /opt/janusgraph-0.2.1-hadoop2/log

# backup the default Gremlin Server configuration
cp conf/gremlin-server/gremlin-server.yaml conf/gremlin-server/gremlin-server.yaml.orig

# make the ConfiguredGraphFactory configuration the default
cp conf/gremlin-server/gremlin-server-configuration.yaml conf/gremlin-server/gremlin-server.yaml

# start Cassandra, Elasticsearch, Gremlin Server
bin/janusgraph.sh start

# start Gremlin Console
bin/gremlin.sh

Be aware that gremlin-server.yaml and gremlin-server-configuration.yaml have significant differences. Refer to the docs in Chapter 8.7: Configuring JanusGraph Server for ConfiguredGraphFactory.

In particular, gremlin-server-configuration.yaml defines:

graphs: {
  ConfigurationManagementGraph: conf/janusgraph-cql-configurationgraph.properties
}

And conf/janusgraph-cql-configurationgraph.properties defines:

graph.graphname=ConfigurationManagementGraph

In your post, you are most likely getting an error because conf/janusgraph-cassandra.properties does not contain the correct graph.graphname.

From this point, you can continue with the example Gremlin Console session listed here https://docs.janusgraph.org/latest/configuredgraphfactory.html#examples. As mentioned previously, the first two commands in the example are to establish the remote sessioned connection and to set the remote console mode:

gremlin> :remote connect tinkerpop.server conf/remote.yaml session
==>Configured localhost/127.0.0.1:8182

gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [localhost:8182]-[5206cdde-b231-41fa-9e6c-69feac0fe2b2] - type ':remote console' to return to local mode

I've created a full gist that shows all the steps on how to do this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...