13.3. 创建新索引到现有数据库


了解如何在 Directory Server 上启动索引操作。您必须手动创建索引,因为 Directory 服务器不会自动索引数据库。
重要
在重新生成索引前,搜索继续,但可能会返回不正确的或不一致的结果。

13.3.1. 创建索引,但实例正在运行

在实例运行时重新创建数据库的索引:
# dsconf -D "cn=Directory Manager" ldap://server.example.com backend index reindex database_name
Copy to Clipboard Toggle word wrap

13.3.1.2. 使用 cn=tasks Entry 创建索引

Directory Server 配置中的 cn=tasks,cn=config 条目是服务器用来管理任务的临时条目的容器条目。要启动索引操作,请在 cn=index,cn=tasks,cn=config 条目中创建一个任务。
使用 ldapadd 工具来添加新的索引任务。例如,添加一个任务,该任务在 userRoot 数据库中为 cn 属性创建 presence 索引:
# ldapadd -D "cn=Directory Manager" -W -p 389 -h server.example.com -x

dn: cn=example_presence_index,cn=index,cn=tasks,cn=config
objectclass: top
objectclass: extensibleObject
cn: example presence index
nsInstance: userRoot
nsIndexAttribute: "cn:pres"
Copy to Clipboard Toggle word wrap
任务完成后,该条目会从目录配置中删除。
有关 cn=index,cn=tasks,cn=config 条目的详情,请查看 Red Hat Directory Server 配置、命令和文件参考 中的 cn=index 部分

13.3.2. 创建索引,其中包含实例离线

创建索引条目或在现有索引条目中添加额外的索引类型后,请使用 dsconf db2index 命令:
  1. 关闭实例:
    # dsctl instance_name stop
    Copy to Clipboard Toggle word wrap
  2. 重新创建索引:
    1. 对于数据库中的所有索引,请运行:
      # dsctl instance_name db2index userRoot
      [13/Aug/2019:15:25:37.277426483 +0200] - INFO - ldbm_instance_config_cachememsize_set - force a minimal value 512000
      [13/Aug/2019:15:25:37.289257996 +0200] - INFO - check_and_set_import_cache - pagesize: 4096, available bytes 1704378368, process usage 22212608 
      [13/Aug/2019:15:25:37.291738104 +0200] - INFO - check_and_set_import_cache - Import allocates 665772KB import cache.
      ...
      db2index successful
      Copy to Clipboard Toggle word wrap
    2. 对于特定属性索引,请运行:
      # dsctl instance_name db2index userRoot --attr aci cn givenname
      Copy to Clipboard Toggle word wrap
      以下命令为 acicngivenname 属性重新创建索引。请注意,如果没有指定数据库,命令会为所有属性重新创建索引。
  3. 启动实例:
    # dsctl instance_name start
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat