将 EC2Rescue for Windows Server 与命令行结合使用 - Amazon Elastic Compute Cloud
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

将 EC2Rescue for Windows Server 与命令行结合使用

利用 EC2Rescue for Windows Server 命令行界面 (CLI),您可以编程方式运行 EC2Rescue for Windows Server 插件(称为“操作”)。

EC2Rescue for Windows Server 工具有两种执行模式:

  • /online — 这允许您对安装了 EC2Rescue for Windows Server 的实例执行操作(如收集日志文件)。

  • /offline:<device_id> — 这允许您对附加到单独的 Amazon EC2 Windows 实例(已安装 EC2Rescue for Windows Server)的脱机根卷执行操作。

EC2Rescue for Windows Server 工具下载到您的 Windows 实例并提取文件。您可以使用以下命令查看帮助文件:

EC2RescueCmd.exe /help

EC2Rescue for Windows Server 可对 Amazon EC2 Windows 实例执行下列操作:

收集操作

注意

您可以收集所有日志、整个日志组或一个组中的单个日志。

EC2Rescue for Windows Server 可以从活动实例和离线实例收集以下数据。

日志组 可用日志 描述
all 收集所有可用日志。
eventlog
  • 'Application'

  • 'System'

  • 'EC2ConfigService'

收集应用程序、系统和 EC2Config 事件日志。
memory-dump
  • 'Memory Dump File'

  • 'Mini Dump Files'

收集实例上的所有内存转储文件。
ec2config
  • 'Log Files'

  • 'Configuration Files'

收集 EC2Config 服务生成的日志文件。
ec2launch
  • 'Logs'

  • 'Config'

收集 EC2Launch 脚本生成的日志文件。
ssm-agent
  • 'Log Files'

  • 'Patch Baseline Logs'

  • 'InstanceData'

收集 SSM Agent 生成的日志文件和 Patch Manager 日志。
sysprep 'Log Files' 收集 Windows 系统准备工具生成的日志文件。
driver-setup
  • 'SetupAPI Log Files'

  • 'DPInst Log File'

  • 'Amazon PV Setup Log File'

收集 Windows SetupAPI 日志 (setupapi.dev.logsetupapi.setup.log)。
registry
  • 'SYSTEM'

  • 'SOFTWARE'

  • 'BCD'

收集 SYSTEMSOFTWARE Hive。
egpu
  • 'Event Log'

  • 'System Files'

收集与 Elastic GPU 相关的事件日志。
boot-config 'BCDEDIT Output' 收集 HKEY_LOCAL_MACHINE\BCD00000000 Hive。
windows-update 'Log Files'

收集 Windows 更新生成的日志文件。

注意

在 Windows Server 2016 及更高版本中,日志以 Windows 事件跟踪 (ETW) 格式收集。

cloudendure
  • 'Migrate Script Logs'

  • 'Driver Logs'

  • 'CloudEndure File List'

收集与 CloudEndure 代理相关的日志文件。

EC2Rescue for Windows Server 可以从活动实例收集以下额外数据。

日志组 可用日志 描述
system-info 'MSInfo32 Output' 收集 MSInfo32
gpresult 'GPResult Output'

收集组策略报告。

可用选项如下:

  • /output:<outputFilePath> – 使用 zip 格式保存收集的日志文件所需的目标文件路径位置。

  • /no-offline – 离线模式下使用的可选属性。不会在完成操作后将卷设置为脱机。

  • /no-fix-signature – 离线模式下使用的可选属性。不会在完成操作后修复可能的磁盘签名冲突。

示例

以下示例使用的是 EC2Rescue for Windows Server CLI。

在线模式示例

收集所有可用日志:

EC2RescueCmd /accepteula /online /collect:all /output:<outputFilePath>

仅收集特定日志组:

EC2RescueCmd /accepteula /online /collect:ec2config /output:<outputFilePath>

收集日志组中的单个日志:

EC2RescueCmd /accepteula /online /collect:'ec2config.Log Files,driver-setup.SetupAPI Log Files' /output:<outputFilePath>

离线模式示例

从 EBS 卷收集所有可用日志。该卷按 device_id 值指定。

EC2RescueCmd /accepteula /offline:xvdf /collect:all /output:<outputFilePath>

仅收集特定日志组:

EC2RescueCmd /accepteula /offline:xvdf /collect:ec2config /output:<outputFilePath>

救援行动

EC2Rescue for Windows Server 可以使用以下服务设置检测和解决问题:

服务组

可用操作

描述

all
system-time 'RealTimeIsUniversal' 系统时间
  • RealTimeisUniversal – 检测是否已启用 RealTimeisUniversal 注册表项。如果禁用,当时区设置为非 UTC 的值时,Windows 系统时间将有偏差。

firewall
  • 'Domain networks'

  • 'Private networks'

  • 'Guest or public networks'

Windows 防火墙

  • 域网络 – 检测是否已启用或禁用此 Windows 防火墙配置文件。

  • 私有网络 – 检测是否已启用或禁用此 Windows 防火墙配置文件。

  • 访客或公有网络 – 检测是否已启用或禁用此 Windows 防火墙配置文件。

rdp
  • 'Service Start'

  • 'Remote Desktop Connections'

  • 'TCP Port'

远程桌面

  • 服务启动 – 检测是否已启用远程桌面服务。

  • 远程桌面连接 – 检测是否已启用。

  • TCP 端口 – 检测远程桌面服务正在侦听的端口。

ec2config
  • 'Service Start'

  • 'Ec2SetPassword'

  • 'Ec2HandleUserData'

EC2Config

  • 服务启动 – 检测是否已启用 EC2Config 服务。

  • Ec2SetPassword – 生成新的管理员密码。

  • Ec2HandleUserData – 在实例下一次启动时允许您运行用户数据脚本。

ec2launch 'Reset Administrator Password' 生成新的 Windows 管理员密码。
network 'DHCP Service Startup'

网络接口

  • DHCP 服务启动 – 检测是否已启用 DHCP 服务。

可用选项如下:

  • /level:<level> – 操作应触发的检查级别的可选属性。允许的值包括:informationwarningerrorall。默认情况下,将它设置为 error

  • /check-only – 可生成报告但不修改离线卷的可选属性。

  • /no-offline – 可防止在完成操作之后将卷设置为离线的可选属性。

  • /no-fix-signature – 不会在完成操作后修复可能的磁盘签名冲突的可选属性。

救援示例

以下示例使用的是 EC2Rescue for Windows Server CLI。该卷是使用 device_id 值指定的。

尝试修复在卷上发现的所有问题:

EC2RescueCmd /accepteula /offline:xvdf /rescue:all

尝试修复卷上的一个服务组内的所有问题:

EC2RescueCmd /accepteula /offline:xvdf /rescue:firewall

尝试修复卷上的一个服务组内的特定项目:

EC2RescueCmd /accepteula /offline:xvdf /rescue:rdp.'Service Start'

指定在一个卷上要尝试修复的多个问题:

EC2RescueCmd /accepteula /offline:xvdf /rescue:'system-time.RealTimeIsUniversal,ec2config.Service Start'

还原操作

EC2Rescue for Windows Server 可以使用以下服务设置检测和解决问题:

服务组

可用操作

描述

还原上次已知的正常配置

lkgc 上次已知的正常配置 – 尝试以上次已知的可启动状态启动实例。
从最新备份还原 Windows 注册表 regback 从备份还原注册表 – 从 \Windows\System32\config\RegBack 还原注册表。

可用选项如下:

  • /no-offline — 可防止在完成操作之后将卷设置为脱机的可选属性。

  • /no-fix-signature — 不会在完成操作后修复可能的磁盘签名冲突的可选属性。

还原示例

以下示例使用的是 EC2Rescue for Windows Server CLI。该卷是使用 device_id 值指定的。

在卷上还原上次已知的正常配置:

EC2RescueCmd /accepteula /offline:xvdf /restore:lkgc

在卷上还原上一个 Windows 注册表备份:

EC2RescueCmd /accepteula /offline:xvdf /restore:regback