排解 SLES 隨用隨付註冊問題

本文說明如何解決將執行隨用隨付 (PAYG) SUSE Linux Enterprise Server (SLES) 的 Compute Engine 虛擬機器 (VM) 執行個體連線至 SUSE Subscription Management Tool (SMT) 存放區時,可能遇到的問題。

事前準備

  • 確認 VM 已連結服務帳戶。
  • 確認可從 VM 存取 Service Metadata API。
  • 確認 VM 與相應的區域伺服器和 SMT 伺服器之間的網路連線
  • 使用 sc-repocheck 工具自動排解問題。
  • 請參閱 SUSE PAYG 疑難排解指南中的步驟。
  • 如果尚未設定驗證,請先完成設定。 驗證程序會確認您的身分,以便授予 Google Cloud 服務和 API 的存取權。如要從本機開發環境執行程式碼或範例,請選取下列其中一個選項,向 Compute Engine 進行驗證:

    選取這個頁面上範例的預計用途分頁:

    控制台

    使用 Google Cloud 控制台存取 Google Cloud 服務和 API 時,您不需要設定驗證機制。

    gcloud

    1. 安裝 Google Cloud CLI。 安裝完成後,請執行下列指令,初始化 Google Cloud CLI:

      gcloud init

      如果您使用外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。

  • 設定預設區域和可用區。

網路問題

無法解析的網域名稱

如果 VM 無法連線至 smt-gce.susecloud.net SMT 伺服器,您可能會遇到下列問題:

SUSEConnect error: SocketError: getaddrinfo: Name or service not known
ping: unknown host smt-gce.susecloud.net

這類問題通常是因為 SMT 伺服器網域名稱 smt-gce.susecloud.net 解析錯誤所致。這個網域無法在全球解析,因此您必須根據 VM 區域設定 IP 位址,方法如下:

檢查 /etc/hosts 檔案,確認其中包含 smt-gce.susecloud.net 網域的項目。

cat /etc/hosts | grep -i smt

輸出內容大致如下,但 IP 位址可能不同:

# Added by SMT registration do not remove, retain comment as well
108.59.80.221   smt-gce.susecloud.net   smt-gce

如果 /etc/hosts 檔案未包含與上述範例相同的行,請按照下列步驟操作:

  1. 從 SUSE SMT IP 位址清單中,找出與 VM 區域對應的 IP 位址。

  2. 編輯檔案,新增 SUSE SMT IP 位址和任何遺漏的資訊。

網路無法使用

即使 VM 能夠解析 Compute Engine Update Server 網域名稱,網路無法使用仍可能導致下列錯誤:

Unexpected exception.
Not ready to read within timeout.
Repository 'SLE-Module-Adv-Systems-Management12-Pool' is invalid.
Repository 'SLE-Module-Adv-Systems-Management12-Updates' is invalid.

以下列舉您在調查期間可能在 /var/log/cloudregister 記錄檔中發現的錯誤:

WARNING:Unable to remove client registration from server
WARNING:HTTPSConnectionPool(host='smt-gce.susecloud.net', port=443): Max retries exceeded with url: /connect/systems (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 110] Connection timed out',))
INFO:Region server arguments: ?regionHint=europe-central2
ERROR:No response from: [('34.118.112.80', None), ('34.116.251.218', None), ('34.116.224.144', None)]

如要進一步瞭解問題原因,請執行網路連線測試。以下範例說明如何使用 cURL 測試 HTTPS 連線:

curl -sSI -m 5 -o /dev/null \
  -w 'Response code (>0 is OK): %{http_code}\n' \
  'https://smt-gce.susecloud.net'

指令的輸出內容包含 HTTP 回應代碼或錯誤訊息。以下是常見的回應和錯誤:

  • 成功回應:

    Response code (>0 is OK): 200
    
  • 要求逾時錯誤:

    Response code (>0 is OK): 000
    curl: (28) Connection timed out after 5001 milliseconds
    
  • 無法解析的網域錯誤:

    Response code (>0 is OK): 000
    curl: (6) Could not resolve host: smt-gce.susecloud.net
    

在某些情況下 (例如嚴格的主機防火牆規則),與 smt-gce.susecloud.net 網域相關聯的預設 IP 位址可能無法使用。為確保問題不只與目前的 IP 位址有關,請測試其他區域伺服器的網路連線。擷取區域伺服器清單:

前往 SUSE WebUI,取得區域更新伺服器清單。

使用 pint 工具,透過 CLI 取得區域更新伺服器清單。

  1. 安裝必要套件

    sudo zypper install python3-susepubliccloudinfo
  2. 使用下列指令並指定區域

    pint google servers --region us-central1
  3. 如果輸出成功,會包含 XML 格式的項目清單

    <?xml version='1.0' encoding='UTF-8'?>
        <servers>
          <server ip="146.148.73.14" name="" region="us-central1" type="regionserver-sles"/>
          <server ip="162.222.182.90" name="" region="us-central1" type="regionserver-sap"/>
          <server ip="108.59.80.221" name="smt-gce.susecloud.net" region="us-central1" type="smt"/>
          <server ip="108.59.85.41" name="smt-gce.susecloud.net" region="us-central1" type="smt"/>
          <server ip="108.59.80.58" name="smt-gce.susecloud.net" region="us-central1" type="smt"/>
        </servers>
    

如要查看 Google Cloud的 SUSE 伺服器 IP 完整清單,請參閱下列文件:

VM 設定錯誤可能會導致網路無法使用。如有問題,請執行網路診斷,找出根本原因。

註冊失敗

如果 Cloud NAT 中有使用私人 IP 位址的 VM,可能會發生下列錯誤:

ERROR:  Registration failed: Registering system to registration proxy https://smt-gce.susecloud.net
command '/usr/bin/zypper --non-interactive refs Python_3_Module_x86_64' failed
Error: zypper returned 4 with 'Problem retrieving the repository index file for service 'Python_3_Module_x86_64':
Timeout exceeded when accessing 'https://smt-gce.susecloud.net/services/2045/repo/repoindex.xml?credentials=Python_3_Module_x86_64'.

如要解決這個問題,請檢查 Cloud NAT 設定,確認已將「每個 VM 執行個體的最低通訊埠數量」參數設為至少 256。

詳情請參閱 SUSE 支援公告「Cloud NAT 後方的 Compute Engine 執行個體註冊和 zypper 失敗」。

未作答

如果 VM 無法與更新和區域伺服器通訊,可能會看到下列錯誤訊息:

  • SUSEConnect 錯誤:

    SUSEConnect error: Errno::ETIMEDOUT: Connection timed out - connect(2) for "smt-gce.susecloud.net" port 443
    
  • zypper 錯誤:

    Error retrieving metadata for 'SLE-Module-Adv-Systems-Management12-Pool':
    Not ready to read within timeout.
    ...
    

如果更新和區域伺服器未回應,就可能發生這些錯誤。如要確認是否發生這種情況,請檢查 /var/log/cloudregister 記錄是否有類似內容:

INFO:Region server arguments: ?regionHint=europe-central2
INFO:Using API: regionInfo
INFO:Region server arguments: ?regionHint=europe-central2
INFO:Getting update server information, attempt 1
INFO:   Using region server: 130.211.242.136
ERROR:  No response from: 130.211.242.136
INFO:   Using region server: 35.187.193.56
ERROR:  No response from: 35.187.193.56
INFO:   Using region server: 162.222.182.90
ERROR:  No response from: 162.222.182.90
INFO:   Using region server: 130.211.88.88
ERROR:  No response from: 130.211.88.88
ERROR:  None of the servers responded
ERROR:  Attempted: [IPv4Address('130.211.242.136'), IPv4Address('35.187.193.56'), IPv4Address('162.222.182.90'), IPv4Address('130.211.88.88')]
...
...
...
ERROR:Request not answered by any server after 3 attempts
ERROR:Exiting without registration

如要解決這個問題,請嘗試下列一或多項做法:

  • 確認 VM 有外部 IP 位址,或虛擬私有雲子網路使用網路位址轉譯 (Cloud NAT 或自訂解決方案)。

  • 如果您修改了預設網路路由規則 (例如限制公開網路連線能力,或透過地端部署網路轉送流量),請透過預設的 Compute Engine 閘道,手動為 SMT IP 新增路由,方法如下:

    1. 前往 Google Cloud 控制台的「Routes」(路徑) 頁面。

      前往「Routes」(路徑) 頁面

    2. 在「Route Management」分頁中,找出包含 SUSE SMT IP 位址的路徑,並確認該路徑的下一個躍點是 Compute Engine 預設閘道。

    3. 如果缺少路線,請按一下「建立路線」並輸入必要資訊,即可新增路線。

  • 如果您使用內部直通式網路負載平衡器,例如搭配其他中介網路軟體 (如防火牆或自訂 NAT),請執行下列操作,確保負載平衡器是 VM 流量的下一個躍點:

    1. 前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面。

      前往 VM 執行個體頁面

    2. 按一下要檢查的 VM 名稱。「VM details」(虛擬機器詳細資料) 頁面隨即開啟。

    3. 在「網路介面」部分,按一下「查看詳細資料」。

    4. 在「防火牆和路徑詳細資料」部分,找出定義所選 IP 位址範圍路徑的路徑。

    5. 按一下路由名稱,確認內部直通式網路負載平衡器或其 IP 位址是下一個躍點。

    如果沒有定義所選 IP 位址範圍路徑的路由,或路由的下一個躍點與內部直通式網路負載平衡器不同,請將內部直通式網路負載平衡器設為下一個躍點。

  • 如果您使用內部直通式網路負載平衡器,請確認該負載平衡器與 VM 位於同一區域。

    1. 前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面。

      前往 VM 執行個體頁面

    2. 找出要檢查的 VM,並記下其所在區域。

    3. 前往 Google Cloud 控制台的「Load balancing」(負載平衡) 頁面。

      前往負載平衡頁面

    4. 找出使用的內部直通式網路負載平衡器,並檢查是否與 VM 位於相同區域。

    5. 如果 VM 和內部直通式網路負載平衡器不在同一區域,請啟用全域存取權。

透過 Proxy 註冊

如果 VM 使用非透明 Proxy 或其他執行中間人 (PITM) 檢查的軟體 (例如 Barracuda CloudGen Firewall、Palo Alto),可能會發生問題。以下範例說明如何嘗試使用 HTTP Proxy 註冊 SLES。

ERROR: Baseproduct registration failed
ERROR: Registering system to registration proxy https://smt-gce.susecloud.net

Announcing system to https://smt-gce.susecloud.net ...
SUSEConnect error: Net::HTTPFatalError: 503 "Service Unavailable"

SUSE 並未正式支援在 Compute Engine 上,透過中間人 (PITM) 和非透明 Proxy 註冊 SLES。由於憑證固定,PITM Proxy 設定在註冊期間失敗。

建議您使用 Cloud NAT 設定,或設定自訂 SMT 伺服器。

違反 VPC Service Controls

如果貴機構使用 VPC Service Controls (VPC-SC),註冊可能會失敗,且您可能會看到 Request is prohibited by organization's policy 錯誤訊息。如果您未在 VPC-SC 政策中為 SUSE Update Infrastructure 設定例外狀況,就可能因輸入或輸出違規而導致失敗。

如要解決這個問題,請在 VPC-SC 政策的允許清單中新增下列元件,允許 VM 與 SUSE Update Infrastructure 通訊:

  • 更新基礎架構專案:Suse-gce-smt (專案編號:778092048372)
  • 服務帳戶:778092048372@project.gserviceaccount.com
  • 必要方法:compute.alpha.InstancesService.GetLicenses

OS 設定問題

登記狀態不明

如果不確定即付即用 (PAYG) SUSE Linux Enterprise Server (SLES) 是否已註冊,請執行下列指令:

sudo SUSEConnect --status-text

輸出內容會包含 SUSE 產品 (包括 SUSE Linux Enterprise Server) 的版本和註冊狀態。

Installed Products:
------------------------------------------

  SUSE Linux Enterprise Server 12 SP5
  (SLES/12.5/x86_64)

  Registered

------------------------------------------
...

如果狀態為 Not Registered,請重新註冊 VM 來修正問題:

sudo registercloudguest --force-new

如果基礎產品連結指向不正確的產品檔案,可能會發生下列錯誤:

2020-06-17 12:03:56,124 ERROR:Unable to obtain product information from server "108.59.85.41,None"
        Unprocessable Entity
        {"type":"error","error":"Unmet product dependencies, activate one of these products first: SUSE Linux Enterprise Server 12 x86_64, SUSE Linux Enterprise Server for SAP Applications 12 x86_64, SUSE Linux Enterprise Server 12 SP1 x86_64, ...","localized_error":"..."}
Unable to register modules, exiting.

如果 /etc/products.d/baseproduct 符號連結指向錯誤的產品檔案 (例如 sle-module-toolchain.prod),就會發生這項錯誤。

如要解決這個問題,請更新 /etc/products.d/baseproduct 的符號連結,指向適當的基礎產品檔案:

  1. 前往 /etc/products.d 目錄

      cd /etc/products.d
  2. 如果您已安裝 SLES for SAP,請執行下列指令,並將 SLES.prod 替換為 SLES_SAP.prod:

      sudo ln -sf SLES.prod baseproduct

無法取得執行個體身分資訊

如果 VM 沒有執行個體身分資訊,您可能會遇到下列錯誤。如果執行個體未附加服務帳戶,或附加的服務帳戶已停用,就可能發生這個問題。

ERROR:Data collected from stderr for instance data collection "b'Unable to access instance identity information\n'"

如要存取身分權杖的執行個體中繼資料,所有 VM 都必須有相關聯的服務帳戶。

詳情請參閱公有雲基礎架構更新。

如要檢查 VM 服務帳戶的狀態,請在 VM 上執行下列指令:

curl -s -H 'Metadata-Flavor: Google' \
  'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity?audience=test'

成功回應範例 (含身分權杖):

eyJhbGciOiJSUzI1NiIsImtpZCI6IjkzOTd0MDQxSHQ2NDNxNzkzUjY1MDIwNzEyMjZPNnppaTdqNTl3eTciLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJ0ZXN0IiwiYXpwIjoiMjY1MDIwMDUyMzgzMjYyNTk0ODU2IiwiZXhwIjoxNjgzNzEyNTQzLCJpYXQiOjE2ODM3MTI4NjQsImlzcyI6Imh0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbSIsInN1YiI6IjQ1NjA2MzQ5MDg5Mzc0Njg3ODI5NyJ9.EpzQ3NZ8mKStdpH10fL34qsKG0rjQEflzvLJLm2tVNX4xBJAkMhi8lcs5InUEY-QMK3njgbzdzNtD1fXoIfKoeWsqkA8vG3NkBz5zqRrtaB2STcO14H5tjIdTBsrCtET447tRXlGG5cvgMcWnRDZG92-jUZEpWki_Ri4T69X5-bBWkfE2Thm3oSUW4fScdeVOEmOgWnzD2jeVqQ_2YniywvpkT-rLzKfN-5AgN66zgBfXqJVTC90KFMebfiaOoL7z6ZSM9AjZGf45QEMZjxjd-Xzyee6ZWK8s0RE3hJlytb3zYcLt3tJwQ1WhnrC2ToJ-ZmKxxK3xKDLCvCQ6Ny5to

如果 VM 未受影響,您會收到權杖。如果 VM 受到影響,傳回的中繼資料會是類似以下的錯誤訊息:

{
  "error": "invalid_request",
  "error_description": "Service account not enabled on this instance"
}

如要修正這個問題,請按照下列步驟操作:

  1. 停止 VM:

    gcloud compute instances stop VM_NAME
  2. 將服務帳戶新增至 VM:

    gcloud compute instances set-service-account VM_NAME \
      --service account SERVICE_ACCOUNT \
      --no-scopes
  3. 啟動 VM:

    gcloud compute instances start VM_NAME
  4. 新增缺少的服務帳戶後,請從 VM 執行下列指令,重新註冊 SLES:

    sudo registercloudguest --force-new

缺少必要套件

如果 VM 缺少 cloud-regionsrv-client、regionServiceClientConfigGCE、cloud-netconfig-gce 或 suseconnect-ng 等必要套件,註冊可能會失敗。

如要解決這個問題,請安裝必要套件、清理註冊檔案,然後重新註冊 VM。

  1. 安裝所有缺少的套件。

    sudo zypper install PACKAGE_NAME

    將 PACKAGE_NAME 替換為缺少的套件名稱。

  2. 清除舊的註冊檔案:

    sudo registercloudguest --clean
    sudo SUSEConnect --cleanup
    sudo rm -f /etc/zypp/credentials.d/*
    sudo rm -f /etc/zypp/repos.d/*
    sudo rm -f /etc/zypp/services.d/*
  3. 重新註冊 VM:

    sudo registercloudguest --force-new

如果執行 registercloudguest 時看到 ModuleNotFoundError: No module named 'requests' 錯誤,可能是因為 /usr/bin/python3 符號連結不正確 (例如手動覆寫)。

Traceback (most recent call last):
File "/usr/sbin/registercloudguest", line 34, in <module>
import requests
ModuleNotFoundError: No module named 'requests'

如要解決這個問題,請重新建立符號連結,指向正確的 Python 版本。

  1. 確認執行個體上安裝的 Python 版本:

    sudo zypper info python3
  2. 檢查 python3 符號連結:

    ls -ll /usr/bin | grep -i python3
  3. 如果連結不正確,請移除連結,並建立指向正確 Python 版本 (例如 python3.6) 的新連結:

    sudo rm /usr/bin/python3
    sudo ln -sf /usr/bin/python3.6 /usr/bin/python3

SSL 憑證驗證失敗

如果 /etc/pki/trust/anchors 目錄中缺少憑證檔案,您可能會看到 Curl error 60 或 ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 等錯誤。以下是您在 /var/log/cloudregister 中可能會看到的錯誤詳細範例:

Traceback (most recent call last):
 File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 677, in urlopen
 ...
 File "/usr/lib64/python3.6/ssl.py", line 689, in do_handshake
 self._sslobj.do_handshake()
 ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

執行下列指令並查看空白輸出內容,即可確認缺少憑證檔案:

ls -lart /etc/pki/trust/anchors

如果缺少憑證,輸出內容應為空白:

total 0

如要解決這個問題,請嘗試下列任一做法:

  • 方法 1:清除並重新註冊

    清除與註冊相關的所有檔案,然後強制進行新的註冊。註冊程序會從區域伺服器下載必要憑證。

    sudo registercloudguest --clean && \
      sudo SUSEConnect --cleanup && \
      sudo rm -f /etc/zypp/credentials.d/* && \
      sudo rm -f /etc/zypp/repos.d/* && \
      sudo rm -f /etc/zypp/services.d/* && \
      sudo rm -f /etc/pki/trust/anchors/* && \
      sudo sed -i '/^# Added by SMT reg/,+1d' /etc/hosts && \
      sudo registercloudguest --force-new
  • 方法 2:從運作中的執行個體複製憑證

    如果清除並重新註冊後問題仍未解決,可以使用 gcloud compute scp 從正常運作的執行個體複製憑證檔案,或是將正常運作的執行個體開機磁碟附加至發生故障的執行個體。

    如果您在 MOUNT_PATH 連接並掛接 worker 執行個體的磁碟,請執行下列指令:

    sudo cp MOUNT_PATH/etc/pki/trust/anchors/* /etc/pki/trust/anchors/
    sudo update-ca-certificates
    sudo cp -pr MOUNT_PATH/usr/lib/regionService /usr/lib/regionService
    sudo registercloudguest --force-new

libzypp 套件不相容

如果使用 SLES for SAP 15 的隨用隨付 SUSE VM 無法註冊,可能會出現類似下列的錯誤:

ERROR:Baseproduct registration failed
Registering system to registration proxy https://smt-gce.susecloud.net
...
command '/usr/bin/zypper --non-interactive refs SUSE_Linux_Enterprise_Server_for_SAP_Applications_x86_64' failed
Error: zypper returned 1 with 'Error occurred while setting download (curl) options for 'https://smt-gce.susecloud.net/services/2294?credentials=SUSE_Linux_Enterprise_Server_for_SAP_Applications_x86_64':
Unexpected exception.
Unknown error reading from 'plugin:/susecloud?credentials=SUSE_Linux_Enterprise_Server_for_SAP_Applications_x86_64&path=/services/2294'
...
- Error occurred while setting download (curl) options for 'https://smt-gce.susecloud.net/services/2294?credentials=SUSE_Linux_Enterprise_Server_for_SAP_Applications_x86_64':

如果更新 libzypp 套件後,libcurl4 套件版本不相容,就會發生這個問題。當 libzypp 嘗試自行更新時,就無法再使用 libcurl4 向套件位置發出要求。

如要解決這個問題,請手動更新 libzypp 套件。以下是指令範例,您可能需要調整版本號碼:

sudo rpm -i libzypp-17.31.31-150400.3.52.2.x86_64.rpm

不支援的 OS 版本或過時的套件

如果執行的 OS 版本超出一般支援期限 (例如 SLES 12 SP4,一般支援期限已於 2020 年 6 月 30 日結束),註冊可能會失敗。如果 VM 上的套件過舊,無法與 SUSE 更新基礎架構通訊,就可能發生這項錯誤。即使網路連線似乎部分成功 (例如使用 telnet 至 SMT 伺服器會傳回 403 Forbidden 錯誤),您仍可能會在 /var/log/cloudregister 記錄檔中看到無法連線至 IP 的錯誤。

如要檢查套件是否過時,可以查看安裝日期。如果套件超過一年未更新,可能已過時。如要查看套件的上次更新時間,請使用下列指令:

rpm -qa --qf '%{NAME}-%{VERSION} : %{INSTALLTIME:date}\n' | grep PACKAGE_NAME

如要解決這個問題,請升級至支援的 SLES 版本。您可能也需要按照 SUSE 技術資訊文件 (TID) 的說明更新特定套件。