- HugeGraph
- HugeGraph的安装部署
- bind url
- gremlin server url, need to be consistent with host and port in gremlin-server.yaml
- http://127.0.0.1:8182">gremlinserver.url=http://127.0.0.1:8182
- graphs list with pair NAME:CONF_PATH
- authentication
- auth.authenticator=
- auth.admin_token=
- auth.user_tokens=[]
- 查看是否有 HugeGraphServer进程
- 访问http服务
HugeGraph
HugeGraph是一款易用、高效、通用的开源图数据库系统,实现了Apache TinkerPop3框架,完全兼容 Gremlin 查询语言,具备完善的工具链组件。支持百亿以上的顶点和边快速导入,并提供毫秒级的关联关系查询能力(OLTP),并可与Hadoop、Spark等大数据平台集成以进行离线分析(OLAP)。
Gremlin是Apache TinkerPop的图遍历语言,相当于关系型数据库的SQL。
HugeGraph的安装部署
在Linux服务器上部署HugeGraph,需要有JDK环境。
首先部署HugeGraph:
- 安装JDK,并配置环境变量
rpm -ivh jdk-8u181-linux-x64.rpm
安装后的路径为:/usr/java/jdk1.8.0_181-amd64
到 GitHub 上下载HugeGraph的发行包:hugegraph-0.11.2-b3.tar.gz
将压缩包上传到服务器,解压
根据需要,修改 conf/rest-server.properties 配置文件 ```properties
bind url
restserver.url=http://127.0.0.1:8080
gremlin server url, need to be consistent with host and port in gremlin-server.yaml
gremlinserver.url=http://127.0.0.1:8182
graphs list with pair NAME:CONF_PATH
graphs=[hugegraph:conf/hugegraph.properties]
authentication
auth.authenticator=
auth.admin_token=
auth.user_tokens=[]
server.id=server-1 server.role=master
5.
启动服务之前需要先手动初始化后端
```sh
bin/init-store.sh
- 启动服务
bin/start-hugegraph.sh
访问http服务
curl http://127.0.0.1:8080/graphs
在服务器部署HugeGraphStudio:
1.
到GitHub下载HugeGraphStudio发行包:[hugegraph-studio-0.11.0.tar.gz](https://github.com/hugegraph/hugegraph-studio/releases/download/v0.11.0/hugegraph-studio-0.11.0.tar.gz)
2.
将压缩包上传到服务器,解压
3.
根据需要,修改 conf/huge-studio.properties 配置文件
```properties
studio.server.port=8088
# 此处需要将原来的localhost修改为具体的IP,否则其他电脑无法访问
studio.server.host=192.168.29.146
graph.server.host=localhost
graph.server.port=8080
graph.name=hugegraph
client.timeout=30
- 启动hugegraph-studio
# 该命令默认没有使用后台运行
bin/hugegraph-studio.sh
- 使用浏览器访问hugegraph-studio验证:http://192.168.29.146:8088/
可以在hugegraph-studio中创建测试数据进行验证:
// PropertyKey
graph.schema().propertyKey("name").asText().ifNotExist().create()
graph.schema().propertyKey("age").asInt().ifNotExist().create()
graph.schema().propertyKey("addr").asText().ifNotExist().create()
graph.schema().propertyKey("lang").asText().ifNotExist().create()
graph.schema().propertyKey("tag").asText().ifNotExist().create()
graph.schema().propertyKey("weight").asFloat().ifNotExist().create()
// VertexLabel
graph.schema().vertexLabel("person").properties("name", "age", "addr", "weight").useCustomizeStringId().ifNotExist().create()
graph.schema().vertexLabel("software").properties("name", "lang", "tag", "weight").primaryKeys("name").ifNotExist().create()
graph.schema().vertexLabel("language").properties("name", "lang", "weight").primaryKeys("name").ifNotExist().create()
// EdgeLabel
graph.schema().edgeLabel("knows").sourceLabel("person").targetLabel("person").properties("weight").ifNotExist().create()
graph.schema().edgeLabel("created").sourceLabel("person").targetLabel("software").properties("weight").ifNotExist().create()
graph.schema().edgeLabel("contains").sourceLabel("software").targetLabel("software").properties("weight").ifNotExist().create()
graph.schema().edgeLabel("define").sourceLabel("software").targetLabel("language").properties("weight").ifNotExist().create()
graph.schema().edgeLabel("implements").sourceLabel("software").targetLabel("software").properties("weight").ifNotExist().create()
graph.schema().edgeLabel("supports").sourceLabel("software").targetLabel("language").properties("weight").ifNotExist().create()
// TinkerPop
okram = graph.addVertex(T.label, "person", T.id, "okram", "name", "Marko A. Rodriguez", "age", 29, "addr", "Santa Fe, New Mexico", "weight", 1)
spmallette = graph.addVertex(T.label, "person", T.id, "spmallette", "name", "Stephen Mallette", "age", 0, "addr", "", "weight", 1)
tinkerpop = graph.addVertex(T.label, "software", "name", "TinkerPop", "lang", "java", "tag", "Graph computing framework", "weight", 1)
tinkergraph = graph.addVertex(T.label, "software", "name", "TinkerGraph", "lang", "java", "tag", "In-memory property graph", "weight", 1)
gremlin = graph.addVertex(T.label, "language", "name", "Gremlin", "lang", "groovy/python/javascript", "weight", 1)
okram.addEdge("created", tinkerpop, "weight", 1)
spmallette.addEdge("created", tinkerpop, "weight", 1)
okram.addEdge("knows", spmallette, "weight", 1)
tinkerpop.addEdge("define", gremlin, "weight", 1)
tinkerpop.addEdge("contains", tinkergraph, "weight", 1)
tinkergraph.addEdge("supports", gremlin, "weight", 1)
// Titan
dalaro = graph.addVertex(T.label, "person", T.id, "dalaro", "name", "Dan LaRocque ", "age", 0, "addr", "", "weight", 1)
mbroecheler = graph.addVertex(T.label, "person", T.id, "mbroecheler", "name", "Matthias Broecheler", "age", 29, "addr", "San Francisco", "weight", 1)
titan = graph.addVertex(T.label, "software", "name", "Titan", "lang", "java", "tag", "Graph Database", "weight", 1)
dalaro.addEdge("created", titan, "weight", 1)
mbroecheler.addEdge("created", titan, "weight", 1)
okram.addEdge("created", titan, "weight", 1)
dalaro.addEdge("knows", mbroecheler, "weight", 1)
titan.addEdge("implements", tinkerpop, "weight", 1)
titan.addEdge("supports", gremlin, "weight", 1)
// HugeGraph
javeme = graph.addVertex(T.label, "person", T.id, "javeme", "name", "Jermy Li", "age", 29, "addr", "Beijing", "weight", 1)
zhoney = graph.addVertex(T.label, "person", T.id, "zhoney", "name", "Zhoney Zhang", "age", 29, "addr", "Beijing", "weight", 1)
linary = graph.addVertex(T.label, "person", T.id, "linary", "name", "Linary Li", "age", 28, "addr", "Wuhan. Hubei", "weight", 1)
hugegraph = graph.addVertex(T.label, "software", "name", "HugeGraph", "lang", "java", "tag", "Graph Database", "weight", 1)
javeme.addEdge("created", hugegraph, "weight", 1)
zhoney.addEdge("created", hugegraph, "weight", 1)
linary.addEdge("created", hugegraph, "weight", 1)
javeme.addEdge("knows", zhoney, "weight", 1)
javeme.addEdge("knows", linary, "weight", 1)
hugegraph.addEdge("implements", tinkerpop, "weight", 1)
hugegraph.addEdge("supports", gremlin, "weight", 1)
查询顶点:
g.V()