排查 SLES 随用随付注册问题


本文档介绍如何解决在将运行随用随付 (PAYG) SUSE Linux Enterprise Server (SLES) 的 Compute Engine 虚拟机实例连接到 SUSE 订阅管理工具 (SMT) 代码库时可能遇到的问题。

准备工作

  • 确保该虚拟机具有关联的服务账号
  • 确保可以从虚拟机访问 Service Metadata API
  • 使用 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. Install the Google Cloud CLI, then initialize it by running the following command:

      gcloud init
    2. Set a default region and zone.

网络问题

无法解析域名

如果虚拟机无法连接到 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 解析不正确所致。此网域不可全局解析,因此您必须根据虚拟机区域设置其 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 地址列表查找与您的虚拟机区域对应的 IP 地址。

  2. 修改该文件,添加 SUSE SMT IP 地址和缺少的任何其他信息。

网络不可用

即使虚拟机能够解析 Compute Engine 更新服务器域名,您也可能会由于网络不可用而遇到以下错误:

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>
    

如需查找 Google Cloud 的 SUSE 服务器 IP 的完整列表,请查看以下文档:

网络不可用可能是因虚拟机配置错误造成的。如果出现问题,需要执行网络诊断来确定根本原因。

注册失败

如果您的虚拟机在 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 配置,以验证每个虚拟机实例的端口数下限参数至少设置为 160

如需了解详情,请参阅 Cloud NAT 后面的 Compute Engine 实例注册和 zypper 失败 SUSE 支持公告。

无响应

如果您的虚拟机在与更新服务器和区域服务器通信时遇到问题,您可能会看到以下错误:

  • 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

如需解决此问题,请尝试以下一项或多项操作:

  • 确认该虚拟机具有外部 IP 地址,或者 Virtual Private Cloud 子网使用 NAT(Cloud NAT 或自定义解决方案)。

  • 如果您修改了默认网络路由规则(例如限制公共互联网访问或通过本地网络路由流量),请执行以下操作,通过 Compute Engine 的默认网关为 SMT IP 手动添加路由:

    1. 转到 Google Cloud 控制台中的路由页面。

      转到“路由”页面

    2. 路由管理标签页下,查找包含 SUSE SMT IP 地址的路由,并验证其 Compute Engine 默认网关是否设置为下一个跃点。

    3. 如果缺少路由,您可以通过点击创建路由并输入必要信息来添加路由。

  • 如果您使用的是内部直通式网络负载均衡器,以及其他中间网络软件(例如防火墙、自定义 NAT 等),请执行以下操作,确保正在使用该负载均衡器作为虚拟机流量的下一个跃点:

    1. 转到 Google Cloud 控制台中的虚拟机实例页面。

      转到“虚拟机实例”页面

    2. 点击要检查的虚拟机的名称。虚拟机详情页面随即打开。

    3. 网络接口部分中,点击查看详细信息

    4. 防火墙和路由详细信息部分中,找到用于定义所需 IP 地址范围的路径的路由。

    5. 点击路由的名称,并确认内部直通式网络负载均衡器或其 IP 地址设置为下一个跃点。

    如果没有路由定义所需 IP 地址范围的路径,或者该路由的下一个跃点与内部直通式网络负载均衡器不同,则设置内部直通式网络负载均衡器作为下一个跃点

  • 如果您使用的是内部直通式网络负载均衡器,请确认它与虚拟机位于同一区域。

    1. 转到 Google Cloud 控制台中的虚拟机实例页面。

      转到“虚拟机实例”页面

    2. 找到您要检查的虚拟机并记下其区域。

    3. 转到 Google Cloud 控制台中的负载均衡页面。

      转到“负载均衡”页面

    4. 找到所使用的内部直通式网络负载均衡器,并检查该负载均衡器是否与虚拟机位于同一区域。

    5. 如果虚拟机和内部直通式网络负载均衡器不在同一区域,请启用全球访问权限

操作系统配置问题

注册状态未知

如果您不知道随用随付 (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
    

实例身份信息不可用

如果实例身份信息不适用于虚拟机,您可能会遇到以下错误:

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

如需访问身份令牌的实例元数据,所有虚拟机都必须与服务账号相关联。

如需了解详情,请参阅公有云基础架构更新

如需检查虚拟机是否与这种情况相关,请在虚拟机上运行以下命令:

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

如果返回的元数据不是令牌,而是如下错误消息,则虚拟机会受到影响:

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

如需解决此问题,请执行以下步骤:

  1. 停止虚拟机:

    gcloud compute instances stop VM_NAME
    
  2. 将服务账号添加到虚拟机:

    gcloud compute instances set-service-account VM_NAME \
      --service account SERVICE_ACCOUNT \
      --no-scopes
    
  3. 启动该虚拟机:

    gcloud compute instances start VM_NAME
    
  4. 添加缺少的服务账号后,请从虚拟机运行以下命令来重新注册 SLES:

    sudo registercloudguest --force-new
    

    请参阅重新注册部分中的详细信息。

代理背后的注册

如果您的虚拟机配置为使用任何类型的代理软件,则可能会遇到问题。以下示例演示了如何尝试通过 HTTP 代理注册 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] 代理或非透明代理)注册操作系统,则 Compute Engine 上的 SUSE 对此类注册不提供正式支持。

解决此问题的官方解决方案是设置 Cloud NAT 并通过它路由虚拟机流量。

常见解决方法

重新注册

在某些情况下,重新注册方法可用于解决注册问题。

若要强制新注册,请使用以下命令:

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. 按照删除模块和扩展程序指南中的说明,移除 SUSE Manager 客户端工具模块。

  2. 按照如何取消注册 SUSE Manager 客户端指南从 SUMA 取消注册。

  3. 从虚拟机运行以下命令,清理旧注册:

      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