---
title: "OBKV-HBase 性能测试 - OceanBase 数据库 V4.6.0 | OceanBase 文档中心"
description: OBKV-HBase 性能测试 本文介绍如何使用 YCSB 工具对 OBKV-HBase 进行性能测试。YCSB-OBKV 是基于 YCSB (Yahoo! Cloud Serving Benchmark) 框架的 OBKV 性能测试工具。用于对 OBKV 接口进行读写性能基准测试。 工具说明 GitHub 仓库： …
image: https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*OSPzQ6GUQF4AAAAAQHAAAAgAeiGDAQ/original
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

文档反馈![](https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*P8CuR4UJ_FkAAAAAAAAAAAAADiGDAQ/original) OceanBase 数据库KV 型 - V 4.6.0

# OBKV-HBase 性能测试

更新时间：2026-06-15 14:16:01

[编辑](https://github.com/oceanbase/oceanbase-kv/edit/V4.6.0/zh-CN/200.obkv-hbase/500.performance-test.md)  

本文介绍如何使用 YCSB 工具对 OBKV-HBase 进行性能测试。YCSB-OBKV 是基于 YCSB (Yahoo! Cloud Serving Benchmark) 框架的 OBKV 性能测试工具。用于对 OBKV 接口进行读写性能基准测试。

## 工具说明

- GitHub 仓库：[oceanbase/YCSB（obkv 分支）](https://github.com/oceanbase/YCSB/tree/obkv)
 - 支持的测试模型：OBKV-HBase 和 OBKV-Table，本文仅介绍 OBKV-HBase 的测试方式。
 - 使用方式（二选一）：
     - Web UI（图形界面）：适用于新手，提供可视化操作 WEB 界面，支持的测试方式比较固定。
     - 命令行（CLI）：针对测试机器与外界网络不同的场景、支持更多自定义的测试行为。
 - 支持的操作类型：
     - load（数据加载）
     - put（写入）
     - read（读取）
     - scan（扫描）
     - batch_put（批量写入）
     - batch_read（批量读取）

## 前提条件

### 环境准备

- JAVA 8+
 - Maven 3.x
 - 已部署的 OBKV-HBase 集群（需要 ODP 地址或直连 configUrl）

### 获取项目

有两种方式获取项目，任选其一：

1. 克隆仓库

   ```shell
   # 克隆仓库并切换到 obkv 分支
   git clone -b obkv https://github.com/oceanbase/YCSB.git
   cd YCSB

   ```

   项目目录结构如下：

   ```shell
   YCSB/
   ├── obkv-hbase/       # OBKV-HBase 测试模块
   ├── obkv-table/       # OBKV-Table 测试模块
   ├── webui/            # Web UI 模块
   ├── core/             # YCSB 核心框架
   ├── deploy.sh         # 一键部署脚本（编译/启动/停止/重启）
   └── docs/             # 详细文档

   ```
 2. 下载压缩包

   点击[obkv 分支](https://github.com/oceanbase/YCSB/tree/obkv)在 Github 上下载压缩包。

   ![Web UI 启动](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/observer/kv/V4.4.2/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%950.png)

## 使用 Web UI

### 启动服务

```shell
# 首次启动（自动编译所有模块 + 启动 Web 服务）
./deploy.sh start --rebuild

# 后续启动（JAR 已存在，直接启动）
./deploy.sh start

# 服务管理命令
./deploy.sh status          # 查看运行状态
./deploy.sh logs --follow   # 实时查看日志
./deploy.sh stop            # 停止服务
./deploy.sh restart         # 重启服务

```

启动后浏览器访问 `http://localhost:8080`。

![建表](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/observer/kv/V4.4.2/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%951.png)

### 操作流程

1. 建表：顶部选择模块（OBKV HBase）→ 「建表向导」 Tab → 填写分区参数 → 生成 SQL → 填写数据库连接 → 执行建表

   ![运行测试](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/observer/kv/V4.4.2/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%952.png)
 2. 运行测试：性能测试 Tab → Step1 填写连接信息 → Step2 选择测试模式 → Step3 选择测试类型和参数 → 发起测试

   ![运行测试](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/observer/kv/V4.4.2/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%953.png)

   一些说明：

      - Step1：支持直连模式和 ODP 模式两种连接方式，两种连接方式的区别介绍见：[OBKV 连接模式](https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000005280328)
      - Step2：支持默认模式和前缀模式两种测试；
      - Step3：填写 YCSB 测试相关参数，如：压测线程、操作数、操作类型比例、字段数量和字段大小等配置
      - Step4：支持配置客户端相关配置，如超时时间、句柄连接数等参数。
 3. 查看结果：实时日志 Tab 查看输出，测试完成后查看结果 Tab 的吞吐量和延迟（见上图）

   #### 注意

   必须先执行 `load` 写入数据，再执行 `read`/`scan`/`batch_read` 测试。
 4. 历史记录：查看历史测试记录，包括：测试结果、测试配置、复用测试配置重新测试

   ![历史记录](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/observer/kv/V4.4.2/%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%954.png)

## 使用命令行

使用命令行测试的流程如下：

```shell
# Step 1: 编译
cd obkv-hbase && ./build.sh

# Step 2: 生成建表 SQL
# 一级 Range 分区：
./create_table.sh --max_key 1000 --partition_count 4
# 一级 Key 分区：
./create_table.sh --mode hbase --type first_part --partition_type key --partition_count 4
# 二级分区（Range + Key）：
./create_table.sh --mode hbase --type sec_part \
  --range_partition_count 30 \
  --range_start_timestamp 1704067200000 \
  --range_partition_duration_ms 2592000000 \
  --key_subpartition_count 40

# Step 3: 在 OceanBase 中执行生成的 SQL 文件

# Step 4: 编辑 workloads/workload_load，填写连接参数（至少填写以下参数）
# hbase.oceanbase.odpMode=true
# hbase.oceanbase.odpAddr=<ODP地址>
# hbase.oceanbase.odpPort=<ODP端口>
# hbase.oceanbase.fullUserName=<user@tenant#cluster>
# hbase.oceanbase.password=<密码>
# hbase.oceanbase.database=<数据库名>
# hbase.oceanbase.table=ycsb_test
# hbase.oceanbase.columnFamily=cf

# Step 5: 运行测试（命令同 OBKV-Table）
./run_fast_test.sh load
./run_fast_test.sh read

```

## 核心参数速查

本节介绍 YCSB 通用参数和 OBKV-HBase 专用参数。

### YCSB 通用参数

| **参数** | **说明** | **类型** | **默认值** |
| --- | --- | --- | --- |
| recordcount | 数据集总记录数 | Int | — |
| operationcount | 运行阶段操作总数 | Int | — |
| threadcount | 并发线程数 | Int | 1 |
| fieldcount | 每条记录字段数 | Int | 10 |
| fieldlength | 每字段字节长度 | Int | 100 |
| requestdistribution | 请求分布（uniform/zipfian/hotspot/latest） | String | uniform |
| insertorder | Key 生成顺序（hashed/ordered） | String | hashed |

### OBKV-HBase 连接参数

| **参数** | **说明** | **ODP 模式** | **直连模式** |
| --- | --- | --- | --- |
| hbase.oceanbase.odpMode | 连接模式 | true | false |
| hbase.oceanbase.odpAddr | ODP 地址 | 必填 | — |
| hbase.oceanbase.odpPort | ODP 端口 | 必填 | — |
| hbase.oceanbase.paramURL | 直连 URL | — | 必填 |
| hbase.oceanbase.sysUserName | 系统用户名 | — | 必填 |
| hbase.oceanbase.sysPassword | 系统密码 | — | 必填 |
| hbase.oceanbase.fullUserName | 用户名（user@tenant#cluster） | 必填 | 必填 |
| hbase.oceanbase.password | 密码 | 必填 | 必填 |
| hbase.oceanbase.database | 数据库名 | 必填 | 必填 |
| hbase.oceanbase.table | 表名 | 必填 | 必填 |
| hbase.oceanbase.columnFamily | 列族名 | 必填 | 必填 |

### OBKV-HBase 测试参数

| **模式** | **obkv.testMode 值** | **适用分区类型** | **额外要求** |
| --- | --- | --- | --- |
| 默认模式 | default | 一级 Key/Range 分区表 | 无 |
| 前缀查询模式 | prefix | 一级或二级分区表 | insertorder=ordered |

## 结果解读

测试完成后，可以通过分析以下关键指标，来判断测试结果是否符合预期：

| 指标 | 含义 | 优化方向 |
| --- | --- | --- |
| Throughput(ops/sec) | 每秒操作数 | 越高越好 |
| AverageLatency(us) | 平均延迟（微秒） | 越低越好 |
| 95thPercentileLatency(us) | P95 延迟 | 越低越好 |
| 99thPercentileLatency(us) | P99 延迟 | 越低越好 |
| Return=OK / Return=ERROR | 成功/失败计数 | ERROR 应为 0 |

## 常见问题

- read/scan/batch_read 报错：需先执行 `load` 加载数据。
 - 前缀模式失败：检查 insertorder 是否设为 ordered。
 - 调试问题：设置 `obkv.debug=true` 启用调试日志。
 - key_range 表数据分布不均匀：检查分区参数是否与建表时一致。

## 详细文档索引

以下文档位于项目仓库的 `docs/` 目录中，提供更深入的性能测试使用指南：

| 文档 | 说明 | 链接 |
| --- | --- | --- |
| 快速入门 | 5 分钟跑通第一次测试 | [getting-started.md](https://github.com/oceanbase/YCSB/blob/obkv/docs/getting-started.md) |
| Web UI 使用指南 | 图形界面完整操作说明 | [guide-webui.md](https://github.com/oceanbase/YCSB/blob/obkv/docs/guide-webui.md) |
| 命令行使用指南 | 黑屏方式完整操作说明 | [guide-cli.md](https://github.com/oceanbase/YCSB/blob/obkv/docs/guide-cli.md) |
| 参数配置大全 | 所有参数的含义、类型、默认值 | [params-reference.md](https://github.com/oceanbase/YCSB/blob/obkv/docs/params-reference.md) |
| Workload 参考 | Workload 文件模板与示例 | [workload-reference.md](https://github.com/oceanbase/YCSB/blob/obkv/docs/workload-reference.md) |
| OBKV-HBase 模块详解 | 表模型、测试模式、分区策略 | [module-obkv-hbase.md](https://github.com/oceanbase/YCSB/blob/obkv/docs/module-obkv-hbase.md) |
| Web UI 架构设计 | 架构、SSE、资源隔离 | [webui-architecture.md](https://github.com/oceanbase/YCSB/blob/obkv/docs/webui-architecture.md) |
| Web UI API 参考 | REST API 完整文档 | [webui-api-reference.md](https://github.com/oceanbase/YCSB/blob/obkv/docs/webui-api-reference.md) |
| 常见问题 | FAQ 汇总 | [faq.md](https://github.com/oceanbase/YCSB/blob/obkv/docs/faq.md) |

 上一篇 下一篇 ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
