HugeGraph【部署】Linux单机部署

📅 2026/7/22 16:53:07 👁️ 阅读次数 📝 编程学习
HugeGraph【部署】Linux单机部署

注: hugegraph从版本1.5.0开始,需要 Java11 运行时环境

一、安装JDK11

1.下载JDK11

https://www.oracle.com/java/technologies/downloads/#java11

2.解压缩包

tar -zxvf jdk-11.0.27_linux-x64_bin.tar.gz

3.修改/etc/profile环境变量

export JAVA_HOME=/usr/local/jdk-11.0.27 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin export PATH=$PATH:${JAVA_PATH}

4.文件生效

source /etc/profile

二、安装hugegraph-Server

1.下载

https://downloads.apache.org/incubator/hugegraph/1.5.0/apache-hugegraph-incubating-1.5.0.tar.gz

2.解压缩包

tar -zxvf apache-hugegraph-incubating-1.5.0.tar.gz

3.以mysql为数据源进行配置

3.1下载mysql驱动

https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.30/mysql-connector-java-8.0.30.jar

比如 mysql-connector-java-8.0.30.jar,并放入 HugeGraph-Server 的 lib 目录下

3.2修改mysql配置

vim /apache-hugegraph-incubating-1.5.0/conf/graphs/hugegraph.properties

store 是数据库名,如果没有会被自动创建

backend=mysql serializer=mysql store=hugegraph # mysql backend config jdbc.driver=com.mysql.cj.jdbc.Driver jdbc.url=jdbc:mysql://127.0.0.1:3306 jdbc.username= jdbc.password= jdbc.reconnect_max_times=3 jdbc.reconnect_interval=3 jdbc.ssl_mode=false

3.3配置账号密码(可以跳过)

配置gremlin-server.yaml文件

vim conf/gremlin-server.yaml #最下面添加 authentication: { authenticator: org.apache.hugegraph.auth.StandardAuthenticator, authenticationHandler: org.apache.hugegraph.auth.WsAndHttpBasicAuthHandler, config: {tokens: conf/rest-server.properties} }

配置rest-server.properties文件

vim conf/rest-server.properties #最下面添加 auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator auth.graph_store=hugegraph

配置hugegraph.properties文件

vim conf/graphs/hugegraph.properties #替换掉第一行的内容 #gremlin.graph=org.apache.hugegraph.HugeFactory gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy

3.4初始化数据库

初始化数据库(如果配置了3.3,此时会让你添加密码,手动输入密码,未配置则是无账号密码

bin/init-store.sh

测试密码: curl -u admin:passwd http://localhost:8080/graphs/hugegraph/schema/vertexlabels

注意事项:官方的init-store.sh脚本写的不够健壮,可能会判断1.9>jdk11,请强制赋值

需要单独把这行拿出来:DEFAULT_JAVA_OPTIONS="--add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED"

3.5修改访问ip配置

conf下的rest-server.properties修改restserver.url=http://0.0.0.0:8080

如果不想配置账号密码,也可以配置多个ip白名单

restserver.urls=http://0.0.0.0:8080,http://192.168.1.100:8080,http://10.0.0.5:8080

4.启动

4.1启动 server

bin/start-hugegraph.sh Starting HugeGraphServer... Connecting to HugeGraphServer (http://127.0.0.1:8080/graphs)....OK

4.2启动 server--创建示例图

bin/start-hugegraph.sh -p true Starting HugeGraphServer in daemon mode... Connecting to HugeGraphServer (http://127.0.0.1:8080/graphs)......OK

使用 RESTful API 请求 HugeGraphServer 如果得到如下结果,则表示部署成功

> curl "http://localhost:8080/graphs/hugegraph/graph/vertices" | gunzip {"vertices":[{"id":"2:lop","label":"software","type":"vertex","properties":{"name":"lop","lang":"java","price":328}},{"id":"1:josh","label":"person","type":"vertex","properties":{"name":"josh","age":32,"city":"Beijing"}},{"id":"1:marko","label":"person","type":"vertex","properties":{"name":"marko","age":29,"city":"Beijing"}},{"id":"1:peter","label":"person","type":"vertex","properties":{"name":"peter","age":35,"city":"Shanghai"}},{"id":"1:vadas","label":"person","type":"vertex","properties":{"name":"vadas","age":27,"city":"Hongkong"}},{"id":"2:ripple","label":"software","type":"vertex","properties":{"name":"ripple","lang":"java","price":199}}]}

三、 安装Hubble可视化界面

1.下载

https://downloads.apache.org/incubator/hugegraph/1.5.0/apache-hugegraph-toolchain-incubating-1.5.0.tar.gz

2.解压缩包

tar -xvf apache-hugegraph-toolchain-incubating-1.5.0.tar.gz

3.启动

进入Hubber 的 bin 目录,并执行 start-hubble.sh 脚本

bash start-hubble.sh

4.访问

127.0.0.1:8088