hugegraph图数据库环境搭建

linux:centos7
版本:1.4.0
server和studio:https://pan.baidu.com/s/1nMvbaXcAHHcUvZDok-upkg
提取码:71t9

修改hugegraph-0.10.4配置文件

cd hugegraph-0.10.4/conf
vim rest-server.properties
restserver.url=http://XXXXX(服务器地址):端口号可修改,如8099
restserver.url是我们程序远程访问的地址,此处必须指定IP否则访问不到

配置hugegraph-studio

cd hugegraph-studio-0.10.0/conf
vim hugegraph-studio.properties
studio.server.host=XXXXX(服务器地址)

graph.server.host=XXXXX(服务器地址)
graph.server.port=8099(同rest-server.properties端口号)

至此配置完成

初始化存储引擎

cd  /hugegraph-0.10.4
bin/init-store.sh
sh start-hugegraph.sh

显示这样即为成功

启动studio

cd /hugegraph-studio-0.10.0/bin/
sh hugegraph-studio.sh 

然后可以在浏览器通过上面配置的地址访问图库
http://XXXXX:XXX/
如:http://1.2.3.40:8088/

通过页面创建第一张图

graph.schema().propertyKey("name").asText().ifNotExist().create()
graph.schema().propertyKey("age").asInt().ifNotExist().create()
graph.schema().propertyKey("city").asText().ifNotExist().create()
graph.schema().propertyKey("lang").asText().ifNotExist().create()
graph.schema().propertyKey("date").asText().ifNotExist().create()
graph.schema().propertyKey("price").asInt().ifNotExist().create()

person = graph.schema().vertexLabel("person").properties("name", "age", "city").primaryKeys("name").ifNotExist().create()
software = graph.schema().vertexLabel("software").properties("name", "lang", "price").primaryKeys("name").ifNotExist().create()

knows = graph.schema().edgeLabel("knows").sourceLabel("person").targetLabel("person").properties("date").ifNotExist().create()
created = graph.schema().edgeLabel("created").sourceLabel("person").targetLabel("software").properties("date", "city").ifNotExist().create()

marko = graph.addVertex(T.label, "person", "name", "marko", "age", 29, "city", "Beijing")
vadas = graph.addVertex(T.label, "person", "name", "vadas", "age", 27, "city", "Hongkong")
lop = graph.addVertex(T.label, "software", "name", "lop", "lang", "java", "price", 328)
josh = graph.addVertex(T.label, "person", "name", "josh", "age", 32, "city", "Beijing")
ripple = graph.addVertex(T.label, "software", "name", "ripple", "lang", "java", "price", 199)
peter = graph.addVertex(T.label, "person","name", "peter", "age", 29, "city", "Shanghai")

marko.addEdge("knows", vadas, "date", "20160110")
marko.addEdge("knows", josh, "date", "20130220")
marko.addEdge("created", lop, "date", "20171210", "city", "Shanghai")
josh.addEdge("created", ripple, "date", "20151010", "city", "Beijing")
josh.addEdge("created", lop, "date", "20171210", "city", "Beijing")
peter.addEdge("created", lop, "date", "20171210", "city", "Beijing")

查询创建的图

g.V()

hugegraph图数据库环境搭建_第1张图片

你可能感兴趣的:(知识图谱,数据库,linux,知识图谱)