部署HugeGraph
这里以hugegraph1.2.0为例子,演示一下如何安装部署hugegraph
一、下载并安装JDK11
- 下载JDK11
https://www.oracle.com/java/technologies/downloads/#java11
- 使用scp命令将安装包上传到服务器
scp /path/to/local/file username@server_ip:/path/to/remote/directory
- 解压缩压缩包
tar -zxvf jdk-11.0.25_linux-x64_bin.tar.gz
- 修改/etc/profile环境变量
vim /etc/profile
在文件末尾添加如下内容
export JAVA_HOME=/usr/local/jdk-11.0.25
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}
修改保存后,执行source /etc/profile,使环境变量生效
- 测试安装是否成功
java -version
如果打印如下内容表示安装成功:
hugegraph_58">二、下载并安装hugegraph
- 下载tar包
wget https://downloads.apache.org/incubator/hugegraph/1.2.0/apache-hugegraph-incubating-1.2.0.tar.gz
下载好之后如下所示:
- 解压缩apache-hugegraph-incubating-1.2.0.tar.gz
tar -zxvf apache-hugegraph-incubating-1.2.0.tar.gz
hugegraph_81">三、修改hugegraph配置
- 修改hugegraph.properties配置
vim /usr/local/apache-hugegraph-incubating-1.2.0/conf/graphs/hugegraph.properties
修改MySQL的相关配置
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
例如:
- 下载数据库驱动包
使用如下命令下载 MySQL 的驱动包,比如 mysql-connector-java-8.0.30.jar
wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.30/mysql-connector-java-8.0.30.jar
将驱动包移动到 HugeGraph-Server 的 lib
目录下
- 初始化数据库
进入HugeGraph-Server 的 bin
目录,并执行 init-store.sh
脚本
bash init-store.sh
如果显示如下日志,表示初始化完成
四、启动
1. 启动不创建示例图
进入HugeGraph-Server 的 bin
目录,并执行 start-hugegraph.sh
脚本
2. 启动并创建示例图
进入HugeGraph-Server 的 bin
目录,并执行 start-hugegraph.sh
脚本,在脚本启动时候携带 -p true
参数,表示 preload, 即创建示例图图
使用 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.2.0版本部署为例子
- 下载
toolchain
的 tar 包并解压
wget https://downloads.apache.org/incubator/hugegraph/1.2.0/apache-hugegraph-toolchain-incubating-1.2.0.tar.gz
tar -xvf apache-hugegraph-toolchain-incubating-1.2.0.tar.gz
- 进入Hubber 的
bin
目录,并执行start-hubble.sh
脚本
bash start-hubble.sh
- 浏览器访问
IP
:8088
,如果看到以下界面,表示部署成功: