排查 OpenLDAP 问题

<ph type="x-smartling-placeholder"></ph> 您正在查看 Apigee Edge 文档。
转到 Apigee X 文档
信息

本节提供关于排查 OpenLDAP 问题的信息和指南。

SMTP 已停用,用户需要重置 密码

问题

如果未在 Edge 界面中设置 SMTP,则添加到 Edge 的新用户需要通过某种方式来设置 密码。

错误消息

Unknown username and password combination.

可能的原因

新用户无法通过“忘记了密码?”选项用于设置的链接 因为未设置 SMTP。

分辨率

您可以通过以下某种方式来解决此问题:

解决方案 1: 配置 SMTP 服务器

配置 SMTP 服务器,以便按照所提供的说明为用户设置新密码 详情请参阅文档

解决方案 2:使用 LDAP

如果您无法配置 SMTP 服务器,请使用以下 LDAP 命令设置 用户的新密码:

  1. 现有组织管理员需要通过 Edge 界面添加特定用户,如下所示:

  2. 使用 ldapsearch 命令查找用户的标识名 (dn) 并将输出重定向到文件:
    ldapsearch -w Secret123 -D "cn=manager,dc=apigee,dc=com" -b "dc=apigee,dc=com" -LLL -h localhost -p 10389 > ldap.txt
    

    以下是用户的 dn 条目及属性的示例:

    dn:uid=f7a4a4a5-7c43-4168-a47e-6e9a1417cc29,ou=users,ou=global,dc=apigee,dc=com
    mail: apigee_validator@apigee.com
    userPassword:: e1NTSEF9b0FrMFFXVmFjbWRxM1BVaFZzMnllWGZMdkNvNjMwNTJlUDZYN3c9PQ=
     =
    uid: f7a4a4a5-7c43-4168-a47e-6e9a1417cc29
    objectClass: inetOrgPerson
    sn: Validator
    cn: apigee
    
  3. 打开 ldap.txt 文件,然后找到已添加的新用户的 dn 根据新用户的电子邮件地址属性确定。
  4. 执行 ldappassword 命令,为新用户添加密码 使用其 dn.在此示例中,您将用户密码设置为 Apigee123:
    ldappasswd -h localhost -p 10389 -D "cn=manager,dc=apigee,dc=com" -W -s Apigee123
    "uid=f7a4a4a5-7c43-4168-a47e-6e9a1417cc29,ou=users,ou=global,dc=apigee,dc=com"
    
  5. 使用上一步中定义的密码以新用户身份登录 Edge 界面。通过 用户可以在登录界面后设置新密码。

LDAP 未复制

问题

许多 Edge 设备都有多个数据中心,例如 DC-1 和 DC-2。记录时 作为组织管理员访问 DC-1 的 Edge 界面,您可以查看用户列表,但是用户列表 未显示在 DC-2 的 Edge 界面中。

错误消息

没有显示任何错误,Edge 界面只是不显示应该访问 复制到所有 OpenLDAP 服务器中。

可能的原因

此问题的原因通常是 OpenLDAP 复制配置配置错误, 安装本身此外,如果在 OpenLDAP 服务器之间连接网络,复制操作可能会中断 不允许通过端口 10389 传输流量。

诊断

请按照以下步骤诊断问题:

  1. 检查 ldapsearch 是否从各个 OpenLDAP 服务器返回数据:
    ldapsearch -W -D "cn=manager,dc=apigee,dc=com" -b "dc=apigee,dc=com" -LLL -h <host-ip> -p 10389
    
  2. 检查您是否可以通过端口 10389 从其他 OpenLDAP 节点连接到每个 OpenLDAP 节点。 如果已安装 telnet,请使用以下命令:
    telnet <OpenLDAP_Peer_IP> 10389
    
  3. 如果 telnet 不可用,请使用 netcat 检查连接,如下所示:

    nc -vz <OpenLDAP_Peer_IP> 10389
    
  4. 检查以下文件中的复制配置:
    /opt/apigee/data/apigee-openldap/slapd.d/cn=config/olcDatabase={2}bdb.ldif
    

    该文件应包含如下配置:

    olcSyncRepl: rid=001
      provider=ldap://__OTHER_LDAP_SERVER__/
      binddn="cn=manager,dc=apigee,dc=com"
      bindmethod=simple
      credentials=__LDAP_PASSWORD__
      searchbase="dc=apigee,dc=com"
      attrs="*,+"
      type=refreshAndPersist
      retry="60 1 300 12 7200 +"
      timeout=1
    
  5. 另外,还应查看同一文件,了解 olcMirrorMode 属性的值。应该是 设为值 TRUE:
    grep olcMirrorMode /opt/apigee/data/apigee-openldap/slapd.d/cn=config/olcDatabase={2}bdb.ldif
    
  6. 检查 iptables 和 tcp 封装容器规则。请移除任何不允许的规则 对等 OpenLDAP 服务器互相通信。与网络管理员合作 以便相应地设置规则
  7. 确保每个 OpenLDAP 节点上的 OpenLDAP 系统密码都相同。
  8. 检查 ldif 配置文件中是否存在用于 通过对 以更新配置。通常,包含错误字符的 ldif 文件会导致 ldapmodify 命令运行失败,因此可能没有设置复制。移除所有不良内容 保存配置文件

如果问题仍然存在,请联系 Apigee 支持,获取有关设置 N-Way OpenLDAP 复制的帮助。

无法启动 OpenLDAP

问题

OpenLDAP 未启动。

错误消息

SLAPD Dead But Pid File Exists

可能的原因

此问题通常是由于文件系统中遗留的锁文件导致 删除。

诊断

请按照以下步骤诊断此问题:

  1. 请在以下位置检查是否有 OpenLDAP 紧急进程锁定或 pid 文件:
    /opt/apigee/var/run/apigee-openldap/apigee-openldap.lock
    /opt/apigee/var/run/apigee-openldap/apigee-openldap.pid
    
  2. 删除锁定文件和 pid 文件(如果找到),然后尝试重启 openldap。
    rm /opt/apigee/var/run/apigee-openldap/apigee-openldap.lock
    Rm /opt/apigee/var/run/apigee-openldap/apigee-openldap.pid
    
  3. 如果 OpenLDAP 受限进程已开始,请跳过以下步骤。
  4. 如果 OpenLDAP slapd 进程未启动,请尝试在调试模式下运行 slapd,然后查找 任何错误:
    slapd -h ldap://:10389/ -u apigee -F /opt/apigee/data/apigee-openldap/slapd.d -d 255
    
  5. 错误可能指向资源问题。检查系统的内存和 CPU 利用率。
  6. 请检查 OpenLDAP 的版本,如果旧版本是旧版,请进行升级。查看支持的 OpenLDAP(我们的支持的软件文档)。
    slapd -V
    
  7. 使用 strace 排查 slapd 进程问题,并将 strace 输出提供给 Apigee 支持
    strace -tt -T -f -F -i -v -e read=all -s 8192 -e write=all -o /tmp/strace.out -p <pid>
    

OpenLDAP 数据损坏

问题

用户将无法再运行管理通话或登录 Edge 界面。使用 ldapsearch 实用程序查询用户,可能会指示该用户存在于 LDAP 数据存储区中,或可以识别 可能缺少某些用户或角色

错误消息

Unknown username and password combination.

可能的原因

通常,该问题可能是由于 OpenLDAP 数据损坏造成的。通常,OpenLDAP 不会损坏数据但在极少数情况下,如果确实出现了这种问题,则可能是 系统磁盘故障或磁盘空间问题。

诊断

  1. 使用以下命令检查已安装 OpenLDAP 的系统上的磁盘空间:
    du -m /opt
    
  2. 如果您发现磁盘可用空间非常接近 100%,则表示原因 您的系统的磁盘空间不足。

分辨率

如果系统的磁盘空间不足或即将耗尽磁盘可用空间,请将 更多的磁盘空间,以确保您有足够的磁盘空间。

当您拥有足够的磁盘可用空间后,请使用以下解决方案之一来处理 LDAP 数据 损坏问题:

  1. 从备份中恢复 OpenLDAP 数据。
  2. 清理 OpenLDAP 数据库。

解决方案 1:恢复 备份中的 LDAP 数据

在正常运行的 OpenLDAP 节点进行备份。应定期进行备份。请参阅 Apigee Private Cloud 操作指南 有关备份的最佳做法:

slapcat -F /opt/apigee/data/apigee-openldap/slapd.d -l /tmp/ldap-backup.ldif

可通过以下步骤从正常备份中恢复 OpenLDAP 数据。

  1. 停止需要恢复数据的 OpenLDAP 节点:
    /opt/apigee/apigee-service/bin/apigee-service apigee-openldap stop
    
  2. 将目录更改为 OpenLDAP 数据目录:
    cd /opt/apigee/data/apigee-openldap
    
  3. 使用移动命令备份现有的 OpenLDAP 数据:
    mv ldap ldap_orig
    
  4. 切换到 apigee 用户:
    su apigee
    
  5. /opt/apigee/data/apigee-openldap 目录创建新的 OpenLDAP 数据 具有原始名称的目录:
    mkdir ldap
    
  6. 备份第 3 步中的 ldap_orig/DB_CONFIG 子目录, openldap 目录。
    cp ldap_orig/DB_CONFIG ldap
    
  7. 要从通过 slapcat 拍摄的备份中恢复数据,请使用 slapadd 导入 ldif, 包含良好数据:
    slapadd -F /opt/apigee/data/apigee-openldap/slapd.d -l /tmp/ldap-backup.ldif
    
  8. 启动 OpenLDAP 流程:
    /opt/apigee/apigee-service/bin/apigee-service apigee-openldap start
    

解决方案 2 清理 LDAP 数据库

执行下列步骤会擦除 OpenLDAP 数据库,以提供全新的开始。此解决方案可以 如果 OpenLDAP 数据工作的最后一个状态没有数据备份,则使用 。

  1. 停止 OpenLDAP 服务:
    /opt/apigee/apigee-service/bin/apigee-service apigee-openldap stop
    
  2. 将目录更改为 OpenLDAP 数据目录:
    cd /opt/apigee/data/apigee-openldap
    
  3. 使用移动命令备份现有的 OpenLDAP 数据:
    mv ldap ldap_orig
    
  4. 切换到 apigee 用户:
    su apigee
    
  5. 使用原来名称创建新的 OpenLDAP 数据目录:
    mkdir ldap
    
  6. 从第 3 步获取备份 ldap_orig/DB_CONFIG 子目录,并将其复制到 openldap 中 目录:
    cp ldap_orig/DB_CONFIG ldap
    
  7. 重启 OpenLDAP 进程:
    /opt/apigee/apigee-service/bin/apigee-service apigee-openldap start
    
  8. 重启管理服务器以强制刷新与 OpenLDAP 的连接:
    /opt/apigee/apigee-service/bin/apigee-service edge-management-server restart
    

解决方案 #3 将 OpenLDAP 重置为基本安装

如果解决方案 #2 没有解决问题,您可以将 OpenLDAP 重置为基本安装, 如本部分所述。

前提条件

要重置 OpenLDAP,您需要满足以下前提条件:

  • 能够使用系统管理员和根 LDAP 凭据运行设置。
  • 拥有对 ldapadd 实用程序的访问权限。
  • 为管理/LDAP 节点保存的原始静默配置文件。

如需重置 OpenLDAP,请执行以下步骤:

  1. 重新安装 OpenLDAP 和管理服务器。
    1. 停止 openldap 服务器:
      apigee-service apigee-openldap stop
    2. 删除损坏的 openldap 数据文件夹:
      rm -rf /opt/apigee/data/apigee-openldap
    3. 卸载 openldap 组件:
      apigee-service apigee-openldap uninstall
    4. 使用之前所用的配置文件重新安装 openldap 组件 初始安装的 SDK:
      /opt/apigee/apigee-setup/bin/setup.sh -p ld -f configfile
      其中 configfile 是配置文件的名称。
    5. 使用原始配置文件重新安装管理服务器:
      /opt/apigee/apigee-setup/bin/setup.sh -p ms -f configfile

    After doing these steps, Management API calls should work again using the sysadmin account only. However, it will not be possible to log into the Edge UI, and Management API calls with any other users will not work.

  2. Add missing openldap entries for orgs that existed prior to the corruption.

    After the above step is completed, openldap will be missing entries for orgs that existed when the corruption occurred. The majority of the actual org data such as proxy bundles is stored in Cassandra or Zookeeper is not lost. However, running the setup-org script will not automatically add the openldap data for the orgs that already exist in Cassandra, and Zookeeper. This data has to be added manually for every org that existed prior to the corruption using the following steps:

    1. Create an ldif file called missingLDAP.ldif with the following content:
      # orgname, organizations, apigee.com
      dn: o=orgname,ou=organizations,dc=apigee,dc=com
      objectClass: organization
      O: orgname
      
      # userroles, orgname, organizations, apigee.com
      dn: ou=userroles,o=orgname,ou=organizations,dc=apigee,dc=com
      ou: userroles
      objectClass: organizationalUnit
      
      # orgadmin, userroles, orgname, organizations, apigee.com
      dn: cn=orgadmin,ou=userroles,o=orgname,ou=organizations,dc=apigee,dc=com
      objectClass: organizationalRole
      cn: orgadmin
      roleOccupant: uid=admin,ou=users,ou=global,dc=apigee,dc=com
      
      # resources, orgadmin, userroles, orgname, organizations, apigee.com
      dn: ou=resources,cn=orgadmin,ou=userroles,o=orgname,ou=organizations,dc=apigee,dc=com
      ou: resources
      objectClass: organizationalUnit
      
      # @@@, resources, orgadmin, userroles, orgname, organizations, apigee.com
      dn: cn=@@@,ou=resources,cn=orgadmin,ou=userroles,o=orgname,ou=organizations,dc=apigee,dc=com
      roleOccupant: ou=delete,ou=permissions,dc=apigee,dc=com
      roleOccupant: ou=get,ou=permissions,dc=apigee,dc=com
      roleOccupant: ou=put,ou=permissions,dc=apigee,dc=com
      labeledURI: /
      objectClass: organizationalRole
      objectClass: labeledURIObject
      cn: @@@

      其中,orgname 是您尝试重新创建的组织。

    2. 使用以下命令添加缺少的 LDAP 实体:
      ldapadd -x -w  -D "cn=manager,dc=apigee,dc=com" -H ldap://localhost:10389 -f missingLDAP.ldif

    上述步骤会为现有组织创建缺失的条目,orgadmin 该组织的权限。针对需要重新创建的每个组织重复上述步骤。 此时,您可以向组织中添加 orgadmin 个用户, 默认角色尚不存在,因此您需要按下一步进行添加。

  3. 为现有组织添加缺少的默认角色和权限。

    使用最初设置任何现有组织时所用的相同配置文件, 运行以下命令:

    /opt/apigee/apigee-service/bin/apigee-service apigee-provision create-roles -f configfile
  4. 完成此过程后,您需要手动执行以下操作:

    • 使用界面或 Management API 添加损坏之前存在的任何自定义角色,
    • 将任意用户添加到相关用户角色。
  5. (可选)在管理中重新建立外部化身份验证配置。

    在以下情况下恢复 /opt/apigee/customer/application/management-server.properties: 配置没有更改 由于该界面尚未重新安装,因此 /opt/apigee/customer/application/ui.properties 应保持不变,因为 系统管理员凭据已经通过新的管理安装恢复了。

  6. (可选)在管理节点上重新安装 Apigee mTLS。

    如果之前已安装 Apigee mTLS,请按照 Apigee mTLS 安装指南重新安装 部署到管理服务器节点上。

如果问题仍然存在,请与 Apigee 联系 支持团队,进一步帮助。