我在gremlin控制台中收到此错误
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]
编辑: 我在回答中还遵循了Jason Plurad的步骤。
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
这是我的janusgraph-cassandra-configurationgraph.properties文件
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
然后我做了
./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
之后
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.
之后
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]
答案 0 :(得分:2)
在ConfiguredGraphFactory docs中,您可能错过了某些事情,或者可能不清楚:
ConfiguredGraphFactory与Gremlin Server一起使用,因此您首先需要进行远程连接。您应该建立会话远程连接,否则所有模板命令都必须在单个行请求中完成。从Gremlin控制台与ConfiguredGraphFactory进行交互时,需要确保将请求发送到远程服务器。通常,您可以在语句前加:>
来完成此操作。或者,您可以使用:remote console
进入远程控制台模式,该模式会将所有命令发送到远程服务器。
您没有提供janusgraph-cassandra.properties
的详细信息,但是最好从分发中打包的配置文件开始。默认情况下,预先打包的分散不使用ConfiguredGraphFactory,因此您可以按照以下步骤进行尝试。
# 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
请注意,gremlin-server.yaml
和gremlin-server-configuration.yaml
具有重大差异。请参阅Chapter 8.7: Configuring JanusGraph Server for ConfiguredGraphFactory中的文档。
特别是gremlin-server-configuration.yaml
定义:
graphs: {
ConfigurationManagementGraph: conf/janusgraph-cql-configurationgraph.properties
}
conf/janusgraph-cql-configurationgraph.properties
定义:
graph.graphname=ConfigurationManagementGraph
在您的帖子中,您很可能会遇到错误,因为conf/janusgraph-cassandra.properties
没有包含正确的graph.graphname
。
此刻,您可以继续在https://docs.janusgraph.org/latest/configuredgraphfactory.html#examples此处列出的示例Gremlin Console会话。如前所述,该示例中的前两个命令是建立远程会话连接并设置远程控制台模式:
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
我创建了一个full gist,其中显示了如何执行此操作的所有步骤。