Skip to content
This repository was archived by the owner on Dec 28, 2025. It is now read-only.

Commit dff6ba1

Browse files
Ethereal-Oimbajin
authored andcommitted
chore: add docker using / add load data methods (apache#423)
1 parent c773933 commit dff6ba1

File tree

2 files changed

+411
-27
lines changed

2 files changed

+411
-27
lines changed

content/cn/docs/quickstart/computing/hugegraph-vermeer.md

Lines changed: 205 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,142 @@ master 是负责通信、转发、汇总的节点,计算量和占用资源量
1616

1717
### 1.2 运行方法
1818

19+
1. **方案一:Docker Compose(推荐)**
20+
21+
确保docker-compose.yaml存在于您的项目根目录中。如果没有,以下是一个示例:
22+
```yaml
23+
#
24+
# Licensed to the Apache Software Foundation (ASF) under one or more
25+
# contributor license agreements. See the NOTICE file distributed with
26+
# this work for additional information regarding copyright ownership.
27+
# The ASF licenses this file to You under the Apache License, Version 2.0
28+
# (the "License"); you may not use this file except in compliance with
29+
# the License. You may obtain a copy of the License at
30+
#
31+
# http://www.apache.org/licenses/LICENSE-2.0
32+
#
33+
# Unless required by applicable law or agreed to in writing, software
34+
# distributed under the License is distributed on an "AS IS" BASIS,
35+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36+
# See the License for the specific language governing permissions and
37+
# limitations under the License.
38+
#
39+
40+
services:
41+
vermeer-master:
42+
image: hugegraph/vermeer
43+
container_name: vermeer-master
44+
volumes:
45+
- ~/.config:/go/bin/config # Change here to your actual config path
46+
command: --env=master
47+
networks:
48+
vermeer_network:
49+
ipv4_address: 172.20.0.10 # Assign a static IP for the master
50+
51+
vermeer-worker:
52+
image: hugegraph/vermeer
53+
container_name: vermeer-worker
54+
volumes:
55+
- ~/:/go/bin/config # Change here to your actual config path
56+
command: --env=worker
57+
networks:
58+
vermeer_network:
59+
ipv4_address: 172.20.0.11 # Assign a static IP for the worker
60+
61+
networks:
62+
vermeer_network:
63+
driver: bridge
64+
ipam:
65+
config:
66+
- subnet: 172.20.0.0/24 # Define the subnet for your network
67+
```
68+
69+
修改 docker-compose.yaml
70+
- **Volume**:例如将两处 ~/:/go/bin/config 改为 /home/user/config:/go/bin/config(或您自己的配置目录)。
71+
- **Subnet**:根据实际情况修改子网IP。请注意,每个容器需要访问的端口在config文件中指定,具体请参照项目`config`文件夹下内容。
72+
73+
在项目目录构建镜像并启动(或者先用 docker build 再 docker-compose up)
74+
75+
```shell
76+
# 构建镜像(在项目根 vermeer 目录)
77+
docker build -t hugegraph/vermeer .
78+
79+
# 启动(在 vermeer 根目录)
80+
docker-compose up -d
81+
# 或使用新版 CLI:
82+
# docker compose up -d
83+
```
84+
85+
查看日志 / 停止 / 删除:
86+
87+
```shell
88+
docker-compose logs -f
89+
docker-compose down
90+
```
91+
92+
2. **方案二:通过 docker run 单独启动(手动创建网络并分配静态 IP)**
93+
94+
确保CONFIG_DIR对Docker进程具有适当的读取/执行权限。
95+
96+
构建镜像:
97+
98+
```shell
99+
docker build -t hugegraph/vermeer .
100+
```
101+
102+
创建自定义 bridge 网络(一次性操作):
103+
104+
```shell
105+
docker network create --driver bridge \
106+
--subnet 172.20.0.0/24 \
107+
vermeer_network
108+
```
109+
110+
运行 master(调整 CONFIG_DIR 为您的绝对配置路径,可以根据实际情况调整IP):
111+
112+
```shell
113+
CONFIG_DIR=/home/user/config
114+
115+
docker run -d \
116+
--name vermeer-master \
117+
--network vermeer_network --ip 172.20.0.10 \
118+
-v ${CONFIG_DIR}:/go/bin/config \
119+
hugegraph/vermeer \
120+
--env=master
121+
```
122+
123+
运行 worker:
124+
125+
```shell
126+
docker run -d \
127+
--name vermeer-worker \
128+
--network vermeer_network --ip 172.20.0.11 \
129+
-v ${CONFIG_DIR}:/go/bin/config \
130+
hugegraph/vermeer \
131+
--env=worker
132+
```
133+
134+
查看日志 / 停止 / 删除:
135+
136+
```shell
137+
docker logs -f vermeer-master
138+
docker logs -f vermeer-worker
139+
140+
docker stop vermeer-master vermeer-worker
141+
docker rm vermeer-master vermeer-worker
142+
143+
# 删除自定义网络(如果需要)
144+
docker network rm vermeer_network
145+
```
146+
147+
3. **方案三:从源码构建**
148+
149+
构建。具体请参照[Vermeer Readme](https://github.com/apache/incubator-hugegraph-computer/tree/master/vermeer)。
150+
151+
```shell
152+
go build
153+
```
154+
19155
在进入文件夹目录后输入 `./vermeer --env=master` 或 `./vermeer --env=worker01`
20156

21157
## 二、任务创建类 rest api
@@ -33,24 +169,79 @@ master 是负责通信、转发、汇总的节点,计算量和占用资源量
33169

34170
具体参数参考 Vermeer 参数列表文档。
35171

36-
request 示例:
172+
vermeer提供三种加载方式:
173+
174+
1. 从本地加载
175+
176+
**request 示例:**
37177

38178
```javascript
39179
POST http://localhost:8688/tasks/create
40180
{
41181
"task_type": "load",
42182
"graph": "testdb",
43183
"params": {
44-
"load.parallel": "50",
45-
"load.type": "local",
46-
"load.vertex_files": "{\"localhost\":\"data/twitter-2010.v_[0,99]\"}",
47-
"load.edge_files": "{\"localhost\":\"data/twitter-2010.e_[0,99]\"}",
48-
"load.use_out_degree": "1",
49-
"load.use_outedge": "1"
184+
"load.parallel": "50",
185+
"load.type": "local",
186+
"load.vertex_files": "{\"localhost\":\"data/twitter-2010.v_[0,99]\"}",
187+
"load.edge_files": "{\"localhost\":\"data/twitter-2010.e_[0,99]\"}",
188+
"load.use_out_degree": "1",
189+
"load.use_outedge": "1"
50190
}
51191
}
52192
```
53193

194+
2. 从hugegraph加载
195+
196+
**request 示例:**
197+
198+
⚠️ 安全警告:切勿在配置文件或代码中存储真实密码。请改用环境变量或安全的凭据管理系统。
199+
200+
```javascript
201+
POST http://localhost:8688/tasks/create
202+
{
203+
"task_type": "load",
204+
"graph": "testdb",
205+
"params": {
206+
"load.parallel": "50",
207+
"load.type": "hugegraph",
208+
"load.hg_pd_peers": "[\"<your-hugegraph-ip>:8686\"]",
209+
"load.hugegraph_name": "DEFAULT/hugegraph2/g",
210+
"load.hugegraph_username": "admin",
211+
"load.hugegraph_password": "<your-password-here>",
212+
"load.use_out_degree": "1",
213+
"load.use_outedge": "1"
214+
}
215+
}
216+
```
217+
218+
3. 从hdfs加载
219+
220+
**request 示例:**
221+
222+
```javascript
223+
POST http://localhost:8688/tasks/create
224+
{
225+
"task_type": "load",
226+
"graph": "testdb",
227+
"params": {
228+
"load.parallel": "50",
229+
"load.type": "hdfs",
230+
"load.hdfs_namenode": "name_node1:9000",
231+
"load.hdfs_conf_path": "/path/to/conf",
232+
"load.krb_realm": "EXAMPLE.COM",
233+
"load.krb_name": "user@EXAMPLE.COM",
234+
"load.krb_keytab_path": "/path/to/keytab",
235+
"load.krb_conf_path": "/path/to/krb5.conf",
236+
"load.hdfs_use_krb": "1",
237+
"load.vertex_files": "/data/graph/vertices",
238+
"load.edge_files": "/data/graph/edges",
239+
"load.use_out_degree": "1",
240+
"load.use_outedge": "1"
241+
}
242+
}
243+
```
244+
54245
### 2.3 输出计算结果
55246

56247
所有的 vermeer 计算任务均支持多种结果输出方式,可自定义输出方式:local、hdfs、afs 或 hugegraph,在发送请求时的 params 参数下加入对应参数,即可生效。指定 output.need_statistics 为 1 时,支持计算结果统计信息输出,结果会写在接口任务信息内。统计模式算子目前支持 "count" 和 "modularity" 。但仅针对社区发现算法适用。
@@ -66,13 +257,13 @@ POST http://localhost:8688/tasks/create
66257
"graph": "testdb",
67258
"params": {
68259
"compute.algorithm": "pagerank",
69-
"compute.parallel":"10",
70-
"compute.max_step":"10",
71-
"output.type":"local",
72-
"output.parallel":"1",
73-
"output.file_path":"result/pagerank"
74-
}
75-
}
260+
"compute.parallel": "10",
261+
"compute.max_step": "10",
262+
"output.type": "local",
263+
"output.parallel": "1",
264+
"output.file_path": "result/pagerank"
265+
}
266+
}
76267
```
77268

78269
## 三、支持的算法

0 commit comments

Comments
 (0)