排解 OpenLDAP 問題

您正在查看 Apigee Edge 說明文件。
查看 Apigee X 說明文件
資訊

本節提供有關 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 未複製

問題

許多邊緣安裝作業都有多個資料中心,例如 DC-1 和 DC-2。以機構組織管理員身分登入 DC-1 的 Edge UI 時,您可以檢視使用者清單,但相同的使用者名單不會顯示在 DC-2 的 Edge UI 中。

錯誤訊息

未出現任何錯誤,Edge UI 不會顯示應已在所有 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 固定程序鎖定或 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 -h ldap://:10389/ -u apigee -F /opt/apigee/data/apigee-openldap/slapd.d -d 255
    
  5. 錯誤可能是資源問題所致。檢查系統的記憶體和 CPU 使用率。
  6. 請檢查 OpenLDAP 的版本,如果版本過舊,請進行升級。請參閱我們的支援軟體文件,查看支援的 OpenLDAP 版本。
    slapd -V
    
  7. 使用 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 從備份還原 LDAP 資料

可在正常運作的 OpenLDAP 節點上建立備份。建議您定期執行備份作業。如要瞭解備份的最佳做法,請參閱 Apigee 私人雲端作業指南

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 元件:
      /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 或 Management API 新增損毀前就存在的自訂角色。
    • 將任何使用者新增至相關使用者角色。
  5. (選用) 針對管理重新建立外部驗證設定。

    如未變更設定,請還原 /opt/apigee/customer/application/management-server.properties。由於 UI 並未重新安裝,由於 sysadmin 的憑證已透過新的管理功能還原,因此 /opt/apigee/customer/application/ui.properties 應維持不變。

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

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

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