diff --git a/content/cn/docs/guides/hugegraph-docker-cluster.md b/content/cn/docs/guides/hugegraph-docker-cluster.md new file mode 100644 index 000000000..a3f6578b6 --- /dev/null +++ b/content/cn/docs/guides/hugegraph-docker-cluster.md @@ -0,0 +1,134 @@ +--- +title: "HugeGraph Docker 集群部署指南" +linkTitle: "Docker 集群" +weight: 6 +--- + +## 概述 + +HugeGraph 通过 Docker-Compose 可快速运行完整的分布式集群版(PD + Store + Server)。该方式适用于 Linux 和 Mac。 + +## 前置条件 + +- Docker Engine 20.10+ 或 Docker Desktop 4.x+ +- Docker Compose v2 +- Mac 运行 3 节点集群时,建议分配至少 **12 GB** 内存(设置 → 资源 → 内存)。[其他平台根据实际情况调整] + +> **已测试环境**:Linux(原生 Docker)和 macOS(Docker Desktop with ARM M4) + +## Compose 文件 + +在 HugeGraph 主仓库 [`docker/`](https://github.com/apache/hugegraph/tree/master/docker) 目录下提供了三个 compose 文件: + +| 文件 | 描述 | +|------|------| +| `docker-compose.yml` | 使用预构建镜像的** 1x3 单进程(节点)**快速启动 | +| `docker-compose.dev.yml` | 从源码构建的单节点**开发模式** | +| `docker-compose-3pd-3store-3server.yml` | ** 3x3 进程**(模拟节点)分布式集群 | + +> 注: 后续步骤皆为假设你本地**已拉取** `hugegraph` 主仓库代码 (至少是 docker 目录) + +## 单节点快速启动 + +```bash +cd hugegraph/docker + # 注意版本号请随时保持更新 → 1.x.0 +HUGEGRAPH_VERSION=1.7.0 docker compose up -d +``` + +验证: +```bash +curl http://localhost:8080/versions +``` + +## 3 节点集群快速启动 + +```bash +cd hugegraph/docker +HUGEGRAPH_VERSION=1.7.0 docker compose -f docker-compose-3pd-3store-3server.yml up -d +``` + +默认内置的启动顺序: +1. PD (节点)最先启动,且必须通过 `/v1/health` 健康检查 +2. Store (节点)在所有 PD 健康后再启动 +3. Server (节点)在所有 Store + PD 健康后最后启动 + +验证集群正常:(重要) +```bash +curl http://localhost:8620/v1/health # PD 健康检查 +curl http://localhost:8520/v1/health # Store 健康检查 +curl http://localhost:8080/versions # Server +curl http://localhost:8620/v1/stores # 已注册的 Store +curl http://localhost:8620/v1/partitions # 分区分配 +``` + +## 环境变量参考 + +### PD 变量 + +| 变量 | 必填 | 默认值 | 映射配置 | +|------|------|--------|----------| +| `HG_PD_GRPC_HOST` | 是 | — | `grpc.host` | +| `HG_PD_RAFT_ADDRESS` | 是 | — | `raft.address` | +| `HG_PD_RAFT_PEERS_LIST` | 是 | — | `raft.peers-list` | +| `HG_PD_INITIAL_STORE_LIST` | 是 | — | `pd.initial-store-list` | +| `HG_PD_GRPC_PORT` | 否 | `8686` | `grpc.port` | +| `HG_PD_REST_PORT` | 否 | `8620` | `server.port` | +| `HG_PD_DATA_PATH` | 否 | `/hugegraph-pd/pd_data` | `pd.data-path` | +| `HG_PD_INITIAL_STORE_COUNT` | 否 | `1` | `pd.initial-store-count` | + +> **已弃用的别名**:`GRPC_HOST` → `HG_PD_GRPC_HOST`、`RAFT_ADDRESS` → `HG_PD_RAFT_ADDRESS`、`RAFT_PEERS` → `HG_PD_RAFT_PEERS_LIST` + +### Store 变量 + +| 变量 | 必填 | 默认值 | 映射配置 | +|------|------|--------|----------| +| `HG_STORE_PD_ADDRESS` | 是 | — | `pdserver.address` | +| `HG_STORE_GRPC_HOST` | 是 | — | `grpc.host` | +| `HG_STORE_RAFT_ADDRESS` | 是 | — | `raft.address` | +| `HG_STORE_GRPC_PORT` | 否 | `8500` | `grpc.port` | +| `HG_STORE_REST_PORT` | 否 | `8520` | `server.port` | +| `HG_STORE_DATA_PATH` | 否 | `/hugegraph-store/storage` | `app.data-path` | + +> **已弃用的别名**:`PD_ADDRESS` → `HG_STORE_PD_ADDRESS`、`GRPC_HOST` → `HG_STORE_GRPC_HOST`、`RAFT_ADDRESS` → `HG_STORE_RAFT_ADDRESS` + +### Server 变量 + +| 变量 | 必填 | 默认值 | 映射配置 | +|------|------|--------|----------| +| `HG_SERVER_BACKEND` | 是 | — | `hugegraph.properties` 中的 `backend` | +| `HG_SERVER_PD_PEERS` | 是 | — | `pd.peers` | +| `STORE_REST` | 否 | — | `wait-partition.sh` 使用 | +| `PASSWORD` | 否 | — | 启用鉴权模式 | + +> **已弃用的别名**:`BACKEND` → `HG_SERVER_BACKEND`、`PD_PEERS` → `HG_SERVER_PD_PEERS` + +## 端口参考 + +| 服务 | 宿主机端口 | 用途 | +|------|-----------|------| +| pd0 | 8620 | REST API | +| pd0 | 8686 | gRPC | +| pd1 | 8621 | REST API | +| pd1 | 8687 | gRPC | +| pd2 | 8622 | REST API | +| pd2 | 8688 | gRPC | +| store0 | 8500 | gRPC | +| store0 | 8520 | REST API | +| store1 | 8501 | gRPC | +| store1 | 8521 | REST API | +| store2 | 8502 | gRPC | +| store2 | 8522 | REST API | +| server0 | 8080 | Graph API | +| server1 | 8081 | Graph API | +| server2 | 8082 | Graph API | + +## 故障排查 + +1. **容器 OOM 退出(exit code 137)**:将 Docker Desktop 内存增加到 12 GB 以上 (或调整被 kill 的启动 jvm 内存设置) + +2. **Raft 选举超时**:检查所有 PD 节点的 `HG_PD_RAFT_PEERS_LIST` 是否一致。验证连通性:`docker exec hg-pd0 ping pd1` + +3. **分区分配未完成**:检查 `curl http://localhost:8620/v1/stores` — 3 个 Store 必须都显示 `"state":"Up"` 才能完成分区分配 + +4. **连接被拒**:确保 `HG_*` 环境变量使用容器主机名(`pd0`、`store0`),而非 `127.0.0.1` diff --git a/content/cn/docs/quickstart/hugegraph/hugegraph-hstore.md b/content/cn/docs/quickstart/hugegraph/hugegraph-hstore.md index 50d28d579..d07fdfe2a 100644 --- a/content/cn/docs/quickstart/hugegraph/hugegraph-hstore.md +++ b/content/cn/docs/quickstart/hugegraph/hugegraph-hstore.md @@ -12,10 +12,10 @@ HugeGraph-Store 是 HugeGraph 分布式版本的存储节点组件,负责实 #### 2.1 前置条件 -- 操作系统:Linux 或 MacOS(Windows 尚未经过完整测试) +- 操作系统:Linux 或 macOS(Windows 尚未经过完整测试) - Java 版本:≥ 11 - Maven 版本:≥ 3.5.0 -- 已部署的 HugeGraph-PD(如果是多节点部署) +- 如需进行多节点部署,请先部署 HugeGraph-PD ### 3 部署 @@ -50,6 +50,50 @@ mvn clean install -DskipTests=true # target/apache-hugegraph-incubating-{version}.tar.gz ``` +#### 3.3 Docker 部署 + +HugeGraph-Store Docker 镜像已发布在 Docker Hub,镜像名是 `hugegraph/store`。 + +> 注: 后续步骤皆假设你本地**已拉取** `hugegraph` 主仓库代码 (至少是 docker 目录) + +使用 docker-compose 文件部署完整的 3 节点集群(PD + Store + Server): + +```bash +cd hugegraph/docker +# 注意版本号请随时保持更新 → 1.x.0 +HUGEGRAPH_VERSION=1.7.0 docker compose -f docker-compose-3pd-3store-3server.yml up -d +``` + +通过 `docker run` 运行单个 Store 节点: + +```bash +docker run -d \ + -p 8520:8520 \ + -p 8500:8500 \ + -p 8510:8510 \ + -e HG_STORE_PD_ADDRESS=:8686 \ + -e HG_STORE_GRPC_HOST= \ + -e HG_STORE_RAFT_ADDRESS=:8510 \ + -v /path/to/storage:/hugegraph-store/storage \ + --name hugegraph-store \ + hugegraph/store:1.7.0 +``` + +**环境变量参考:** + +| 变量 | 必填 | 默认值 | 描述 | +|------|------|--------|------| +| `HG_STORE_PD_ADDRESS` | 是 | — | PD gRPC 地址(如 `pd0:8686,pd1:8686,pd2:8686`) | +| `HG_STORE_GRPC_HOST` | 是 | — | 本节点的 gRPC 主机名/IP(如 `store0`) | +| `HG_STORE_RAFT_ADDRESS` | 是 | — | 本节点的 Raft 地址(如 `store0:8510`) | +| `HG_STORE_GRPC_PORT` | 否 | `8500` | gRPC 服务端口 | +| `HG_STORE_REST_PORT` | 否 | `8520` | REST API 端口 | +| `HG_STORE_DATA_PATH` | 否 | `/hugegraph-store/storage` | 数据存储路径 | + +> **注意**:在 Docker 桥接网络中,`HG_STORE_GRPC_HOST` 应使用容器主机名(如 `store0`)而非 IP 地址。 + +> **已弃用的别名**:`PD_ADDRESS`、`GRPC_HOST`、`RAFT_ADDRESS` 仍可使用,但会输出弃用警告。新部署请使用 `HG_STORE_*` 名称。 + ### 4 配置 Store 的主要配置文件为 `conf/application.yml`,以下是关键配置项: @@ -116,7 +160,7 @@ logging: 启动成功后,可以在 `logs/hugegraph-store-server.log` 中看到类似以下的日志: ``` -2024-xx-xx xx:xx:xx [main] [INFO] o.a.h.s.n.StoreNodeApplication - Started StoreNodeApplication in x.xxx seconds (JVM running for x.xxx) +YYYY-mm-dd xx:xx:xx [main] [INFO] o.a.h.s.n.StoreNodeApplication - Started StoreNodeApplication in x.xxx seconds (JVM running for x.xxx) ``` #### 5.2 停止 Store @@ -188,6 +232,36 @@ pdserver: address: 127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688 ``` +#### 6.3 Docker 分布式集群配置 + +3 节点 Store 集群包含在 `docker/docker-compose-3pd-3store-3server.yml` 中。每个 Store 节点拥有独立的主机名和环境变量: + +```yaml +# store0 +HG_STORE_PD_ADDRESS: pd0:8686,pd1:8686,pd2:8686 +HG_STORE_GRPC_HOST: store0 +HG_STORE_GRPC_PORT: "8500" +HG_STORE_REST_PORT: "8520" +HG_STORE_RAFT_ADDRESS: store0:8510 +HG_STORE_DATA_PATH: /hugegraph-store/storage + +# store1 +HG_STORE_PD_ADDRESS: pd0:8686,pd1:8686,pd2:8686 +HG_STORE_GRPC_HOST: store1 +HG_STORE_RAFT_ADDRESS: store1:8510 + +# store2 +HG_STORE_PD_ADDRESS: pd0:8686,pd1:8686,pd2:8686 +HG_STORE_GRPC_HOST: store2 +HG_STORE_RAFT_ADDRESS: store2:8510 +``` + +Store 节点仅在所有 PD 节点通过健康检查后才会启动,其中 docker-compose 中的 healthcheck 实际访问的是 PD 的 REST 接口 `/v1/health`(也可以通过 Actuator 暴露的 `/actuator/health` 进行手动检查),并通过 `depends_on: condition: service_healthy` 强制执行依赖关系。 + +运行时日志可通过 `docker logs `(如 `docker logs hg-store0`)直接查看,无需进入容器。 + +完整的部署指南请参阅 [docker/README.md](https://github.com/apache/hugegraph/blob/master/docker/README.md)。 + ### 7 验证 Store 服务 确认 Store 服务是否正常运行: @@ -204,7 +278,9 @@ curl http://localhost:8520/actuator/health curl http://localhost:8620/v1/stores ``` -如果Store配置成功,上述接口的响应中应该包含当前节点的状态信息,状态为Up表示节点正常运行,这里只展示了一个节点配置成功的响应,如果三个节点都配置成功并正在运行,响应中`storeId`列表应该包含三个id,并且`stateCountMap`中`Up`、`numOfService`、`numOfNormalService`三个字段应该为3。 +如果 Store 配置成功,上述接口响应中应包含当前节点的状态信息,其中 `state` 为 `Up` 表示节点运行正常。 + +下方示例仅展示 1 个 Store 节点的返回结果。如果 3 个节点都已正确配置并正在运行,则响应中的 `storeId` 列表应包含 3 个 ID,且 `stateCountMap.Up`、`numOfService` 和 `numOfNormalService` 都应为 `3`。 ```javascript { "message": "OK", @@ -241,4 +317,4 @@ curl http://localhost:8620/v1/stores }, "status": 0 } -``` \ No newline at end of file +``` diff --git a/content/cn/docs/quickstart/hugegraph/hugegraph-pd.md b/content/cn/docs/quickstart/hugegraph/hugegraph-pd.md index 46d70c32f..6602cbd94 100644 --- a/content/cn/docs/quickstart/hugegraph/hugegraph-pd.md +++ b/content/cn/docs/quickstart/hugegraph/hugegraph-pd.md @@ -12,7 +12,7 @@ HugeGraph-PD (Placement Driver) 是 HugeGraph 分布式版本的元数据管理 #### 2.1 前置条件 -- 操作系统:Linux 或 MacOS(Windows 尚未经过完整测试) +- 操作系统:Linux 或 macOS(Windows 尚未经过完整测试) - Java 版本:≥ 11 - Maven 版本:≥ 3.5.0 @@ -49,6 +49,56 @@ mvn clean install -DskipTests=true # target/apache-hugegraph-incubating-{version}.tar.gz ``` +#### 3.3 Docker 部署 + +HugeGraph-PD Docker 镜像已发布在 Docker Hub,镜像名为 `hugegraph/pd`。 +> 注: 后续步骤皆假设你本地**已拉取** `hugegraph` 主仓库代码 (至少是 docker 目录) + +使用 docker-compose 模式部署完整的 3 节点集群(PD + Store + Server): + +```bash +cd hugegraph/docker +# 注意版本号请随时保持更新 → 1.x.0 +HUGEGRAPH_VERSION=1.7.0 docker compose -f docker-compose-3pd-3store-3server.yml up -d +``` + +通过 `docker run` 运行单个 PD 节点时,通过环境变量提供配置: + +```bash +docker run -d \ + -p 8620:8620 \ + -p 8686:8686 \ + -p 8610:8610 \ + -e HG_PD_GRPC_HOST= \ + -e HG_PD_RAFT_ADDRESS=:8610 \ + -e HG_PD_RAFT_PEERS_LIST=:8610 \ + -e HG_PD_INITIAL_STORE_LIST=:8500 \ + -v /path/to/data:/hugegraph-pd/pd_data \ + --name hugegraph-pd \ + hugegraph/pd:1.7.0 +``` + +**环境变量参考:** + +| 变量 | 必填 | 默认值 | 描述 | +|------|------|--------|------| +| `HG_PD_GRPC_HOST` | 是 | — | 本节点的 gRPC 主机名/IP(Docker 中使用 `pd0`,裸机使用 `192.168.1.10`) | +| `HG_PD_RAFT_ADDRESS` | 是 | — | 本节点的 Raft 地址(如 `pd0:8610`) | +| `HG_PD_RAFT_PEERS_LIST` | 是 | — | 所有 PD 节点的 Raft 地址(如 `pd0:8610,pd1:8610,pd2:8610`) | +| `HG_PD_INITIAL_STORE_LIST` | 是 | — | 预期的 Store gRPC 地址(如 `store0:8500,store1:8500,store2:8500`) | +| `HG_PD_GRPC_PORT` | 否 | `8686` | gRPC 服务端口 | +| `HG_PD_REST_PORT` | 否 | `8620` | REST API 端口 | +| `HG_PD_DATA_PATH` | 否 | `/hugegraph-pd/pd_data` | 元数据存储路径 | +| `HG_PD_INITIAL_STORE_COUNT` | 否 | `1` | 集群可用所需的最小 Store 数量 | + +> **注意**:在 Docker 桥接网络中,`HG_PD_GRPC_HOST` 和 `HG_PD_RAFT_ADDRESS` 应使用容器主机名(如 `pd0`)而非 IP 地址。 + +> **已弃用的别名**:`GRPC_HOST`、`RAFT_ADDRESS`、`RAFT_PEERS`、`PD_INITIAL_STORE_LIST` 仍可使用,但会输出弃用警告。新部署请使用 `HG_PD_*` 名称。 + +运行时日志可通过 `docker logs `(如 `docker logs hg-pd0`)直接查看,无需进入容器。 + +完整的集群部署指南请参阅 [docker/README.md](https://github.com/apache/hugegraph/blob/master/docker/README.md)。 + ### 4 配置 PD 的主要配置文件为 `conf/application.yml`,以下是关键配置项: @@ -72,7 +122,7 @@ pd: data-path: ./pd_data # 自动扩容的检查周期(秒) patrol-interval: 1800 - # 初始 store 列表,在列表内的 store 自动激活 + # 集群可用所需的最小 Store 数量 initial-store-count: 1 # store 的配置信息,格式为 IP:gRPC端口 initial-store-list: 127.0.0.1:8500 @@ -116,7 +166,7 @@ partition: 启动成功后,可以在 `logs/hugegraph-pd-stdout.log` 中看到类似以下的日志: ``` -2024-xx-xx xx:xx:xx [main] [INFO] o.a.h.p.b.HugePDServer - Started HugePDServer in x.xxx seconds (JVM running for x.xxx) +YYYY-mm-dd xx:xx:xx [main] [INFO] o.a.h.p.b.HugePDServer - Started HugePDServer in x.xxx seconds (JVM running for x.xxx) ``` #### 5.2 停止 PD @@ -136,3 +186,11 @@ curl http://localhost:8620/actuator/health ``` 如果返回 `{"status":"UP"}`,则表示 PD 服务已成功启动。 + +此外,也可以通过 PD API 查看 Store 节点状态: + +```bash +curl http://localhost:8620/v1/stores +``` + +如果响应中 `state` 为 `Up`,说明对应的 Store 节点运行正常。在一个健康的 3 节点部署中,`storeId` 列表应包含 3 个 ID,且 `stateCountMap.Up`、`numOfService` 和 `numOfNormalService` 都应为 `3`。 diff --git a/content/cn/docs/quickstart/hugegraph/hugegraph-server.md b/content/cn/docs/quickstart/hugegraph/hugegraph-server.md index 5b0610e16..8ecc4a08f 100644 --- a/content/cn/docs/quickstart/hugegraph/hugegraph-server.md +++ b/content/cn/docs/quickstart/hugegraph/hugegraph-server.md @@ -12,18 +12,18 @@ Core 模块是 Tinkerpop 接口的实现,Backend 模块用于管理数据存 > ⚠️ **重要变更**: 从 1.7.0 版本开始,MySQL、PostgreSQL、Cassandra、ScyllaDB 等遗留后端已被移除。如需使用这些后端,请使用 1.5.x 或更早版本。 -> 文档中会出现 `HugeGraph-Server` 及 `HugeGraphServer` 这两种写法,其他组件也类似。 -> 这两种写法含义上并明显差异,可以这么区分:`HugeGraph-Server` 表示服务端相关组件代码,`HugeGraphServer` 表示服务进程。 +> 文档中会出现 `HugeGraph-Server` 与 `HugeGraphServer` 两种写法,其他组件也类似。 +> 两者在含义上并无明显差异,可简单区分为:`HugeGraph-Server` 表示服务端相关组件代码,`HugeGraphServer` 表示服务进程。 ### 2 依赖 #### 2.1 安装 Java 11 (JDK 11) -请考虑在 Java 11 的环境上启动 `HugeGraph-Server`(在 1.5.0 版前,会保留对 Java 8 的基本兼容) +建议在 Java 11 环境中运行 `HugeGraph-Server`(1.5.0 之前的版本仍保留对 Java 8 的基本兼容)。 -**在往下阅读之前先执行 `java -version` 命令确认 jdk 版本** +**在继续阅读前,请先执行 `java -version` 命令确认 JDK 版本。** -> 注:使用 Java 8 启动 HugeGraph-Server 会失去一些**安全性**的保障,也会降低性能相关指标 (请尽早升级/迁移,1.7.0 不再支持) +> 注:使用 Java 8 启动 HugeGraph-Server 会失去部分**安全性**保障,也会影响性能表现。请尽早升级或迁移,1.7.0 起已不再支持 Java 8。 ### 3 部署 @@ -34,47 +34,48 @@ Core 模块是 Tinkerpop 接口的实现,Backend 模块用于管理数据存 - 方式 3:源码编译 - 方式 4:使用 tools 工具部署 (Outdated) -**注意** 生产或对外网暴露访问的环境必须使用 Java 11 并开启 [Auth 权限认证](/cn/docs/config/config-authentication/), 否则会有安全隐患。 +**注意**:生产环境或对公网暴露的环境必须使用 Java 11,并开启 [Auth 权限认证](/cn/docs/config/config-authentication/),否则存在安全风险。 #### 3.1 使用 Docker 容器 (便于**测试**) -可参考 [Docker 部署方式](https://github.com/apache/hugegraph/blob/master/hugegraph-server/hugegraph-dist/docker/README.md)。 +可参考 [Docker 部署方式](https://github.com/apache/hugegraph/blob/master/docker/README.md)。 -我们可以使用 `docker run -itd --name=server -p 8080:8080 -e PASSWORD=xxx hugegraph/hugegraph:1.7.0` 去快速启动一个内置了 `RocksDB` 的 `Hugegraph server`. +可以使用 `docker run -itd --name=server -p 8080:8080 -e PASSWORD=xxx hugegraph/hugegraph:1.7.0` 快速启动一个内置 `RocksDB` 后端的 `HugeGraph-Server` 实例。 可选项: -1. 可以使用 `docker exec -it server bash` 进入容器完成一些操作 -2. 可以使用 `docker run -itd --name=server -p 8080:8080 -e PRELOAD="true" hugegraph/hugegraph:1.7.0` 在启动的时候预加载一个**内置的**样例图。可以通过 `RESTful API` 进行验证。具体步骤可以参考 [5.1.9](#519-%E5%90%AF%E5%8A%A8-server-%E7%9A%84%E6%97%B6%E5%80%99%E5%88%9B%E5%BB%BA%E7%A4%BA%E4%BE%8B%E5%9B%BE) -3. 可以使用 `-e PASSWORD=xxx` 设置是否开启鉴权模式以及 admin 的密码,具体步骤可以参考 [Config Authentication](/cn/docs/config/config-authentication#使用-docker-时开启鉴权模式) +1. 可以使用 `docker exec -it server bash` 进入容器执行运维或调试操作。 +2. 可以使用 `docker run -itd --name=server -p 8080:8080 -e PRELOAD="true" hugegraph/hugegraph:1.7.0` 在启动时预加载一个**内置**样例图。可通过 `RESTful API` 进行验证,具体步骤可参考 [5.1.8](#518-%E5%90%AF%E5%8A%A8-server-%E7%9A%84%E6%97%B6%E5%80%99%E5%88%9B%E5%BB%BA%E7%A4%BA%E4%BE%8B%E5%9B%BE)。 +3. 可以使用 `-e PASSWORD=xxx` 开启鉴权模式并设置 admin 密码,具体步骤可参考 [Config Authentication](/cn/docs/config/config-authentication#使用-docker-时开启鉴权模式)。 -如果使用 docker desktop,则可以按照如下的方式设置可选项: +如果使用 Docker Desktop,则可以按如下方式设置相关选项:
image
-另外,如果我们希望能够在一个文件中管理除了 `server` 之外的其他 Hugegraph 相关的实例,我们也可以使用 `docker-compose`完成部署,使用命令 `docker-compose up -d`,(当然只配置 `server` 也是可以的)以下是一个样例的 `docker-compose.yml`: +> **注意**:Docker Compose 文件使用桥接网络(`hg-net`),适用于 Linux 和 Mac(Docker Desktop)。如需运行 3 节点分布式集群,请为 Docker Desktop 分配至少 **12 GB** 内存(设置 → 资源 → 内存)。Linux 上 Docker 直接使用宿主机内存。 -```yaml -version: '3' -services: - server: - image: hugegraph/hugegraph:1.7.0 - container_name: server - environment: - - PASSWORD=xxx - # - PASSWORD=xxx 为可选参数,设置的时候可以开启鉴权模式,并设置密码 - # - PRELOAD=true - # - PRELOAD=true 为可选参数,为 True 时可以在启动的时候预加载一个内置的样例图 - ports: - - 8080:8080 +如果希望通过一个配置文件统一管理 HugeGraph 的多个服务实例,则可以使用 `docker compose`。 +[`docker/`](https://github.com/apache/hugegraph/tree/master/docker) 目录下提供了两个 compose 文件: + +- **单节点快速启动**(预构建镜像):`docker/docker-compose.yml` +- **单节点开发构建**(从源码构建):`docker/docker-compose.dev.yml` + +```bash +cd hugegraph/docker +# 注意版本号请随时保持更新 → 1.x.0 +HUGEGRAPH_VERSION=1.7.0 docker compose up -d ``` +如需开启鉴权,可在 compose 文件的环境变量中添加 `PASSWORD=xxx`,或在 `docker run` 命令中传入 `-e PASSWORD=xxx`。 + +完整的部署指南请参阅 [docker/README.md](https://github.com/apache/hugegraph/blob/master/docker/README.md)。 + > 注意: > -> 1. hugegraph 的 docker 镜像是一个便捷版本,用于快速启动 hugegraph,并不是**官方发布物料包方式**。你可以从 [ASF Release Distribution Policy](https://infra.apache.org/release-distribution.html#dockerhub) 中得到更多细节。 +> 1. HugeGraph 的 Docker 镜像主要用于便捷地快速启动 HugeGraph,并不是 **ASF 官方发布物料包**。你可以从 [ASF Release Distribution Policy](https://infra.apache.org/release-distribution.html#dockerhub) 中了解更多细节。 > > 2. 推荐使用 `release tag` (如 `1.7.0/1.x.0`) 以获取稳定版。使用 `latest` tag 可以使用开发中的最新功能。 @@ -134,7 +135,6 @@ mvn package -DskipTests
过时的 tools 工具安装 -```bash #### 3.4 使用 tools 工具部署 (Outdated) HugeGraph-Tools 提供了一键部署的命令行工具,用户可以使用该工具快速地一键下载、解压、配置并启动 HugeGraph-Server 和 HugeGraph-Hubble,最新的 HugeGraph-Toolchain 中已经包含所有的这些工具,直接下载它解压就有工具包集合了 @@ -168,11 +168,11 @@ bin/hugegraph deploy -v {hugegraph-version} -p {install-path} [-u {download-path #### 5.1 使用启动脚本启动 -启动分为"首次启动"和"非首次启动",这么区分是因为在第一次启动前需要初始化后端数据库,然后启动服务。 +启动流程分为“首次启动”和“非首次启动”。首次启动前需要先初始化后端数据库,然后再启动服务。 -而在人为停掉服务后,或者其他原因需要再次启动服务时,因为后端数据库是持久化存在的,直接启动服务即可。 +如果服务曾被手动停止,或因其他原因需要再次启动,由于后端数据库已持久化存在,通常可以直接启动服务。 -HugeGraphServer 启动时会连接后端存储并尝试检查后端存储版本号,如果未初始化后端或者后端已初始化但版本不匹配时(旧版本数据),HugeGraphServer 会启动失败,并给出错误信息。 +HugeGraphServer 启动时会连接后端存储并检查其版本信息。如果后端尚未初始化,或者已初始化但版本不匹配(例如存在旧版本数据),HugeGraphServer 会启动失败并给出错误信息。 如果需要外部访问 HugeGraphServer,请修改 `rest-server.properties` 的 `restserver.url` 配置项(默认为 `http://127.0.0.1:8080`),修改成机器名或 IP 地址。 @@ -307,6 +307,34 @@ curl http://localhost:8081/graphs ```bash bin/stop-hugegraph.sh ``` + +###### Docker 分布式集群 + +通过 Docker-Compose 运行完整的分布式集群(3 PD + 3 Store + 3 Server): + + +```bash +cd hugegraph/docker +HUGEGRAPH_VERSION=1.7.0 docker compose -f docker-compose-3pd-3store-3server.yml up -d +``` + +服务通过 `hg-net` 桥接网络上的容器主机名进行通信。配置通过环境变量注入: + +```yaml +# Server 配置 +HG_SERVER_BACKEND: hstore +HG_SERVER_PD_PEERS: pd0:8686,pd1:8686,pd2:8686 +``` + +验证集群: +```bash +curl http://localhost:8080/versions +curl http://localhost:8620/v1/stores +``` + +运行时日志可通过 `docker logs `(如 `docker logs hg-pd0`)直接查看,无需进入容器。 + +完整的环境变量参考、端口表和故障排查指南请参阅 [docker/README.md](https://github.com/apache/hugegraph/blob/master/docker/README.md)。
##### 5.1.2 RocksDB / ToplingDB @@ -570,7 +598,7 @@ Connecting to HugeGraphServer (http://127.0.0.1:8080/graphs)....OK ##### 5.1.8 启动 server 的时候创建示例图 -在脚本启动时候携带 `-p true`参数,表示 preload, 即创建示例图图 +在启动脚本时携带 `-p true` 参数,表示开启 preload,即创建示例图。 ``` bin/start-hugegraph.sh -p true @@ -590,7 +618,7 @@ Connecting to HugeGraphServer (http://127.0.0.1:8080/graphs)......OK #### 5.2 使用 Docker -在 [3.1 使用 Docker 容器](#31-使用-docker-容器-便于测试)中,我们已经介绍了如何使用 `docker` 部署 `hugegraph-server`, 我们还可以使用其他的后端存储或者设置参数在 sever 启动的时候加载样例图 +在 [3.1 使用 Docker 容器](#31-使用-docker-容器-便于测试) 中,我们已经介绍了如何使用 `docker` 部署 `hugegraph-server`。此外,也可以通过切换后端存储或设置参数,在 Server 启动时加载样例图。 ##### 5.2.1 使用 Cassandra 作为后端 @@ -652,7 +680,7 @@ volumes: 在这个 yaml 中,需要在环境变量中以 `hugegraph.`的形式进行参数传递,配置 Cassandra 相关的参数。 -具体来说,在 `hugegraph.properties` 配置文件中,提供了 `backend=xxx`, `cassandra.host=xxx` 等配置项,为了配置这些配置项,在传递环境变量的过程之中,我们需要在这些配置项前加上 `hugegrpah.`,即 `hugegraph.backend` 和 `hugegraph.cassandra.host`。 +具体来说,在 `hugegraph.properties` 配置文件中,提供了 `backend=xxx`、`cassandra.host=xxx` 等配置项。为了通过环境变量传递这些配置,需要在配置项前加上 `hugegraph.`,例如 `hugegraph.backend` 和 `hugegraph.cassandra.host`。 其他配置可以参照 [4 配置](#4-配置) @@ -660,7 +688,7 @@ volumes: ##### 5.2.2 启动 server 的时候创建示例图 -在 docker 启动的时候设置环境变量 `PRELOAD=true`, 从而实现启动脚本的时候加载数据。 +在 Docker 启动时设置环境变量 `PRELOAD=true`,即可在启动脚本执行过程中加载样例数据。 1. 使用`docker run` diff --git a/content/en/docs/guides/hugegraph-docker-cluster.md b/content/en/docs/guides/hugegraph-docker-cluster.md new file mode 100644 index 000000000..6b742f6ae --- /dev/null +++ b/content/en/docs/guides/hugegraph-docker-cluster.md @@ -0,0 +1,136 @@ +--- +title: "HugeGraph Docker Cluster Guide" +linkTitle: "Docker Cluster" +weight: 6 +--- + +## Overview + +HugeGraph can quickly run a full distributed deployment (PD + Store + Server) with Docker Compose. This works on Linux and Mac. + +## Prerequisites + +- Docker Engine 20.10+ or Docker Desktop 4.x+ +- Docker Compose v2 +- For a 3-node cluster on Mac: allocate at least **12 GB** memory (Settings → Resources → Memory). Adjust this on other platforms as needed. + +> **Tested environments**: Linux (native Docker) and macOS (Docker Desktop with ARM M4). + +## Compose Files + +Three compose files are available in the [`docker/`](https://github.com/apache/hugegraph/tree/master/docker) directory of the HugeGraph main repository: + +| File | Description | +|------|-------------| +| `docker-compose.yml` | Quickstart for a single-host deployment using pre-built images | +| `docker-compose.dev.yml` | Development mode for a single-host deployment built from source | +| `docker-compose-3pd-3store-3server.yml` | Distributed cluster with 3 PD, 3 Store, and 3 Server processes | + +> **Note**: The following steps assume you have already cloned or pulled the HugeGraph main repository locally, or at least have its `docker/` directory available. + +## Single-Node Quickstart + +```bash +cd hugegraph/docker +# Keep the version aligned with the latest release, for example 1.x.0 +HUGEGRAPH_VERSION=1.7.0 docker compose up -d +``` + +Verify: +```bash +curl http://localhost:8080/versions +``` + +## 3-Node Cluster Quickstart + +```bash +cd hugegraph/docker +HUGEGRAPH_VERSION=1.7.0 docker compose -f docker-compose-3pd-3store-3server.yml up -d +``` + +Built-in startup ordering: +1. PD nodes start first and must pass the `/v1/health` check +2. Store nodes start only after all PD nodes are healthy +3. Server nodes start last, after all PD and Store nodes are healthy + +Verify that the cluster is healthy: +```bash +curl http://localhost:8620/v1/health # PD health +curl http://localhost:8520/v1/health # Store health +curl http://localhost:8080/versions # Server +curl http://localhost:8620/v1/stores # Registered stores +curl http://localhost:8620/v1/partitions # Partition assignment +``` + +## Environment Variable Reference + +### PD Variables + +| Variable | Required | Default | Maps To | +|----------|----------|---------|---------| +| `HG_PD_GRPC_HOST` | Yes | — | `grpc.host` | +| `HG_PD_RAFT_ADDRESS` | Yes | — | `raft.address` | +| `HG_PD_RAFT_PEERS_LIST` | Yes | — | `raft.peers-list` | +| `HG_PD_INITIAL_STORE_LIST` | Yes | — | `pd.initial-store-list` | +| `HG_PD_GRPC_PORT` | No | `8686` | `grpc.port` | +| `HG_PD_REST_PORT` | No | `8620` | `server.port` | +| `HG_PD_DATA_PATH` | No | `/hugegraph-pd/pd_data` | `pd.data-path` | +| `HG_PD_INITIAL_STORE_COUNT` | No | `1` | `pd.initial-store-count` | + +> **Deprecated aliases**: `GRPC_HOST` → `HG_PD_GRPC_HOST`, `RAFT_ADDRESS` → `HG_PD_RAFT_ADDRESS`, `RAFT_PEERS` → `HG_PD_RAFT_PEERS_LIST` + +### Store Variables + +| Variable | Required | Default | Maps To | +|----------|----------|---------|---------| +| `HG_STORE_PD_ADDRESS` | Yes | — | `pdserver.address` | +| `HG_STORE_GRPC_HOST` | Yes | — | `grpc.host` | +| `HG_STORE_RAFT_ADDRESS` | Yes | — | `raft.address` | +| `HG_STORE_GRPC_PORT` | No | `8500` | `grpc.port` | +| `HG_STORE_REST_PORT` | No | `8520` | `server.port` | +| `HG_STORE_DATA_PATH` | No | `/hugegraph-store/storage` | `app.data-path` | + +> **Deprecated aliases**: `PD_ADDRESS` → `HG_STORE_PD_ADDRESS`, `GRPC_HOST` → `HG_STORE_GRPC_HOST`, `RAFT_ADDRESS` → `HG_STORE_RAFT_ADDRESS` + +### Server Variables + +| Variable | Required | Default | Maps To | +|----------|----------|---------|---------| +| `HG_SERVER_BACKEND` | Yes | — | `backend` in `hugegraph.properties` | +| `HG_SERVER_PD_PEERS` | Yes | — | `pd.peers` | +| `STORE_REST` | No | — | used by `wait-partition.sh` | +| `PASSWORD` | No | — | enables auth mode | + +> **Deprecated aliases**: `BACKEND` → `HG_SERVER_BACKEND`, `PD_PEERS` → `HG_SERVER_PD_PEERS` + +## Port Reference + +| Service | Host Port | Purpose | +|---------|-----------|---------| +| pd0 | 8620 | REST API | +| pd0 | 8686 | gRPC | +| pd1 | 8621 | REST API | +| pd1 | 8687 | gRPC | +| pd2 | 8622 | REST API | +| pd2 | 8688 | gRPC | +| store0 | 8500 | gRPC | +| store0 | 8520 | REST API | +| store1 | 8501 | gRPC | +| store1 | 8521 | REST API | +| store2 | 8502 | gRPC | +| store2 | 8522 | REST API | +| server0 | 8080 | Graph API | +| server1 | 8081 | Graph API | +| server2 | 8082 | Graph API | + +## Troubleshooting + +1. **Containers exit due to OOM (`exit code 137`)**: Increase Docker Desktop memory to at least 12 GB, or reduce the JVM heap settings for the process that is being killed. + +2. **Raft leader election timeout**: Check that `HG_PD_RAFT_PEERS_LIST` is identical on all PD nodes. Verify connectivity with `docker exec hg-pd0 ping pd1`. + +3. **Partition assignment does not complete**: Check `curl http://localhost:8620/v1/stores` and confirm that all 3 stores show `"state":"Up"` before partition assignment can finish. + +4. **Connection refused**: Ensure `HG_*` environment variables use container hostnames (`pd0`, `store0`) instead of `127.0.0.1`. + +**Viewing runtime logs**: Use `docker logs ` (e.g. `docker logs hg-pd0`) to view logs directly without exec-ing into the container. diff --git a/content/en/docs/quickstart/hugegraph/hugegraph-hstore.md b/content/en/docs/quickstart/hugegraph/hugegraph-hstore.md index 2d82a48d5..9c357de63 100644 --- a/content/en/docs/quickstart/hugegraph/hugegraph-hstore.md +++ b/content/en/docs/quickstart/hugegraph/hugegraph-hstore.md @@ -12,10 +12,10 @@ HugeGraph-Store is the storage node component of HugeGraph's distributed version #### 2.1 Requirements -- Operating System: Linux or MacOS (Windows has not been fully tested) +- Operating System: Linux or macOS (Windows has not been fully tested) - Java version: ≥ 11 - Maven version: ≥ 3.5.0 -- Deployed HugeGraph-PD (for multi-node deployment) +- Deploy HugeGraph-PD first for multi-node deployment ### 3 Deployment @@ -50,6 +50,50 @@ mvn clean install -DskipTests=true # target/apache-hugegraph-incubating-{version}.tar.gz ``` +#### 3.3 Docker Deployment + +The HugeGraph-Store Docker image is available on Docker Hub as `hugegraph/store`. + +> **Note**: The following steps assume you have already cloned or pulled the HugeGraph main repository locally, or at least have its `docker/` directory available. + +Use the compose file to deploy the complete 3-node cluster (PD + Store + Server): + +```bash +cd hugegraph/docker +# Keep the version aligned with the latest release, for example 1.x.0 +HUGEGRAPH_VERSION=1.7.0 docker compose -f docker-compose-3pd-3store-3server.yml up -d +``` + +To run a single Store node via `docker run`: + +```bash +docker run -d \ + -p 8520:8520 \ + -p 8500:8500 \ + -p 8510:8510 \ + -e HG_STORE_PD_ADDRESS=:8686 \ + -e HG_STORE_GRPC_HOST= \ + -e HG_STORE_RAFT_ADDRESS=:8510 \ + -v /path/to/storage:/hugegraph-store/storage \ + --name hugegraph-store \ + hugegraph/store:1.7.0 +``` + +**Environment variable reference:** + +| Variable | Required | Default | Description | +|----------|----------|---------|-------------| +| `HG_STORE_PD_ADDRESS` | Yes | — | PD gRPC addresses (e.g. `pd0:8686,pd1:8686,pd2:8686`) | +| `HG_STORE_GRPC_HOST` | Yes | — | This node's hostname/IP for gRPC (e.g. `store0`) | +| `HG_STORE_RAFT_ADDRESS` | Yes | — | This node's Raft address (e.g. `store0:8510`) | +| `HG_STORE_GRPC_PORT` | No | `8500` | gRPC server port | +| `HG_STORE_REST_PORT` | No | `8520` | REST API port | +| `HG_STORE_DATA_PATH` | No | `/hugegraph-store/storage` | Data storage path | + +> **Note**: In Docker bridge networking, use container hostnames (e.g. `store0`) for `HG_STORE_GRPC_HOST` instead of IP addresses. + +> **Deprecated aliases**: `PD_ADDRESS`, `GRPC_HOST`, `RAFT_ADDRESS` still work but log a deprecation warning. Use the `HG_STORE_*` names for new deployments. + ### 4 Configuration The main configuration file for Store is `conf/application.yml`. Here are the key configuration items: @@ -116,7 +160,7 @@ Ensure that the PD service is already started, then in the Store installation di After successful startup, you can see logs similar to the following in `logs/hugegraph-store-server.log`: ``` -2024-xx-xx xx:xx:xx [main] [INFO] o.a.h.s.n.StoreNodeApplication - Started StoreNodeApplication in x.xxx seconds (JVM running for x.xxx) +YYYY-mm-dd xx:xx:xx [main] [INFO] o.a.h.s.n.StoreNodeApplication - Started StoreNodeApplication in x.xxx seconds (JVM running for x.xxx) ``` #### 5.2 Stop Store @@ -188,6 +232,36 @@ pdserver: address: 127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688 ``` +#### 6.3 Docker Distributed Cluster Configuration + +The distributed Store cluster definition is included in `docker/docker-compose-3pd-3store-3server.yml`. Each Store node gets its own hostname and environment variables: + +```yaml +# store0 +HG_STORE_PD_ADDRESS: pd0:8686,pd1:8686,pd2:8686 +HG_STORE_GRPC_HOST: store0 +HG_STORE_GRPC_PORT: "8500" +HG_STORE_REST_PORT: "8520" +HG_STORE_RAFT_ADDRESS: store0:8510 +HG_STORE_DATA_PATH: /hugegraph-store/storage + +# store1 +HG_STORE_PD_ADDRESS: pd0:8686,pd1:8686,pd2:8686 +HG_STORE_GRPC_HOST: store1 +HG_STORE_RAFT_ADDRESS: store1:8510 + +# store2 +HG_STORE_PD_ADDRESS: pd0:8686,pd1:8686,pd2:8686 +HG_STORE_GRPC_HOST: store2 +HG_STORE_RAFT_ADDRESS: store2:8510 +``` + +Store nodes start only after all PD nodes pass healthchecks (`/v1/health`), enforced via `depends_on: condition: service_healthy`. + +To view runtime logs for a running Store container use `docker logs ` (e.g. `docker logs hg-store0`). + +See [docker/README.md](https://github.com/apache/hugegraph/blob/master/docker/README.md) for the full setup guide. + ### 7 Verify Store Service Confirm that the Store service is running properly: @@ -201,5 +275,47 @@ If it returns `{"status":"UP"}`, it indicates that the Store service has been su Additionally, you can check the status of Store nodes in the cluster through the PD API: ```bash -curl http://localhost:8620/pd/api/v1/stores +curl http://localhost:8620/v1/stores +``` + +If Store is configured successfully, the response should include status information for the current node, and `state: "Up"` means the node is running normally. + +The example below shows a single Store node. If all three nodes are configured correctly and running, the `storeId` list should contain three IDs, and `stateCountMap.Up`, `numOfService`, and `numOfNormalService` should all be `3`. + +```javascript +{ + "message": "OK", + "data": { + "stores": [ + { + "storeId": 8319292642220586694, + "address": "127.0.0.1:8500", + "raftAddress": "127.0.0.1:8510", + "version": "", + "state": "Up", + "deployPath": "/Users/{your_user_name}/hugegraph/apache-hugegraph-incubating-1.5.0/apache-hugegraph-store-incubating-1.5.0/lib/hg-store-node-1.5.0.jar", + "dataPath": "./storage", + "startTimeStamp": 1754027127969, + "registedTimeStamp": 1754027127969, + "lastHeartBeat": 1754027909444, + "capacity": 494384795648, + "available": 346535829504, + "partitionCount": 0, + "graphSize": 0, + "keyCount": 0, + "leaderCount": 0, + "serviceName": "127.0.0.1:8500-store", + "serviceVersion": "", + "serviceCreatedTimeStamp": 1754027127000, + "partitions": [] + } + ], + "stateCountMap": { + "Up": 1 + }, + "numOfService": 1, + "numOfNormalService": 1 + }, + "status": 0 +} ``` diff --git a/content/en/docs/quickstart/hugegraph/hugegraph-pd.md b/content/en/docs/quickstart/hugegraph/hugegraph-pd.md index c8b6cf401..9f30bd794 100644 --- a/content/en/docs/quickstart/hugegraph/hugegraph-pd.md +++ b/content/en/docs/quickstart/hugegraph/hugegraph-pd.md @@ -12,7 +12,7 @@ HugeGraph-PD (Placement Driver) is the metadata management component of HugeGrap #### 2.1 Requirements -- Operating System: Linux or MacOS (Windows has not been fully tested) +- Operating System: Linux or macOS (Windows has not been fully tested) - Java version: ≥ 11 - Maven version: ≥ 3.5.0 @@ -49,6 +49,57 @@ mvn clean install -DskipTests=true # target/apache-hugegraph-incubating-{version}.tar.gz ``` +#### 3.3 Docker Deployment + +The HugeGraph-PD Docker image is available on Docker Hub as `hugegraph/pd`. + +> **Note**: The following steps assume you have already cloned or pulled the HugeGraph main repository locally, or at least have its `docker/` directory available. + +Use the `docker compose` setup to deploy the complete 3-node cluster (PD + Store + Server): + +```bash +cd hugegraph/docker +# Keep the version aligned with the latest release, for example 1.x.0 +HUGEGRAPH_VERSION=1.7.0 docker compose -f docker-compose-3pd-3store-3server.yml up -d +``` + +To run a single PD node via `docker run`, configuration is provided via environment variables: + +```bash +docker run -d \ + -p 8620:8620 \ + -p 8686:8686 \ + -p 8610:8610 \ + -e HG_PD_GRPC_HOST= \ + -e HG_PD_RAFT_ADDRESS=:8610 \ + -e HG_PD_RAFT_PEERS_LIST=:8610 \ + -e HG_PD_INITIAL_STORE_LIST=:8500 \ + -v /path/to/data:/hugegraph-pd/pd_data \ + --name hugegraph-pd \ + hugegraph/pd:1.7.0 +``` + +**Environment variable reference:** + +| Variable | Required | Default | Description | +|----------|----------|---------|-------------| +| `HG_PD_GRPC_HOST` | Yes | — | This node's hostname/IP for gRPC (e.g. `pd0` in Docker, `192.168.1.10` on bare metal) | +| `HG_PD_RAFT_ADDRESS` | Yes | — | This node's Raft address (e.g. `pd0:8610`) | +| `HG_PD_RAFT_PEERS_LIST` | Yes | — | All PD peers (e.g. `pd0:8610,pd1:8610,pd2:8610`) | +| `HG_PD_INITIAL_STORE_LIST` | Yes | — | Expected store gRPC addresses (e.g. `store0:8500,store1:8500,store2:8500`) | +| `HG_PD_GRPC_PORT` | No | `8686` | gRPC server port | +| `HG_PD_REST_PORT` | No | `8620` | REST API port | +| `HG_PD_DATA_PATH` | No | `/hugegraph-pd/pd_data` | Metadata storage path | +| `HG_PD_INITIAL_STORE_COUNT` | No | `1` | Minimum stores required for cluster availability | + +> **Note**: In Docker bridge networking, use container hostnames (e.g. `pd0`) for `HG_PD_GRPC_HOST` and `HG_PD_RAFT_ADDRESS` instead of IP addresses. + +> **Deprecated aliases**: `GRPC_HOST`, `RAFT_ADDRESS`, `RAFT_PEERS`, `PD_INITIAL_STORE_LIST` still work but log a deprecation warning. Use the `HG_PD_*` names for new deployments. + +To view runtime logs for a running PD container use `docker logs ` (e.g. `docker logs hg-pd0`). + +See [docker/README.md](https://github.com/apache/hugegraph/blob/master/docker/README.md) for the full cluster setup guide. + ### 4 Configuration The main configuration file for PD is `conf/application.yml`. Here are the key configuration items: @@ -72,7 +123,7 @@ pd: data-path: ./pd_data # Auto-expansion check cycle (seconds) patrol-interval: 1800 - # Initial store list, stores in the list are automatically activated + # Minimum number of Store nodes required for cluster availability initial-store-count: 1 # Store configuration information, format is IP:gRPC port initial-store-list: 127.0.0.1:8500 @@ -116,7 +167,7 @@ In the PD installation directory, execute: After successful startup, you can see logs similar to the following in `logs/hugegraph-pd-stdout.log`: ``` -2024-xx-xx xx:xx:xx [main] [INFO] o.a.h.p.b.HugePDServer - Started HugePDServer in x.xxx seconds (JVM running for x.xxx) +YYYY-mm-dd xx:xx:xx [main] [INFO] o.a.h.p.b.HugePDServer - Started HugePDServer in x.xxx seconds (JVM running for x.xxx) ``` #### 5.2 Stop PD @@ -137,13 +188,13 @@ curl http://localhost:8620/actuator/health If it returns `{"status":"UP"}`, it indicates that the PD service has been successfully started. -Additionally, you can verify the status of the Store node by querying the PD API: +Additionally, you can verify Store node status through the PD API: ```bash curl http://localhost:8620/v1/stores ``` -If the Store is configured successfully, the response of the above interface should contain the status information of the current node. The status "Up" indicates that the node is running normally. Only the response of one node configuration is shown here. If all three nodes are configured successfully and are running, the `storeId` list in the response should contain three IDs, and the `Up`, `numOfService`, and `numOfNormalService` fields in `stateCountMap` should be 3. +If the response shows `state` as `Up`, the corresponding Store node is running normally. The example below shows a single Store node. In a healthy 3-node deployment, the `storeId` list should contain three IDs, and `stateCountMap.Up`, `numOfService`, and `numOfNormalService` should all be `3`. ```javascript { diff --git a/content/en/docs/quickstart/hugegraph/hugegraph-server.md b/content/en/docs/quickstart/hugegraph/hugegraph-server.md index ee70e6d2d..84469f08e 100644 --- a/content/en/docs/quickstart/hugegraph/hugegraph-server.md +++ b/content/en/docs/quickstart/hugegraph/hugegraph-server.md @@ -6,27 +6,23 @@ weight: 1 ### 1 HugeGraph-Server Overview -`HugeGraph-Server` is the core part of the HugeGraph Project, contains submodules such as graph-core, backend, API. +`HugeGraph-Server` is the core server component of the HugeGraph project. It includes submodules such as graph-core, backend, and API. -The Core Module is an implementation of the Tinkerpop interface; The Backend module is used to save the graph data to the data store. For version 1.7.0+, supported backends include: RocksDB (standalone default), HStore (distributed), HBase, and Memory. The API Module provides HTTP Server, which converts Client's HTTP request into a call to Core Module. +The Core module implements the TinkerPop interfaces. The Backend module manages data storage. Starting from 1.7.0, supported backends include RocksDB (the default standalone backend), HStore (distributed), HBase, and Memory. The API module provides an HTTP server that converts client requests into calls to the Core module. > ⚠️ **Important Change**: Starting from version 1.7.0, legacy backends such as MySQL, PostgreSQL, Cassandra, and ScyllaDB have been removed. If you need to use these backends, please use version 1.5.x or earlier. -> There will be two spellings HugeGraph-Server and HugeGraphServer in the document, and other -> modules are similar. There is no big difference in the meaning of these two ways, -> which can be distinguished as follows: `HugeGraph-Server` represents the code of server-related -> components, `HugeGraphServer` represents the service process. +> The documentation uses both `HugeGraph-Server` and `HugeGraphServer`, and the same pattern applies to other components. The two names are nearly interchangeable: `HugeGraph-Server` usually refers to the server-side codebase, while `HugeGraphServer` refers to the running service process. ### 2 Dependency for Building/Running #### 2.1 Install Java 11 (JDK 11) -You need to use Java 11 to run `HugeGraph-Server` (compatible with Java 8 before 1.5.0, but not recommended to use), -and configure by yourself. +Use Java 11 to run `HugeGraph-Server`. Versions earlier than 1.5.0 kept basic compatibility with Java 8, but Java 11 is recommended. -**Be sure to execute the `java -version` command to check the jdk version before reading** +**Before continuing, run `java -version` to confirm your JDK version.** -> Note: Using Java8 will lose some security guarantees, we recommend using Java11 in production +> Note: Running HugeGraph-Server on Java 8 loses some security protections and may reduce performance. Please upgrade as soon as possible. Java 8 is no longer supported starting from 1.7.0. ### 3 Deploy @@ -37,49 +33,50 @@ There are four ways to deploy HugeGraph-Server components: - Method 3: Source code compilation - Method 4: One-click deployment -**Note:** If it's exposed to the public network, **must enable** [Auth authentication](/docs/config/config-authentication/) to ensure safety (so as the legacy version). +**Note:** For production environments or environments exposed to the public network, you must use Java 11 and enable [Auth authentication](/docs/config/config-authentication/) to avoid security risks. #### 3.1 Use Docker container (Convenient for Test/Dev) -You can refer to the [Docker deployment guide](https://github.com/apache/hugegraph/blob/master/hugegraph-server/hugegraph-dist/docker/README.md). +You can refer to the [Docker deployment guide](https://github.com/apache/hugegraph/blob/master/docker/README.md). -We can use `docker run -itd --name=server -p 8080:8080 -e PASSWORD=xxx hugegraph/hugegraph:1.7.0` to quickly start a `HugeGraph Server` with a built-in `RocksDB` backend. +You can use `docker run -itd --name=server -p 8080:8080 -e PASSWORD=xxx hugegraph/hugegraph:1.7.0` to quickly start a `HugeGraph-Server` instance with a built-in `RocksDB` backend. Optional: -1. use `docker exec -it graph bash` to enter the container to do some operations. -2. use `docker run -itd --name=graph -p 8080:8080 -e PRELOAD="true" hugegraph/hugegraph:1.7.0` to start with a **built-in** example graph. We can use `RESTful API` to verify the result. The detailed step can refer to [5.1.8](#518-create-an-example-graph-when-startup) -3. use `-e PASSWORD=xxx` to enable auth mode and set the password for admin. You can find more details from [Config Authentication](/docs/config/config-authentication#use-docker-to-enable-authentication-mode) +1. You can use `docker exec -it server bash` to enter the container for troubleshooting or other maintenance operations. +2. You can use `docker run -itd --name=server -p 8080:8080 -e PRELOAD="true" hugegraph/hugegraph:1.7.0` to preload a **built-in** sample graph at startup. You can verify it through the `RESTful API`. See [5.1.8](#518-create-an-example-graph-when-startup) for details. +3. You can use `-e PASSWORD=xxx` to enable authentication mode and set the admin password. See [Config Authentication](/docs/config/config-authentication#use-docker-to-enable-authentication-mode) for details. -If you use docker desktop, you can set the option like: +If you use Docker Desktop, you can set the options as follows:
image
-Also, if we want to manage the other Hugegraph related instances in one file, we can use `docker-compose` to deploy, with the command `docker-compose up -d` (you can config only `server`). Here is an example `docker-compose.yml`: +> **Note**: The Docker Compose files use bridge networking (`hg-net`) and work on Linux and Mac (Docker Desktop). For the 3-node distributed cluster on Mac (Docker Desktop), allocate at least **12 GB** of memory (Settings → Resources → Memory). On Linux, Docker uses host memory directly. -```yaml -version: '3' -services: - server: - image: hugegraph/hugegraph:1.7.0 - container_name: server - environment: - - PASSWORD=xxx - # PASSWORD is an option to enable auth mode with the password you set. - # - PRELOAD=true - # PRELOAD is a option to preload a build-in sample graph when initializing. - ports: - - 8080:8080 +If you want a single, unified setup for multiple HugeGraph services, you can use `docker compose`. +Two compose files are available in the [`docker/`](https://github.com/apache/hugegraph/tree/master/docker) directory: + +- **Single-node quickstart** (pre-built images): `docker/docker-compose.yml` +- **Single-node dev build** (build from source): `docker/docker-compose.dev.yml` + +```bash +cd hugegraph/docker +# Keep the version aligned with the latest release, for example 1.x.0 +HUGEGRAPH_VERSION=1.7.0 docker compose up -d ``` +To enable authentication, add `PASSWORD=xxx` to the service environment in the compose file or pass `-e PASSWORD=xxx` to `docker run`. + +See [docker/README.md](https://github.com/apache/hugegraph/blob/master/docker/README.md) for the full setup guide. + > Note: > -> 1. The docker image of the hugegraph is a convenient release to start it quickly, but not **official distribution** artifacts. You can find more details from [ASF Release Distribution Policy](https://infra.apache.org/release-distribution.html#dockerhub). +> 1. HugeGraph Docker images are provided as a convenient way to start HugeGraph quickly, but they are not official ASF distribution artifacts. You can find more details in the [ASF Release Distribution Policy](https://infra.apache.org/release-distribution.html#dockerhub). > -> 2. Recommend to use `release tag` (like `1.7.0`/`1.x.0`) for the stable version. Use `latest` tag to experience the newest functions in development. +> 2. We recommend using a release tag (such as `1.7.0` or `1.x.0`) for stable deployments. Use the `latest` tag only if you want the newest features still under development. -#### 3.2 Download the binary tar tarball +#### 3.2 Download the binary tarball You could download the binary tarball from the download page of the ASF site like this: ```bash @@ -111,6 +108,7 @@ curl https://downloads.apache.org/hugegraph/{version}/apache-hugegraph-incubatin # Way2 : clone the latest code by git way (e.g GitHub) git clone https://github.com/apache/hugegraph.git + ``` Compile and generate tarball @@ -186,13 +184,13 @@ For detailed configuration introduction, please refer to [configuration document #### 5.1 Use a startup script to startup -The startup is divided into "first startup" and "non-first startup." This distinction is because the back-end database needs to be initialized before the first startup, and then the service is started. -after the service is stopped artificially, or when the service needs to be started again for other reasons, because the backend database is persistent, you can start the service directly. +Startup is divided into "first startup" and "non-first startup". On the first startup, you need to initialize the backend database before starting the service. + +If the service was stopped manually, or needs to be started again for any other reason, you can usually start it directly because the backend database is persistent. -When HugeGraphServer starts, it will connect to the backend storage and try to check the version number of the backend storage. If the backend is not initialized or the backend has been initialized but the version does not match (old version data), HugeGraphServer will fail to start and give an error message. +When HugeGraphServer starts, it connects to the backend storage and checks its version information. If the backend has not been initialized, or if it was initialized with an incompatible version (for example, old-version data), HugeGraphServer will fail to start and report an error. -If you need to access HugeGraphServer externally, please modify the `restserver.url` configuration item of `rest-server.properties` -(default is `http://127.0.0.1:8080`), change to machine name or IP address. +If you need to access HugeGraphServer externally, modify the `restserver.url` configuration item in `rest-server.properties` (the default is `http://127.0.0.1:8080`) and change it to the machine name or IP address. Since the configuration (hugegraph.properties) and startup steps required by various backends are slightly different, the following will introduce the configuration and startup of each backend one by one. @@ -323,6 +321,32 @@ The sequence to stop the services should be the reverse of the startup sequence: ```bash bin/stop-hugegraph.sh ``` + +###### Docker Distributed Cluster + +Run the full distributed cluster (3 PD + 3 Store + 3 Server) with Docker Compose: + +```bash +cd hugegraph/docker +HUGEGRAPH_VERSION=1.7.0 docker compose -f docker-compose-3pd-3store-3server.yml up -d +``` + +Services communicate via container hostnames on the `hg-net` bridge network. Configuration is injected via environment variables: + +```yaml +# Server configuration +HG_SERVER_BACKEND: hstore +HG_SERVER_PD_PEERS: pd0:8686,pd1:8686,pd2:8686 +``` + +Verify the cluster: +```bash +curl http://localhost:8080/versions +curl http://localhost:8620/v1/stores +``` +To view runtime logs for any container use `docker logs ` (e.g. `docker logs hg-pd0`). + +See [docker/README.md](https://github.com/apache/hugegraph/blob/master/docker/README.md) for the full environment variable reference, port table, and troubleshooting guide. ##### 5.1.2 Memory @@ -585,7 +609,7 @@ Connecting to HugeGraphServer (http://127.0.0.1:8080/graphs)....OK ##### 5.1.8 Create an example graph when startup -Carry the `-p true` arguments when starting the script, which indicates `preload`, to create a sample graph. +Pass the `-p true` argument when starting the script to enable `preload`, which creates a sample graph. ``` bin/start-hugegraph.sh -p true @@ -606,7 +630,7 @@ This indicates the successful creation of the sample graph. #### 5.2 Use Docker to startup -In [3.1 Use Docker container](#31-use-docker-container-convenient-for-testdev), we have introduced how to use docker to deploy `hugegraph-server`. `server` can also preload an example graph by setting the parameter. +In [3.1 Use Docker container](#31-use-docker-container-convenient-for-testdev), we introduced how to deploy `hugegraph-server` with Docker. You can also switch storage backends or preload a sample graph by setting the corresponding parameters. ##### 5.2.1 Uses Cassandra as storage @@ -668,15 +692,15 @@ volumes: In this YAML file, configuration parameters related to Cassandra need to be passed as environment variables in the format of `hugegraph.`. -Specifically, in the configuration file `hugegraph.properties` , there are settings like `backend=xxx` and `cassandra.host=xxx`. To configure these settings during the process of passing environment variables, we need to prepend `hugegraph.` to these configurations, like `hugegraph.backend` and `hugegraph.cassandra.host`. +Specifically, the `hugegraph.properties` file contains settings such as `backend=xxx` and `cassandra.host=xxx`. To pass these settings through environment variables, prepend `hugegraph.` to the configuration keys, for example `hugegraph.backend` and `hugegraph.cassandra.host`. -The rest of the configurations can be referenced under [4 config](#4-config) +Refer to [4 Config](#4-config) for the remaining settings. ##### 5.2.2 Create an example graph when starting a server -Set the environment variable `PRELOAD=true` when starting Docker to load data during the execution of the startup script. +Set the environment variable `PRELOAD=true` when starting Docker so that sample data is loaded during startup. 1. Use `docker run` @@ -684,22 +708,24 @@ Set the environment variable `PRELOAD=true` when starting Docker to load data du 2. Use `docker-compose` - Create `docker-compose.yml` as following. We should set the environment variable `PRELOAD=true`. [`example.groovy`](https://github.com/apache/hugegraph/blob/master/hugegraph-server/hugegraph-dist/src/assembly/static/scripts/example.groovy) is a predefined script to preload the sample data. If needed, we can mount a new `example.groovy` to change the preload data. + Create a `docker-compose.yml` file like the following and set `PRELOAD=true` in the environment. [`example.groovy`](https://github.com/apache/hugegraph/blob/master/hugegraph-server/hugegraph-dist/src/assembly/static/scripts/example.groovy) is a predefined script used to preload sample data. If needed, you can mount a new `example.groovy` script to change the preload data. ```yaml version: '3' - services: - server: - image: hugegraph/hugegraph:1.7.0 - container_name: server - environment: - - PRELOAD=true - - PASSWORD=xxx - ports: - - 8080:8080 + services: + server: + image: hugegraph/hugegraph:1.7.0 + container_name: server + environment: + - PRELOAD=true + - PASSWORD=xxx + volumes: + - /path/to/yourscript:/hugegraph/scripts/example.groovy + ports: + - 8080:8080 ``` - Use `docker-compose up -d` to start the container + Use `docker-compose up -d` to start the container. And use the RESTful API to request `HugeGraphServer` and get the following result: @@ -709,7 +735,7 @@ And use the RESTful API to request `HugeGraphServer` and get the following resul {"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}}]} ``` -This indicates the successful creation of the sample graph. +This indicates that the sample graph was created successfully. ### 6. Access server