Janusgraph安装

安装

Docker安装JanusGraph

JanusGraph提供Docker image,使得其能在Docker容器中运行。下面就举例如何使用Docker技术来安装和运行JanusGraph:

$ docker run -it -p 8182:8182 janusgraph/janusgraph

运行docker命令,获取janusgraph的Dockerimage并运行于Docker容器,8182端口作为服务端口暴露对外。启动日志如下:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/janusgraph/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/janusgraph/lib/logback-classic-1.1.3.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]
0    [main] INFO  com.jcabi.manifests.Manifests  - 110 attributes loaded from 283 stream(s) in 130ms, 110 saved, 3770 ignored: ["Agent-Class", "Ant-Version", "Archiver-Version", "Automatic-Module-Name", "Bnd-LastModified", "Boot-Class-Path", "Branch", "Build-Date", "Build-Host", "Build-Id", "Build-Java-Version", "Build-Jdk", "Build-Job", "Build-Number", "Build-Timestamp", "Build-Version", "Built-At", "Built-By", "Built-Date", "Built-OS", "Built-On", "Built-Status", "Bundle-ActivationPolicy", "Bundle-Activator", "Bundle-BuddyPolicy", "Bundle-Category", "Bundle-ClassPath", "Bundle-ContactAddress", "Bundle-Description", "Bundle-DocURL", "Bundle-License", "Bundle-ManifestVersion", "Bundle-Name", "Bundle-NativeCode", "Bundle-RequiredExecutionEnvironment", "Bundle-SymbolicName", "Bundle-Vendor", "Bundle-Version", "Can-Redefine-Classes", "Change", "Class-Path", "Created-By", "DSTAMP", "DynamicImport-Package", "Eclipse-BuddyPolicy", "Eclipse-ExtensibleAPI", "Embed-Dependency", "Embed-Transitive", "Export-Package", "Extension-Name", "Extension-name", "Fragment-Host", "Gradle-Version", "Gremlin-Lib-Paths", "Gremlin-Plugin-Dependencies", "Gremlin-Plugin-Paths", "Ignore-Package", "Implementation-Build", "Implementation-Build-Date", "Implementation-Title", "Implementation-URL", "Implementation-Vendor", "Implementation-Vendor-Id", "Implementation-Version", "Import-Package", "Include-Resource", "JCabi-Build", "JCabi-Date", "JCabi-Version", "Java-Vendor", "Java-Version", "Main-Class", "Manifest-Version", "Maven-Version", "Module-Email", "Module-Origin", "Module-Owner", "Module-Source", "Originally-Created-By", "Os-Arch", "Os-Name", "Os-Version", "Package", "Premain-Class", "Private-Package", "Provide-Capability", "Require-Bundle", "Require-Capability", "Scm-Connection", "Scm-Revision", "Scm-Url", "Specification-Title", "Specification-Vendor", "Specification-Version", "TODAY", "TSTAMP", "Time-Zone-Database-Version", "Tool", "X-Compile-Elasticsearch-Snapshot", "X-Compile-Elasticsearch-Version", "X-Compile-Lucene-Version", "X-Compile-Source-JDK", "X-Compile-Target-JDK", "hash", "implementation-version", "mode", "package", "service", "url", "version"]
1    [main] INFO  org.apache.tinkerpop.gremlin.server.GremlinServer  - 3.4.1
         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----

100  [main] INFO  org.apache.tinkerpop.gremlin.server.GremlinServer  - Configuring Gremlin Server from /etc/opt/janusgraph/gremlin-server.yaml
...
...
3965 [gremlin-server-boss-1] INFO  org.apache.tinkerpop.gremlin.server.GremlinServer  - Gremlin Server configured with worker thread pool of 1, gremlin pool of 8 and boss thread pool of 1.
等待服务启动完成后,就可以启动Gremlin Console来连接新安装的janusgraph server:
$ bin/gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182

为了方便起见,这里在同一台机器同时安装JanusGraph Server和Gremlin Console Client:

首先在机器上创建Docker容器来运行JanusGraph Server。

$ docker run --name janusgraph-default janusgraph/janusgraph:latest

然后在这台机器上再另启一个容器来运行Gremlin Console Client并连接运行中的Janusgraph Server。

$ docker run --rm --link janusgraph-default:janusgraph -e GREMLIN_REMOTE_HOSTS=janusgraph \
    -it janusgraph/janusgraph:latest ./bin/gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured janusgraph/172.17.0.2:8182

本地安装

JanusGraph运行需要依赖Java 8 SE,安装前请将$JAVA_HOME环境变量指向已经安装的JDK。JanusGraph版本包可以从官网下载,并解压。

$ unzip janusgraph-0.5.2.zip
Archive:  janusgraph-0.5.2.zip
  creating: janusgraph-0.5.2/
...        

运行Gremlin Console

Janusgraph解压包下自带Gremlin Console运行脚本, 按照如下命令来启动Gremlin Console:

$ cd janusgraph-0.5.2
$ bin/gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
09:12:24 INFO  org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph  - HADOOP_GREMLIN_LIBS is set to: /usr/local/janusgraph/lib
plugin activated: tinkerpop.hadoop
plugin activated: janusgraph.imports
gremlin>

Gremlin Console命令采用的是Apache Groovy。Gremlin-Groovy集成自Groovy提供了许多基本或高级的图遍历方法。如果想了解更多的Gremlin语言特性可以参照introduction to Gremlin

运行Gremlin Server

可以通过运行 gremlin-server.sh 脚本启动Server。启动脚本是可以传入配置文件路径参数,不传配置文件路径的情况下默认使用配置文件路径conf/gremlin-server/gremlin-server.yaml。

$ ./bin/gremlin-server.sh start
or

$ ./bin/gremlin-server.sh ./conf/gremlin-server/[...].yaml

Gremlin server启动完成后,默认端口是8182。下面我们启动Gremlin Console使用如下:remote的远程连接命令,将Gremlin Console连接到Server上。

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

如果Gremlin Server和Gremlin Console安装在不同的机器时,可以通过修改conf/remote.yaml里面的参数来设置IP等参数。

### JanusGraph 安装部署教程 #### 准备工作 为了成功安装和部署JanusGraph,需先准备好支持的后端存储系统。常见的选择包括Cassandra、Elasticsearch以及HBase等[^2]。 #### 获取JanusGraph 前往官方网站下载页面获取最新的JanusGraph分发版压缩包,并将其解压至目标位置。该操作可以通过浏览器手动完成,也可以利用命令行工具如`wget`或`curl`来实现自动化处理[^3]。 #### 配置环境变量与参数调整 进入解压后的目录结构,在`conf/`路径下找到名为`storage.properties`的关键配置文件。依据所选后台数据库的不同,编辑此文件以适配具体的连接设置。对于初次使用者而言,建议参照官方文档或其他权威资源提供的模板进行修改[^1]。 #### 启动服务 当一切准备就绪之后,切换到`bin/`子目录内运行如下所示的Shell指令来激活JanusGraph实例: ```bash ./janusgraph.sh start ``` 上述过程会读取之前定义好的各项属性,并尝试建立同指定数据仓库之间的通信链路;一旦确认无误,则正式开启图谱引擎等待客户端请求的到来。 另外值得注意的是,除了传统的远程访问模式之外,还存在一种更为紧密耦合的方式——即把JanusGraph直接以内存映射的形式加载进Java虚拟机进程中成为一部分业务逻辑组件的一部分。这种方式固然简化了一些运维上的难题,但也牺牲了一定程度上灵活性与可伸缩性的优势。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值