排解 OpenLDAP 問題

您正在查看 Apigee Edge 說明文件。
請參閱 Apigee X 說明文件
info

本節提供 OpenLDAP 疑難排解資訊和指南。

SMTP 已停用,使用者必須重設密碼

問題

如果 Edge UI 未設定 SMTP,新增至 Edge 的新使用者就需要設定密碼。

錯誤訊息

Unknown username and password combination.

可能的原因

新使用者無法透過「忘記密碼?」連結取得電子郵件,以便設定密碼,因為系統未設定 SMTP。

解析度

您可以透過下列其中一種方式解決這個問題:

解決方案 1:設定 SMTP 伺服器

請按照說明文件中的操作說明,設定 SMTP 伺服器,為使用者設定新密碼。

解決方案 #2:使用 LDAP

如果無法設定 SMTP 伺服器,請使用下列 LDAP 指令為使用者設定新密碼:

  1. 現有的機構管理員必須透過 Edge UI 新增特定使用者,如下所示:

  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 UI。使用者登入 UI 後,即可設定新密碼。

LDAP 未複製

問題

許多 Edge 安裝有數個資料中心,例如 DC-1 和 DC-2。以組織管理員身分登入 DC-1 中的 Edge UI 時,您可以查看使用者清單,但 DC-2 中的 Edge UI 不會顯示相同的使用者清單。

錯誤訊息

系統不會顯示任何錯誤,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. 針對用於設定 N-Way OpenLDAP 複製作業的 ldif 設定檔,針對已建立用於更新設定的 ldif 檔案執行 dos2unix,檢查其中是否有隱藏字元。一般來說,如果 ldif 檔案含有錯誤字元,就會導致 ldapmodify 指令無法執行,因此可能無法設定複寫作業。移除所有錯誤字元,然後儲存設定檔。

如果問題仍未解決,請與 Apigee 支援團隊聯絡,尋求設定 N-Way OpenLDAP 複製作業的協助。

無法啟動 OpenLDAP

問題

OpenLDAP 無法啟動。

錯誤訊息

SLAPD Dead But Pid File Exists

可能的原因

這個問題通常是因為檔案系統中留下了鎖定檔案,需要將其移除。

診斷

請按照下列步驟診斷這個問題:

  1. 請在下列位置檢查 OpenLDAP slapd 程序鎖定或 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 slapd 程序已啟動,請略過下列步驟。
  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 UI。使用 ldapsearch 公用程式查詢使用者,可能會顯示使用者存在於 LDAP 資料儲存庫中,或是指出可能遺漏的使用者或角色。

錯誤訊息

Unknown username and password combination.

可能的原因

通常,這類問題可能會因 OpenLDAP 資料毀損而發生。一般來說,OpenLDAP 資料不會遭到損毀。但在極少數情況下,損毀可能會是因為系統磁碟故障或磁碟空間問題。

診斷

  1. 使用下列指令,檢查已安裝 OpenLDAP 的系統磁碟空間:
    du -m /opt
  2. 如果您發現已用磁碟空間已接近 100%,表示系統磁碟空間不足,因此導致這個問題。

解析度

如果系統的磁碟空間已用盡或即將用盡,請新增更多磁碟空間,確保有足夠的空間可用。

磁碟空間足夠後,請使用下列任一解決方法解決 LDAP 資料毀損問題:

  1. 從備份還原 OpenLDAP 資料。
  2. 請按照下列步驟清除 OpenLDAP 資料庫:
    1. 關閉 Management Server 2LDAP2
    2. 從 VM 備份 (或 Apigee 備份) 還原 LDAP1
    3. 檢查 Management Server 1 的啟動和復原功能。
    4. 管理伺服器 1LDAP1 正常運作後,請從頭重新安裝 LDAP2 (建立完全空白的系統)。
    5. 以唯讀模式設定 LDAP2,讓 LDAP1 複製至 LDAP2
    6. 使用 ldapsearch 驗證 LDAP1LDAP2 中的行數是否相符。
    7. 重新啟動管理伺服器 2UI2,並確認這些服務已成功啟動。

如需詳細操作說明,請參閱 Public Issue Tracker

解決方案 1:從備份還原 LDAP 資料

在運作中的 OpenLDAP 節點上建立備份。並定期執行備份。如要瞭解備份的最佳做法,請參閱 Apigee Private Cloud Operations Guide

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. 使用 move 指令備份現有的 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. 使用 move 指令備份現有的 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 元件:
      /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. 按照這個程序操作後,您需要手動執行以下操作:

    • 使用 UI 或管理 API 新增損毀前存在的任何自訂角色。
    • 將任何使用者新增至相關使用者角色。
  5. (選用) 在管理工具中重新建立外部驗證設定。

    如果設定未變更,請還原 /opt/apigee/customer/application/management-server.properties。由於 UI 並未重新安裝,因此系統管理員的憑證已透過新安裝的管理工具還原,因此 /opt/apigee/customer/application/ui.properties 應保持不變。

  6. (選用) 在管理節點上重新安裝 Apigee mTLS。

    如果先前已安裝 Apigee mTLS,請按照 Apigee mTLS 安裝指南的說明,在管理伺服器節點上重新安裝。

如果問題仍未解決,請與 Apigee 支援團隊聯絡,尋求進一步協助。