Wren:DS 5.1.1 常用 CLI 命令与工具详解

Wren:DS 5.1.1 命令行工具族全解:服务启停、LDAP 数据操作、口令编码、配置与任务管理、备份恢复、索引与数据库诊断、LDIF 处理、压测与复制,全部命令与回显均为实测记录。

Wren:DS目录服务LDAP身份认证Java2026/11/02

Wren:DS 5.1.1 常用 CLI 命令与工具详解

目标:把 Wren:DS 5.1.1 自带的命令行工具按用途分类讲透——服务启停、LDAP 数据操作、口令处理、配置与任务管理、备份恢复、索引与数据库诊断、LDIF 文件处理、压测、复制——每个高频命令给出语法、关键参数与本机实测回显。全文命令与输出均为 2026-11-02 在测试服务器 wrends01(已按 《Ubuntu 22.04 安装 Wren:DS 5.1.1 指南》 完成安装,配置面见 《Wren:DS 5.1.1 配置参数详解》)上的实测记录。

一、环境信息

项目值
主机名wrends01(Ubuntu 22.04.5 LTS)
Wren:DS5.1.1(Build 2026-05-22T13:11:32Z)
JDKOpenJDK 17.0.20.1(export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64)
安装目录/opt/wren-ds,全部工具在 bin/
LDAP 端口1389(明文)
LDAPS 端口1636(本机 TLS 传输层缺陷,见注意事项)
管理连接器端口4444(dsconfig/status/manage-tasks 等依赖)
根 DN / 口令cn=Directory Manager / q1w2e3r4
业务后缀dc=example,dc=com(实测 4 条数据条目)

二、工具概览

bin/ 目录实测清单(33 个条目,含 2 个 GUI 应用入口):

root@wrends01:~# ls /opt/wren-ds/bin/ | tr '\n' ' '
ControlPanel.app addrate authrate backendstat backup base64 control-panel create-rc-script dsconfig dsreplication encode-password export-ldif import-ldif ldapcompare ldapdelete ldapmodify ldappasswordmodify ldapsearch ldifdiff ldifmodify ldifsearch list-backends makeldif manage-account manage-tasks modrate rebuild-index restore searchrate start-ds status stop-ds verify-index

按用途分类如下,连接方式差异是选型关键:

类别工具连哪里本机实测可用性
服务启停start-ds / stop-ds / status / create-rc-script本地脚本 / status 走 4444启停可用;status 受 TLS 缺陷影响不可用
LDAP 数据操作ldapsearch / ldapmodify / ldapdelete / ldapcompare / ldappasswordmodify1389 明文全部可用
口令与编码encode-password / base64纯本地全部可用
配置与任务dsconfig / manage-tasks / manage-account / dsreplication4444 SSLmanage-tasks 可用;其余受 TLS 缺陷间歇影响
备份恢复与导入导出backup / restore / export-ldif / import-ldif在线走 4444,离线直读 db/离线全部可用;在线备份服务端成功但工具端误报
索引与数据库诊断verify-index / rebuild-index / backendstat / list-backends离线直读 db/(rebuild-index 在线需 4444)离线全部可用
LDIF 文件处理makeldif / ldifsearch / ldifmodify / ldifdiff纯本地文件全部可用
压测searchrate / addrate / authrate / modrate1389 明文searchrate 可用

⚠️ 与 OpenLDAP 客户端的差异:Wren:DS 自带客户端没有 ldapwhoami(实测 ./bin/ldapwhoami 报 No such file or directory),bind 连通性验证请用 ldapsearch -s base 或 ldappasswordmodify。参数风格也不同:-p 是端口(OpenLDAP 里 -p 是密码),口令用 -w。

三、前置条件

  • Wren:DS 已安装且服务在跑(在线类命令);离线类命令要求服务已停止。
  • 所有命令在 /opt/wren-ds 下以 ./bin/<工具> 执行,并保证 JAVA_HOME 已导出。
  • 在线命令统一凭据:-D 'cn=Directory Manager' -w q1w2e3r4。
  • 走 4444 的工具首次连接会弹证书信任菜单(1) No 2) Yes, for this session only 3) Yes, also add it to a truststore 4) View certificate details),非交互场景用 echo 2 | 喂选项,或加 -X(信任所有证书,仅限测试)。

四、服务启停与状态检查

4.1 start-ds

启动服务并前台输出启动日志(详细回显见 《Ubuntu 22.04 安装 Wren:DS 5.1.1 指南》 第六章)。查版本:

root@wrends01:/opt/wren-ds# ./bin/start-ds --version
Wren:DS Server 5.1.1
Build 2026-05-22T13:11:32Z

停机后重启的实测尾部回显:

root@wrends01:/opt/wren-ds# ./bin/start-ds
[02/Nov/2026:14:27:30 +0000] category=PROTOCOL severity=NOTICE msgID=276 msg=Started listening for new connections on LDAP Connection Handler 0.0.0.0 port 1389
[02/Nov/2026:14:27:30 +0000] category=CORE severity=NOTICE msgID=135 msg=The Directory Server has started successfully

4.2 stop-ds

root@wrends01:/opt/wren-ds# ./bin/stop-ds
Stopping Server...
[02/Nov/2026:14:26:25 +0000] category=BACKEND severity=NOTICE msgID=370 msg=The backend userRoot is now taken offline
[02/Nov/2026:14:26:25 +0000] category=CORE severity=NOTICE msgID=203 msg=The Directory Server is now stopped

stop-ds 干净退出后进程消失,可用 ps -ef | grep '[D]irectoryServer' 复核(返回 0 行)。

4.3 status

status 经管理连接器(4444)查询实例状态,本机实测不可用:

root@wrends01:/opt/wren-ds# ./bin/status -D 'cn=Directory Manager' -w q1w2e3r4
Unable to connect to the server at "wrends01" on port 4444

替代判活手段(实测有效):

root@wrends01:/opt/wren-ds# ./bin/ldapsearch -p 1389 -D 'cn=Directory Manager' -w q1w2e3r4 \
  -b 'dc=example,dc=com' -s base '(objectClass=*)' dn
dn: dc=example,dc=com

或看 logs/errors 的 The Directory Server has started successfully 与 logs/server.pid 对得上 ps。

4.4 create-rc-script

生成系统级启停脚本(-f 输出路径、-j JAVA_HOME、-u 运行用户),生成物内容与使用建议在 《Ubuntu 22.04 安装 Wren:DS 5.1.1 指南》 第八章已实测记录,此处不重复。

五、LDAP 数据操作命令

5.1 ldapsearch

基础语法:ldapsearch -p <端口> -D <bindDN> -w <口令> -b <baseDN> <过滤器> [属性...]。

列全库条目 DN:

root@wrends01:/opt/wren-ds# ./bin/ldapsearch -p 1389 -D 'cn=Directory Manager' -w q1w2e3r4 \
  -b 'dc=example,dc=com' '(objectClass=*)' dn
dn: dc=example,dc=com
dn: ou=People,dc=example,dc=com
dn: uid=alice,ou=People,dc=example,dc=com
dn: uid=bob,ou=People,dc=example,dc=com

读 cn=config 配置树(在线配置查看的底层通道,见 《Wren:DS 5.1.1 配置参数详解》 3.2 节):

root@wrends01:/opt/wren-ds# ./bin/ldapsearch -p 1389 -D 'cn=Directory Manager' -w q1w2e3r4 \
  -b 'cn=config' -s base '(objectClass=ds-cfg-root-config)' ds-cfg-size-limit ds-cfg-lookthrough-limit
dn: cn=config
ds-cfg-size-limit: 1000
ds-cfg-lookthrough-limit: 5000

常用参数实测要点:-s base/one/sub 控范围;属性列表放在过滤器之后;-q/--useStartTLS 走 StartTLS(本机 TLS 缺陷实测报 SSL handshake failed,见注意事项);-z/--sizeLimit 控返回条数(实测帮助);-j 指定口令文件避免口令进 shell 历史。

5.2 ldapmodify

增删改一条命令全包:LDIF 里 changetype: add/modify/delete。

新增条目触发口令策略被拒(constraint violation 实录):

root@wrends01:/opt/wren-ds# printf 'dn: uid=carol,ou=people,dc=example,dc=com\nchangetype: add\nobjectClass: top\nobjectClass: person\nobjectClass: organizationalPerson\nobjectClass: inetOrgPerson\nuid: carol\ncn: Carol\nsn: Zhou\nuserPassword: abc\n' > /tmp/carol.ldif
root@wrends01:/opt/wren-ds# ./bin/ldapmodify -p 1389 -D 'cn=Directory Manager' -w q1w2e3r4 -f /tmp/carol.ldif
Processing ADD request for uid=carol,ou=people,dc=example,dc=com
The LDAP modify request failed: 19 (Constraint Violation)
Additional Information:  The password value for attribute userPassword was
found to be unacceptable: The provided password is shorter than the minimum
required length of 6 characters

改口令为合规值后修改成功:

root@wrends01:/opt/wren-ds# sed -i 's/userPassword: abc/userPassword: Zq9w8e7r3t5y/' /tmp/carol.ldif
root@wrends01:/opt/wren-ds# printf 'dn: uid=bob,ou=people,dc=example,dc=com\nchangetype: modify\nreplace: userPassword\nuserPassword: q1w2e3r4\n' > /tmp/bob2.ldif
root@wrends01:/opt/wren-ds# ./bin/ldapmodify -p 1389 -D 'cn=Directory Manager' -w q1w2e3r4 -f /tmp/bob2.ldif
Processing MODIFY request for uid=bob,ou=people,dc=example,dc=com
MODIFY operation successful for DN uid=bob,ou=people,dc=example,dc=com

重复 ADD 的报错(幂等性检查用):

The LDAP modify request failed: 68 (Entry Already Exists)
Additional Information:  The entry uid=bob,ou=people,dc=example,dc=com cannot
be added because an entry with that name already exists

5.3 ldapdelete

root@wrends01:/opt/wren-ds# ./bin/ldapdelete -p 1389 -D 'cn=Directory Manager' -w q1w2e3r4 \
  'uid=carol,ou=people,dc=example,dc=com'
Processing DELETE request for uid=carol,ou=people,dc=example,dc=com
DELETE operation successful for DN uid=carol,ou=people,dc=example,dc=com

删除后搜索验证为空(实测 ldapsearch '(uid=carol)' 无返回条目)。DN 可走 stdin 批量删除,以 EOF 结束。

5.4 ldapcompare

语法特殊:ldapcompare {options} attribute:value DN。

root@wrends01:/opt/wren-ds# ./bin/ldapcompare -p 1389 -D 'cn=Directory Manager' -w q1w2e3r4 \
  'sn:Li' 'uid=bob,ou=People,dc=example,dc=com'
Comparing type sn with value Li in entry uid=bob,ou=People,dc=example,dc=com
Compare operation returned true for entry uid=bob,ou=People,dc=example,dc=com

典型用途:脚本里校验口令(userPassword:<明文>)或属性值而无需读回密文,配合 -r(用 LDAP compare 结果码作退出码)可直接当断言用。

5.5 ldappasswordmodify

改用户口令走 RFC 3062 扩展操作。参数陷阱实测:新口令是 -n(小写),-N 是证书昵称——第一次误用 -N 时服务端自动生成了随机口令并回显:

root@wrends01:/opt/wren-ds# ./bin/ldappasswordmodify -p 1389 -D 'uid=carol,ou=people,dc=example,dc=com' \
  -w Zq9w8e7r3t5y -N CarolNew2026pwd -a 'u:carol'
The LDAP password modify operation was successful
Generated Password:  lgx74mkn

用户随即被踢出(旧口令失效、新口令是随机值)。用正确参数改回:

root@wrends01:/opt/wren-ds# ./bin/ldappasswordmodify -p 1389 -D 'uid=carol,ou=people,dc=example,dc=com' \
  -w lgx74mkn -n CarolNew2026pwd -a 'u:carol'
The LDAP password modify operation was successful

要点:-a 'u:<uid>' 或 -a 'dn:<完整DN>' 指定目标用户;-c 当前口令、-n 新口令、-C/-F 对应口令文件;不给 -n 就触发随机口令(配合密码策略的生成器,见 《Wren:DS 5.1.1 配置参数详解》 5.4 节)。

六、口令与编码工具

6.1 encode-password

离线生成任意存储方案的密文(写 LDIF 预编码口令、比对校验都用它):

root@wrends01:/opt/wren-ds# ./bin/encode-password -c q1w2e3r4 -s SSHA512
Encoded Password:  "{SSHA512}6DgWD9xo5TTpNLC780ceLeHbYFawrXcGuLJi1AcJZ1kh3DhQBV9ldeH4EtksV5ZWHHMI/BUxex+Au/Jc9bxTPewM5IwcIpM2"

-l 列出全部 17 种方案;-e {编码值} -c {明文} 做匹配校验;-r 用比较结果码作退出码。方案对比与选型见 《Wren:DS 5.1.1 配置参数详解》 5.4 节技术拓展。

6.2 base64

root@wrends01:/opt/wren-ds# echo -n 'q1w2e3r4' | ./bin/base64 encode
cTF3MmUzcjQ=

子命令 encode/decode,处理 LDIF 里 Base64 属性值(如 objectGUID 类二进制属性)的辅助工具。

七、配置与任务管理

7.1 dsconfig

官方配置工具,走管理连接器 4444。子命令按域分 --help-core-server/--help-database/--help-logging/--help-replication/--help-security/--help-all 列目录(create-/delete-/get-/set-/list- 五式 × 组件类型)。首次连接弹证书信任菜单:

root@wrends01:/opt/wren-ds# ./bin/dsconfig list-backends -h 127.0.0.1 -p 4444 \
  -D 'cn=Directory Manager' -w q1w2e3r4
Server Certificate:

User DN  : O=Administration Connector RSA Self-Signed Certificate, CN=wrends01
Validity : From 'Mon Nov 02 12:40:30 GMT 2026'
             To 'Sun Oct 28 12:40:30 GMT 2046'
Issuer   : O=Administration Connector RSA Self-Signed Certificate, CN=wrends01



Do you trust this server certificate?

  1) No
  2) Yes, for this session only
  3) Yes, also add it to a truststore
  4) View certificate details

Enter choice: [2]:

喂 echo 2 | 后会话仍被掐断(TLS 传输层缺陷):

The Backends could not be listed due to a communications problem: Server
Connection Closed

加 -X 跳过信任菜单则直接报 Unable to connect to the server at "127.0.0.1" on port 4444。本机结论:dsconfig 不可用,在线配置一律用 ldapmodify 改 cn=config(实测通道与完整用法见 《Wren:DS 5.1.1 配置参数详解》 3.2 节),dsconfig 语法留作上游修复后的参考。

7.2 manage-tasks

查看/取消经 cn=tasks 提交的服务器端任务,同样走 4444,但本机实测可用(TLS 缺陷是间歇性的,此连接幸存):

root@wrends01:/opt/wren-ds# echo 2 | ./bin/manage-tasks -h 127.0.0.1 -p 4444 \
  -D 'cn=Directory Manager' -w q1w2e3r4 -n
  ID                 Type    Status
  -------------------------------------------------
  20261102142331638  Backup  Completed successfully

参数:-s 摘要、-i <taskID> 单任务详情、-c <taskID> 取消。上表的 Backup 任务正是 8.1 节 backup 命令提交的——工具端报错时以 manage-tasks/errors 日志的任务状态为准。

7.3 manage-account

读写口令策略状态变量(锁定、过期、失败次数等)。子命令实测清单(--help):get-all、get-account-is-disabled、set-account-is-disabled、clear-account-is-disabled、get-account-expiration-time、get-authentication-failure-times、get-grace-login-use-times、get-last-login-time、get-password-history、get-seconds-until-* 等。目标用户参数是 -b/--targetDN(不是 --userDN,实测传 --userDN 报 not a valid global argument identifier):

root@wrends01:/opt/wren-ds# ./bin/manage-account get-all -X -h 127.0.0.1 -p 4444 \
  -D 'cn=Directory Manager' -w q1w2e3r4 -b 'uid=alice,ou=People,dc=example,dc=com'
The Directory Server closed the connection before the response could be read

本机受 TLS 缺陷影响不可用;策略状态也可用 ldapsearch 读用户条目的 ds-pwp-* 运营属性替代(明文端口可用)。

八、备份、恢复与导入导出

8.1 backup

在线备份(经 4444 提交 BackupTask)。全量备份所有后端:

root@wrends01:/opt/wren-ds# ./bin/backup -h 127.0.0.1 -p 4444 -D 'cn=Directory Manager' \
  -w q1w2e3r4 -a --backupDirectory /opt/wren-ds/backups

工具端回显(注意:这是误报):

ERROR:  The server rejected the task for the following reason: NOTICE:  The
connection to the Directory Server was closed while waiting for a response to
the shutdown request.  This likely means that the server has started the
shutdown process

但服务端三处证据表明备份实际成功:

root@wrends01:/opt/wren-ds# find backups -maxdepth 2
backups
backups/schema
backups/schema/backup.info
backups/schema/backup-schema-20261102142331Z
backups/userRoot
backups/userRoot/backup.info
backups/userRoot/backup-userRoot-20261102142331Z
backups/tasks
backups/tasks/backup.info
backups/tasks/backup-tasks-20261102142331Z
root@wrends01:/opt/wren-ds# grep 'Backup task' logs/errors | tail -1
[02/Nov/2026:14:23:31 +0000] category=BACKEND severity=NOTICE msgID=414 msg=Backup task 20261102142331638 finished execution in the state Completed successfully

backup.info 元数据实测:

backend_dn=ds-cfg-backend-id=userRoot,cn=Backends,cn=config

backup_id=20261102142331Z
backup_date=20261102142331Z
incremental=false
compressed=false
encrypted=false
property.archive_file=backup-userRoot-20261102142331Z
property.last_logfile_size=73995
property.last_logfile_name=00000000.jdb

要点:-a 全后端、--backendID <id> 单后端、--backupDirectory 必填(不给直接报 The argument backupDirectory is required);工具退出码 1 不代表备份失败,必须按上面三处证据复核;同一命令重跑可能真失败(本机第二次跑未产出新文件),本质是 TLS 缺陷掐断任务结果通道导致的竞态,生产定时备份建议以「备份目录新文件 + errors 日志」做成功判据。

8.2 restore

恢复与备份清单查看。列备份(离线模式,--backupDirectory 要指到后端子目录,指顶层会报缺 descriptor):

root@wrends01:/opt/wren-ds# ./bin/restore --offline --listBackups --backupDirectory /opt/wren-ds/backups/userRoot
Is Encrypted:       false
Has Unsigned Hash:  false
Has Signed Hash:    false
Dependent Upon:     none

(回显节选:每个备份一条记录,尾部为上述属性行。)

恢复本身要求停机(stop-ds 后执行):restore --offline --backendId userRoot --backupDirectory /opt/wren-ds/backups。恢复后数据与备份时点一致,验证方式见 8.4 导入后的复核命令。

8.3 export-ldif

离线导出(停机执行):

root@wrends01:/opt/wren-ds# ./bin/export-ldif --offline --backendId userRoot --ldifFile /tmp/export.ldif
[02/11/2026:14:26:40 +0000] category=BACKEND seq=36 severity=INFO msg=Exported 5 entries and skipped 0 in 0 seconds (average rate 1666.7/sec)

在线导出(经 4444 提交 ExportTask)本机实测失败:

You have provided options for scheduling this operation as a task but options
provided for connecting to the server's tasks backend resulted in the
following error: 'Cannot send the simple bind request:
SSLHandshakeException(Remote host terminated the handshake)'

把 -p 指到明文 1389 更直接报 Unsupported or unrecognized SSL message——在线任务模式只认 4444,且受 TLS 缺陷影响。结论:导出用离线模式。

8.4 import-ldif

离线全量导入(覆盖后端现有数据,不能追加——help 原文 It cannot be used to append data to the backend database):

root@wrends01:/opt/wren-ds# ./bin/import-ldif --offline --backendId userRoot --ldifFile /tmp/export.ldif
[02/11/2026:14:27:20 +0000] category=BACKEND seq=121 severity=INFO msg=Total import time was 0 seconds. Phase one processing completed in 0 seconds, phase two processing completed in 0 seconds
[02/11/2026:14:27:20 +0000] category=BACKEND seq=122 severity=INFO msg=Processed 5 entries, imported 5, skipped 0, rejected 0 and migrated 0 in 0 seconds (average rate 17.4/sec)
[02/11/2026:14:27:20 +0000] category=BACKEND seq=123 severity=INFO msg=Import LDIF environment close took 0 seconds
[02/11/2026:14:27:20 +0000] category=BACKEND seq=124 severity=INFO msg=Flushing data to disk

导入后启动并复核(实测闭环):

root@wrends01:/opt/wren-ds# ./bin/start-ds
root@wrends01:/opt/wren-ds# ./bin/ldapsearch -p 1389 -D 'cn=Directory Manager' -w q1w2e3r4 \
  -b 'dc=example,dc=com' '(objectClass=inetOrgPerson)' uid
uid: alice
uid: bob
uid: carol

要点:--excludeBaseDNs/--includeFilter 可裁剪导入范围;导入自动重建全部索引(两阶段 phase one/phase two),所以导入后不必再 rebuild-index。

九、索引与数据库诊断

9.1 verify-index

校验索引与数据一致性,只有离线形态(实测传 --offline 反而报 Argument --offline is not allowed,即默认直读数据库):

root@wrends01:/opt/wren-ds# ./bin/verify-index -b 'dc=example,dc=com' --index uid
[02/11/2026:14:26:32 +0000] category=BACKEND seq=36 severity=INFO msg=Checked 5 entries and found 0 error(s) in 0 seconds (average rate 714.3/sec)

服务运行时执行会报 EnvironmentLockedException ... ENV_LOCKED: The je.lck file could not be locked(实录见 《Ubuntu 22.04 安装 Wren:DS 5.1.1 指南》 排障 11.3),必须先 stop-ds。不带 --index 则校验全部索引。

9.2 rebuild-index

离线重建索引(停机执行):

root@wrends01:/opt/wren-ds# ./bin/rebuild-index --offline -b 'dc=example,dc=com' --index uid
[02/11/2026:14:27:08 +0000] category=BACKEND seq=40 severity=INFO msg=Setting DB cache size to 33554432 bytes and phase one buffer size to 226793631 bytes
[02/11/2026:14:27:09 +0000] category=BACKEND seq=43 severity=INFO msg=Index /dc=com,dc=example/uid.caseIgnoreMatch phase two started processing 1 buffers in 1 batches
[02/11/2026:14:27:09 +0000] category=BACKEND seq=44 severity=INFO msg=Index /dc=com,dc=example/uid.caseIgnoreMatch phase two processing completed
[02/11/2026:14:27:09 +0000] category=BACKEND seq=47 severity=INFO msg=Rebuild complete. Processed 5 entries in 0 seconds (average rate 20.6/sec)

在线模式(不带 --offline,经 4444 提交 RebuildTask)本机实测在无人值守环境失败:

"java.lang.System.console()" is null
You have provided options for scheduling this operation as a task but options
provided for connecting to the server's tasks backend resulted in the
following error: 'Connect Error'

结论与 8.3 相同:索引重建用离线模式。

9.3 backendstat

直读 JE 数据库的调试工具(停机执行),子命令:dump-index、dump-raw-db、list-backends、list-base-dns、list-indexes、list-raw-dbs。

列索引与记录数:

root@wrends01:/opt/wren-ds# ./bin/backendstat list-indexes -n userRoot -b 'dc=example,dc=com'
Index Name                                        Raw DB Name                                                          Type               Record Count
------------------------------------------------------------------------------------------------------------------------------------------------------
dn2id                                             /dc=com,dc=example/dn2id                                             DN2ID              5
id2entry                                          /dc=com,dc=example/id2entry                                          ID2Entry           5
referral                                          /dc=com,dc=example/referral                                          DN2URI             0
id2childrencount                                  /dc=com,dc=example/id2childrencount                                  ID2ChildrenCount   9
state                                             /dc=com,dc=example/state                                             State              18
mail.caseIgnoreIA5SubstringsMatch:6               /dc=com,dc=example/mail.caseIgnoreIA5SubstringsMatch:6               MatchingRuleIndex  26
mail.caseIgnoreIA5Match                           /dc=com,dc=example/mail.caseIgnoreIA5Match                           MatchingRuleIndex  2
givenName.caseIgnoreMatch                         /dc=com,dc=example/givenName.caseIgnoreMatch                         MatchingRuleIndex  1
entryUUID.uuidMatch                               /dc=com,dc=example/entryUUID.uuidMatch                               MatchingRuleIndex  5
sn.caseIgnoreMatch                                /dc=com,dc=example/sn.caseIgnoreMatch                                MatchingRuleIndex  3

注意索引名是「属性.匹配规则」形态:dump-index -i uid 会报 No index exists with the requested name 'uid',要用 -i uid.caseIgnoreMatch。

导出索引内容(尾部统计实测):

root@wrends01:/opt/wren-ds# ./bin/backendstat dump-index -n userRoot -b 'dc=example,dc=com' -i uid.caseIgnoreMatch
Value (len 2): [COUNT:1] 9

Total Records: 3
Total / Average Key Size: 13 bytes / 4 bytes
Total / Average Data Size: 6 bytes / 2 bytes

-q 只看统计不导数据。索引记录数异常(如 presence 索引 0 条)是排查「搜索慢/结果缺」的第一手证据。

9.4 list-backends

离线列出后端与 base DN 映射:

root@wrends01:/opt/wren-ds# ./bin/list-backends
Backend ID     : Base DN
---------------:--------------------
adminRoot      : cn=admin data
ads-truststore : cn=ads-truststore
backup         : cn=backups
monitor        : cn=monitor
schema         : cn=schema
tasks          : cn=tasks
userRoot       : "dc=example,dc=com"

不接受 -h/-p(实测报 Argument -h is not allowed for use with this program),纯本地读配置。与 9.3 的 backendstat list-backends 互补:这个列配置面,backendstat 列数据库层。

十、LDIF 文件处理工具

10.1 makeldif

按模板批量造数据(压测前灌数据标配)。发行包自带模板在 config/MakeLDIF/(实测清单:example.template、people_and_groups.template、addrate.template 及 cities/first.names/last.names 等数据文件):

root@wrends01:/opt/wren-ds# ./bin/makeldif -s 1 -o /tmp/gen.ldif config/MakeLDIF/example.template
Processed 8000 entries
Processed 9000 entries
Processed 10000 entries
LDIF processing complete. 10002 entries written

产物头部实测:

dn: dc=example,dc=com
dc: example
objectClass: top
objectClass: domain

dn: ou=People,dc=example,dc=com
ou: People
objectClass: top
objectClass: organizationalUnit

dn: uid=user.0,ou=People,dc=example,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson

要点:-s <seed> 保证随机可复现;-c name=value 覆盖模板常量;-o 输出文件。自写模板需要 <macro-definition>/<entry> 块语法,直接拿 LDIF 当模板会报 Unexpected template line(实测踩坑),建议从 example.template 抄改。

10.2 ldifsearch

对 LDIF 文件做 LDAP 过滤器搜索(不连服务器):

root@wrends01:/opt/wren-ds# ./bin/ldifsearch /tmp/gen.ldif '(uid=user.1*)' uid
dn: uid=user.1,ou=People,dc=example,dc=com
uid: user.1

dn: uid=user.10,ou=People,dc=example,dc=com
uid: user.10

dn: uid=user.11,ou=People,dc=example,dc=com
uid: user.11

dn: uid=user.12,ou=People,dc=example,dc=com

用途:导入前抽查数据、核对过滤器命中集。

10.3 ldifmodify

把变更 LDIF 应用到文件 LDIF(离线转换,-o 必须放在文件参数之前,放后面会被当成第二个源文件报错,实测踩坑):

root@wrends01:/opt/wren-ds# printf 'dn: uid=user.0,ou=People,dc=example,dc=com\nchangetype: modify\nreplace: description\ndescription: modified-by-ldifmodify\n' > /tmp/chg.ldif
root@wrends01:/opt/wren-ds# ./bin/ldifmodify -o /tmp/gen2.ldif /tmp/gen.ldif /tmp/chg.ldif
root@wrends01:/opt/wren-ds# grep -c 'modified-by-ldifmodify' /tmp/gen2.ldif
1

10.4 ldifdiff

比对两个 LDIF 输出差异变更(回滚脚本生成利器):

root@wrends01:/opt/wren-ds# ./bin/ldifdiff /tmp/gen.ldif /tmp/gen2.ldif
dn: uid=user.0,ou=People,dc=example,dc=com
changetype: modify
delete: description
description: This is the description for Aaccf Amar.
-
add: description
description: modified-by-ldifmodify
-

十一、压测工具

11.1 searchrate

搜索吞吐压测(实测 30 秒采样节选):

root@wrends01:/opt/wren-ds# ./bin/searchrate -p 1389 -D 'cn=Directory Manager' -w q1w2e3r4 \
  -b 'dc=example,dc=com' -f '(objectClass=inetOrgPerson)' -c 2 -r 10 -e 30
--------------------------------------------------------------------------------------------
|     Throughput    |                 Response Time                |       Additional      |
|    (ops/second)   |                (milliseconds)                |       Statistics      |
|   recent  average |   recent  average    99.9%   99.99%  99.999% |  err/sec Entries/Srch |
--------------------------------------------------------------------------------------------
|   1084.4   1084.4 |    0.513    0.510     6.16    10.55    10.55 |      0.0          3.0 |
|   1943.8   1513.9 |    0.280    0.363     5.01    10.49    10.55 |      0.0          3.0 |
|   2111.9   1713.2 |    0.258    0.320     4.23     9.76    10.55 |      0.0          3.0 |
|   1911.6   1762.8 |    0.283    0.310     4.05     7.96    10.55 |      0.0          3.0 |
|   2072.6   1824.7 |    0.263    0.299     3.57     7.47    10.55 |      0.0          3.0 |
|   2144.5   1878.0 |    0.254    0.291     3.29     6.52    10.55 |      0.0          3.0 |
|   1869.8   1876.8 |    0.286    0.290     3.26     6.42    10.55 |      0.0          3.0 |

参数:-c 并发连接、-r 目标速率(ops/s)、-e 采样秒数、-f 过滤器、-b 基 DN。256MB 堆 + 小库下平均约 1877 ops/s、99.9% 响应 3.3ms(仅本机参考值,不代表产品性能结论)。

11.2 addrate / modrate / authrate

同族工具:addrate 灌写吞吐、modrate 修改吞吐、authrate 绑定(认证)吞吐,参数风格与 searchrate 一致(-c/-r/-e/-b 等)。本机未逐一压测,用法参照 11.1;config/MakeLDIF/addrate.template 是配套造数模板。

十二、复制工具 dsreplication

子命令实测清单:enable(建立复制域)、initialize/initialize-all(全量同步到对端)、status(复制状态)、unconfigure(拆除)、promote-server/add-host/remove-host 等。所有子命令只连各节点的 4444 管理端口。

单节点试跑 status 的实测回显(交互式索要 truststore 路径):

root@wrends01:/opt/wren-ds# ./bin/dsreplication status -h 127.0.0.1 -p 4444
Truststore path: The connection parameters could not be read due to the following error: The
response could not be read from the console due to the following error: End of
input

结论:dsreplication 需要双节点 + truststore 参数(--trustStorePath/--trustStorePin)配合 4444 通道;本机 4444 TLS 缺陷下无法完成 enable/initialize 全流程,复制配置面结构见 《Wren:DS 5.1.1 配置参数详解》 5.7 节。

十三、注意事项

  1. TLS 缺陷影响面:5.1.1 + OpenJDK 17.0.20 上,所有走 TLS 的通道(1636 LDAPS、StartTLS -q、4444 管理连接器)都受间歇性传输层缺陷影响(logs/errors 实测 GRIZZLY0013 累计 29 条)。同一工具同一命令可能一次成功一次失败(manage-tasks 成功、dsconfig 失败即实证),脚本必须做失败重试并以服务端日志/产物为最终判据。明文 1389 上的数据操作命令不受影响。
  2. 在线任务类命令只认 4444:backup/export-ldif/rebuild-index 的在线模式经 cn=tasks 提交,把 -p 指到 1389 会报 Unsupported or unrecognized SSL message。
  3. 离线类命令要求停机:verify-index、rebuild-index --offline、import-ldif --offline、export-ldif --offline、backendstat、list-backends、restore --offline 都要先 stop-ds,否则争抢 je.lck 报 EnvironmentLockedException。
  4. 口令别进 shell 历史:在线命令用 -z/--bindPasswordFile(口令文件)替代 -w;setup 用 --rootUserPasswordFile。
  5. control-panel 需要图形环境:control-panel/ControlPanel.app 是 GUI 管理工具,服务器无 X 环境不可用(未实测),管理场景走 CLI + cn=config。
  6. DN 大小写不敏感但索引区分:ou=people 与 ou=People 指向同一条目(ldapdelete 实测成功),但 backendstat 的索引名必须精确到匹配规则(9.3)。

十四、常见问题

  1. ldapwhoami 不存在? Wren:DS 客户端集不含它(实测),用 ldapsearch -s base 验证 bind。
  2. dsconfig 报 Server Connection Closed? TLS 缺陷,改走 ldapmodify cn=config(见 7.1 与配置篇 3.2)。
  3. backup 退出码 1 就是备份失败? 不是。以 backups/<backend>/backup-* 新文件、backup.info、errors 日志 Completed successfully、manage-tasks 任务状态四处证据为准(8.1 实测)。
  4. --backupDirectory 指顶层报缺 descriptor? restore 的 --listBackups 要指后端子目录(如 backups/userRoot),8.2 实测。
  5. ldifmodify 把 -o 当文件名? -o 必须放在源文件参数之前(10.3 实测)。
  6. makeldif 报 Unexpected template line? 模板需要宏/条目块语法,从 config/MakeLDIF/example.template 抄改(10.1 实测)。
  7. verify-index 在线跑报 ENV_LOCKED? 停机执行(见 9.1 与 《Ubuntu 22.04 安装 Wren:DS 5.1.1 指南》 排障 11.3 实录)。

十五、参考链接

Wren:DS 5.1.1 常用 CLI 命令与工具详解 - Quzuo