排解 SLES 按量付費註冊問題


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

事前準備

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

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

      1. After installing the Google Cloud CLI, initialize it by running the following command:

        gcloud init

        If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

      2. Set a default region and zone.

網路問題

無法解析的網域名稱

如果 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 位址有關,請對其他區域伺服器執行網路連線測試。如要擷取區域伺服器清單,請執行下列步驟:

WebUI

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

CLI

使用 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>
    

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

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

註冊失敗

如果 VM 在 Cloud NAT 中有私人 IP 位址,您可能會遇到下列錯誤:

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

詳情請參閱 Registration and zypper failed for Compute Engine instances behind Cloud NAT SUSE 支援公告。

未作答

如果 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 位址,或虛擬私有雲子網路使用 NAT (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」(VM 詳細資料) 頁面隨即開啟。

    3. 在「Network interfaces」(網路介面) 區段中,按一下「View details」(查看詳細資料)

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

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

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

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

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

      前往 VM 執行個體頁面

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

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

      前往「Load balancing」(負載平衡) 頁面

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

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

作業系統設定問題

登記狀態不明

如果您不確定隨用隨付 (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,請從重新註冊程序開始,修正問題。

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

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...
        ...
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 受到影響:

{
  "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

    詳情請參閱「重新註冊」一節。

透過 Proxy 註冊

如果 VM 設定為使用任何類型的 Proxy 軟體,就可能會發生問題。下列範例示範如何嘗試使用 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"

透過中介機構 (例如中間人 (MITM) 或非透明類型 Proxy) 修改原始通訊時,Compute Engine 上的 SUSE 不會提供作業系統註冊的官方支援。

如要解決這個問題,官方解決方案是設定 Cloud NAT,並透過 Cloud NAT 傳送 VM 流量。

常見解決方法

重新註冊

在某些情況下,重新註冊的方法可用於解決註冊問題。

如要強制進行新註冊,請使用下列指令:

sudo registercloudguest --force-new

如果成功,系統會輸出下列內容。

Registration succeeded

如要瞭解重新註冊程序的詳細資訊,請參閱/var/log/cloudregister

成功示例

INFO:Forced new registration
INFO:Clean current registration server: ('108.59.80.221', None)
...
INFO:Starting new HTTP connection (1): 169.254.169.254
INFO:Region server arguments: ?regionHint=us-central1
INFO:Using region server: 130.211.242.136
INFO:Starting new HTTPS connection (1): 130.211.242.136
INFO:Starting new HTTPS connection (1): 108.59.80.58
INFO:Modified /etc/hosts, added: 108.59.80.58   smt-gce.susecloud.net   smt-gce
...
INFO:Starting new HTTPS connection (1): 108.59.80.58
DEBUG:"GET /api/health/status HTTP/1.1" 200 None
INFO:Current update server will be used: "('108.59.80.58', None)"
INFO:Starting new HTTPS connection (1): smt-gce.susecloud.net
DEBUG:"POST /connect/systems/products/migrations HTTP/1.1" 422 None
INFO:Registration: /usr/sbin/SUSEConnect --url https://smt-gce.susecloud.net --product sle-module-containers/12/x86_64 --instance-data /var/lib/cloudregister/9c982106-78de-48fe-a662-20383da4c760

失敗的範例

INFO:Forced new registration
INFO:Using API: regionInfo
INFO:Starting new HTTP connection (1): 169.254.169.254
INFO:Region server arguments: ?regionHint=us-central1
INFO:Using region server: 130.211.242.136
INFO:Starting new HTTPS connection (1): 130.211.242.136
ERROR:No response from: 130.211.242.136
INFO:Using region server: 130.211.88.88
INFO:Starting new HTTPS connection (1): 130.211.88.88
ERROR:No response from: 130.211.88.88
INFO:Using region server: 146.148.73.14
INFO:Starting new HTTPS connection (1): 146.148.73.14
ERROR:No response from: 146.148.73.14
ERROR:None of the servers responded
ERROR:  Attempted: ['130.211.242.136', '130.211.88.88', '146.148.73.14']
ERROR:Exiting without registration

取消註冊

在某些情況下 (例如重大版本升級),您可能會遇到下列錯誤,因為系統已向 SUMA 註冊:

Can't get available migrations from server: SUSE::Connect::ApiError: The requested products 'SUSE Manager Client Tools for SLE 12 x86_64' are not activated on the system.
This system is managed by SUSE manager.

請按照下列步驟解決問題:

  1. 請按照「Adding or deleting modules and extensions with SUSEConnect」指南的說明,移除 SUSE Manager Client Tools 模組。

  2. 按照「如何取消註冊 SUSE Manager Client」指南的說明,取消註冊 SUMA。

  3. 從 VM 執行下列指令,清除舊的註冊項目:

      sudo SUSEConnect --cleanup && \
        sudo registercloudguest --clean && \
        sudo rm -f /etc/SUSEConnect && \
        sudo rm -f /etc/zypp/{repos,services,credentials}.d/* && \
        sudo rm -f /var/lib/cloudregister/* && \
        sudo rm -rf /var/cache/zypp/* && \
        sudo rm -rf /var/cache/cloudregister/* && \
        sudo sed -i '/^# Added by SMT reg/,+1d' /etc/hosts
  4. 執行下列指令,再次註冊系統:

      sudo registercloudguest --force-new

    詳情請參閱「重新註冊」一節。

  5. 註冊程序完成後,請重新整理服務和存放區,並檢查 SMT 伺服器提供的系統是否包含所有預期存放區:

      sudo zypper ref -s && \
        sudo zypper ls && \
        sudo zypper lr -U