如何解决 AWS Replication Agent 在 EC2 Linux 实例上安装失败问题?

4 分钟阅读
0

我正在为 AWS Application Migration Service 或 AWS 弹性灾难恢复安装 AWS Replication Agent。在我的 Amazon Elastic Compute Cloud (Amazon EC2) Linux 实例上安装失败。

解决方法

确定错误

AWS Replication Agent 安装程序日志从日志末尾开始显示错误。运行以下命令查看安装程序日志的最后一页,以确定错误。然后,查看以下与错误相关的部分。

less +G aws_replication_installer.log

以下解决方法涵盖了 Linux 操作系统上最常见的 AWS Replication Agent 安装错误。

libz.so .1:无法从共享库映射分段: 不允许操作

错误示例

./aws-replication-installer-64bit: error while loading shared libraries: libz.so .1: failed to map segment from shared object: Operation not permitted

安装脚本使用 /tmp 目录。如果在 /tmp 上设置了 noexec,则 libz.so 无法映射分段。发生这种情况时,您会收到此不允许操作错误。

要排除此错误,请执行以下操作:

1.运行以下命令卸载 /tmp

# umount /tmp

2.运行以下命令,以使用 exec 权限装载卷:

# sudo mount /tmp -o remount, exec

请求中包含的安全令牌已过期

错误示例

botocore.exceptions.ClientError: An error occurred (ExpiredTokenException) when calling the GetAgentInstallationAssetsForDrs operation: The security token included in the request is expired [installation_id: 1a9af9d3-9485-4e02-965e-611929428c61, agent_version: 3.7.0, mac_addresses: 206915885515739,206915885515740, _origin_client_type: installer]

此错误通常是由过期的 AWS Identify and Access Management (IAM) 角色引起的。当 IAM 角色过期时,对 Application Migration Service 或弹性灾难恢复端点的 API 调用将失败。

要解决此问题,请刷新 IAM 角色,或者使用访问密钥或秘密访问密钥安装该角色。有关详细信息,请参阅:

rmmod: 错误: 模块 aws_replication_driver 当前未加载

错误示例

rmmod: ERROR: Module aws_replication_driver is not currently loaded insmod: ERROR: could not insert module ./aws-replication-driver.ko: Required key not available

当在源实例中启用安全启动时,就会发生此错误。Application Migration Service 或弹性灾难恢复不支持安全启动。

要排除此错误,请在源实例中关闭安全启动。

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED]

错误示例

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997) - urllib.error.URLError: <urlopen error unknown url type: https>

**注意:**除了此错误外,您还可以使用以下方法排除大多数 urllib/SSL 错误。

如果客户端使用的是较旧的操作系统版本,运行 Python 3.10 或更高版本,就可能会出现此错误。Python 3.10 增加了 PEP 644,需要具有 OpenSSL 1.1.1 或较新版本提案。

较旧的操作系统版本没有支持 Python 3.10 的最新 OpenSSL 库。因此,AWS Replication Agent 安装无法验证 Application Migration Service 或弹性灾难恢复端点的 SSL 证书。

为避免此错误,请使用较旧版本的 Python,例如 2.7 或 3.8 版。

botocore.exceptions.CredentialRetrievalError

错误示例:

botocore.exceptions.CredentialRetrievalError: Error when retrieving credentials from cert: Oct 17, 2022 9:38:54 AM com.amazonaws.cloudendure.credentials_provider.SharedMain createAndSaveJks

如果您修改 AWS Replication Agent 角色 AWSElasticDisasterRecoveryAgentRole/ AWSApplicationMigrationAgentRole,就可能会发生此错误。

要排除此错误,请确保 AWS Replication Agent 角色如下所示:

Application Migration Service

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "PrincipalGroup": {
        "AWS": "svc:mgn.amazonaws.com"
      },
      "Action": [
        "sts:AssumeRole",
        "sts:SetSourceIdentity"
      ],
      "Condition": {
        "StringLike": {
          "sts:SourceIdentity": "s-*",
          "aws:SourceAccount": "AWSACCOUNTIDHERE"
        }
      }
    }
  ]
}

弹性灾难恢复

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "PrincipalGroup": {
        "AWS": "svc:drs.amazonaws.com"
      },
      "Action": [
        "sts:AssumeRole",
        "sts:SetSourceIdentity"
      ],
      "Condition": {
        "StringLike": {
          "aws:SourceAccount": "AWSACCOUNTIDHERE",
          "sts:SourceIdentity": "s-*"
        }
      }
    }
  ]
}

stderr: aws-replication.target 的依赖项作业失败。

错误示例:

stderr: A dependency job for aws-replication.target failed. See 'journalctl -xe' for details

以下是出现此错误的两个可能原因:

  • /var 目录的权限为 754。
  • 为 aws-replication 用户创建 Linux 组时出现问题。

要解决 /var 问题,请为 /var 目录运行 chmod 755

要解决 Linux 组问题,请执行以下操作:

1.完全卸载 AWS Replication Agent。

2.运行以下命令删除 aws-replication 用户和 aws-replication 组:

# userdel aws-replication
# groupdel aws-replication

3.重新安装 AWS Replication Agent。

有关详细信息和安装先决条件,请参阅:

线程 "main" com.amazonaws.services.drs.model.InternalServerException 中发生异常

错误示例:

Exception in thread "main" com.amazonaws.services.drs.model.InternalServerException: An unexpected error has occurred (Service: Drs; Status Code: 500; Error Code: InternalServerException; Request ID: 4f4a76cb-aaec-44cc-a07a-c3579454ca55; Proxy: null)

如果客户端禁用 AWS STS 端点,就会出现此错误。如果 AWS STS 端点禁用,Application Migration Service 就无法调用 STS 来代入客户端账户中的角色。弹性灾难恢复也是如此。

要排除此错误,请在客户端中启用 AWS STS 端点。有关详细信息,请参阅在 AWS 区域启用和停用 AWS STS

insmod: 错误:无法插入模块 ./aws-replication-driver.ko: 必需的密钥不可用

如果操作系统启用了安全启动,就会出现此错误。Application Migration Service 和弹性灾难恢复不支持启用了安全启动的 Linux 操作系统。

要解决此错误,请为 Linux 操作系统禁用安全启动。在大多数操作系统上,都是在虚拟机监控器中禁用安全启动。

insmod: 错误:无法插入模块 ./aws-replication-driver.ko: 无法分配内存

错误示例:

insmod: ERROR: could not insert module ./aws-replication-driver.ko: Cannot allocate memory
rmmod: ERROR: Module aws_replication_driver is not currently loaded
]
2023-03-16 10:27:08,416 ERROR      Exception during agent installation                                             
Traceback (most recent call last):
  File "cirrus/installer_shared/installer_main.py", line 308, in run_agent_installer_command_linux
  File "shared/installer_utils/command_utils.py", line 161, in run
shared.installer_utils.command_utils.RunException:
command: /tmp/tmp_t

如果 Linux 操作系统没有足够的内存来安装代理,就会出现此错误。

要排除此错误,请确保您的操作系统至少有 300 MB 的可用内存。

生成代理驱动程序时出现意外错误! 内核 Linux 标头文件安装是否正确?

错误示例:

Unexpected error while making agent driver! Are kernel linux headers installed correctly?
Installation returned with code 1
Installation failed due to unspecified error:

在代理安装期间,安装会从 Linux 操作系统中配置的包存储库下载匹配的 kernel-devel 包。当代理安装工作流无法将匹配的 kernel-devel 包安装到 Linux 操作系统的运行内核时,就会出现此错误。

要排除此错误,请查看安装日志,以确认访问存储库时是否出现问题。然后,从互联网上手动下载 kernel-devel 包。下载包后,再次运行安装。

您可以从以下网站下载匹配的 kernel-devel/linux-headers 包:

AWS Replication Agent 还会安装安装所需的依赖项,例如 make gcc perl tar gawk rpm。有关详细信息,请参阅 Linux 安装要求

AWS 官方
AWS 官方已更新 1 年前