第 7 章 每个搜索操作日志记录统计信息

在一些搜索操作中,特别是带有 (cn=user*) 等过滤器,服务器用于接收任务的时间,然后发送结果返回(etime)可能会非常长。

使用搜索操作中使用的索引信息扩展访问日志有助于诊断为什么 etime 值的资源代价。

使用 nsslapd-statlog-level 属性启用收集统计信息,如多个索引查找(数据库读取操作)和每个搜索操作的索引查找的整体持续时间,对服务器的影响最少。

先决条件

  • 启用了访问日志记录。

流程

  1. 启用搜索操作指标:

    # dsconf -D "cn=Directory Manager" ldap://server.example.com config replace nsslapd-statlog-level=1
  2. 重启实例:

    # dsctl instance_name restart

验证

  1. 执行搜索操作:

    # ldapsearch -D "cn=Directory Manager" -H ldap://server.example.com -b "dc=example,dc=com" -s sub -x "cn=user*"
  2. 查看访问日志文件并找到搜索统计记录:

    # cat /var/log/dirsrv/slapd-instance_name/access
    ...
    [16/Nov/2022:11:34:11.834135997 +0100] conn=1 op=73 SRCH base="dc=example,dc=com" scope=2 filter="(cn=user)"* attrs=ALL
    [16/Nov/2022:11:34:11.835750508 +0100] conn=1 op=73 STAT read index: attribute=objectclass key(eq)=referral --> count 0
    [16/Nov/2022:11:34:11.836648697 +0100] conn=1 op=73 STAT read index: attribute=cn key(sub)=er_ --> count 25
    [16/Nov/2022:11:34:11.837538489 +0100] conn=1 op=73 STAT read index: attribute=cn key(sub)=ser --> count 25
    [16/Nov/2022:11:34:11.838814948 +0100] conn=1 op=73 STAT read index: attribute=cn key(sub)=use --> count 25
    [16/Nov/2022:11:34:11.841241531 +0100] conn=1 op=73 STAT read index: attribute=cn key(sub)=^us --> count 25
    [16/Nov/2022:11:34:11.842230318 +0100] conn=1 op=73 STAT read index: duration 0.000010276
    [16/Nov/2022:11:34:11.843185322 +0100] conn=1 op=73 RESULT err=0 tag=101 nentries=24 wtime=0.000078414 optime=0.001614101 etime=0.001690742
    ...

其他资源

  • TBA 链接到 nsslapd-statlog-level 描述