みなさんWindows ServerのEOL対策はどのようにされていますか?
直近ではWindows Server 2012R2の延長サポートが2023/10/10に終了しました。
Windows Server 2012R2が動いているAmazon EC2も多いのではないでしょうか?これらのインスタンスを新しいOSに移行するためには、新しいOSバージョンのAMIを使って再度アプリケーションをインストールするという方法もありますが、オンプレミスと同様にインプレースアップグレードをすることもできます。
インプレースアップグレードを行うことで、ドキュメントに残されていない手順によって新しくインストールしなおしても動作しないといった問題に悩まされることは少なくなります。
アップグレードが必要なEC2インスタンスがたくさんある場合には、AWS Systems ManagerのオートメーションランブックのAWSEC2-CloneInstanceAndUpgradeWindows ランブックを活用することもできます。
今回はAWSEC2-CloneInstanceAndUpgradeWindows ランブックを活用して実際にインプレースアップグレードを行ない、発生した問題とAWSサポートの協力を得て実施した対応策についてまとめてみました。
サポート切れになっているWindows Server 2012R2以前のOSを利用されている方は、ぜひ参考にしてみてください。
なお、アップグレードするためにはt2.medium相当以上のインスタンス(インストール作業にてかなりのCPUリソースを使用し、smallインスタンスサイズ相当ではクレジットが枯渇するため)と30GB以上の空き容量が必要ですので、注意してください。
getOSVersion ステップでタイムアウトする
SSM Agent on Instances: [i-xxxxxxx] are not functioning
SSM Agentのインストールを行ってください。
runUpgradeFrom2012R2Or2016 ステップで失敗する
Fail to start automation, errorMessage: Parameter "TargetWindowVersion" has value "2012R2" not found in [2016, 2019, 2022]. (Service: AmazonSSM; Status Code: 400; Error Code: InvalidAutomationExecutionParametersException; Request ID: xxxxxxxxxxxxx; Proxy: null)
ランブック指定時の TargetWindowVersion の指定が間違っているため、移行先のバージョンを正しく入力します。
checkForSSMAgent でタイムアウトし、prepareServerInstanceForSSMInstall、getUpgradedImageDetailsで失敗する
runUpgradeFrom2012R2Or2016のステップが以下で失敗する場合に、内部的にAWSEC2-CloneInstanceAndUpgradeWindows2019のオートーションランブックが呼ばれていて、その中でcheckForSSMAgentのタイムアウトが発生する事象です。
Failed to run automation with executionId: xxxxxxxxxxxxx TimedOut :
{Status=[TimedOut], Output=[No output available yet because the step is not successfully executed, No output available yet because the step is not successfully executed], ExecutionId=[xxxxxxxxxxxxx]}
ランブック指定時の SubnetId にNAT Gatewayが有効になっているか「パブリック IPv4 アドレスの自動割り当て」になっているサブネットを指定します。もしくは「パブリック IPv4 アドレスの自動割り当て」を有効に変更します。
checkAfterWindowsUpgrade2019 でタイムアウトする
SSM Agent on Instances: [i-xxxxxxxxxxxxx] are not functioning
dism /online /get-intlコマンド実行時に表示されるインストールされている言語とフォールバック言語が異なる場合に発生するため、以下の設定を変更し、いったんフォールバック言語に変更したうえで、アップグレードを行い、そのあと再び元に戻す必要があります。(以下の例では英語版のAMIを使って日本語設定をしているEC2の手順となります)
- 日本語のインストールと表示言語の変更でEnglish (United States)を選択
- 地域の変更でUnited Statesを選択
- タイムゾーンを(UTC) Coordinated Universal Timeに変更
- Unicode 対応ではないプログラムの言語の変更でEnglish (United States)を選択
- ようこそ画面と新しいユーザーアカウントの言語設定
なお、システムログからも言語が異なっているかどうかを判断することができます。
以下の例では英語版AMIを使っていて、言語が日本語になっていることがわかります。また、AWS PVドライバがv7.3.1.2となっているため、事前にv8.3.5へのバージョンアップが必要です。
2022/07/15 18:08:08Z: AMI Origin Version: 2015.06.10
2022/07/15 18:08:08Z: AMI Origin Name: Windows_Server-2012-R2_RTM-English-64Bit-Base
2022/07/15 18:08:08Z: OS: Microsoft Windows NT 6.3.9600
2022/07/15 18:08:08Z: OsVersion: 6.3
2022/07/15 18:08:08Z: OsProductName: Windows Server 2012 R2 Standard
2022/07/15 18:08:08Z: OsBuildLabEx: 9600.20475.amd64fre.winblue_ltsb_escrow.220622-1747
2022/07/15 18:08:08Z: Language: ja-JP
2022/07/15 18:08:08Z: EC2 Agent: Ec2Config service v3.6.269
2022/07/15 18:09:19Z: Message: Waiting for meta-data accessibility...
2022/07/15 18:09:20Z: Message: Meta-data is now available.
2022/07/15 18:09:20Z: AMI-ID: ami-xxxxxxx
2022/07/15 18:09:20Z: Instance-ID: i-xxxxxxxx
2022/07/15 18:09:24Z: Driver: AWS PV Network Device v7.3.1.2
2022/07/15 18:09:24Z: Driver: AWS PV Storage Host Adapter v7.3.1.2
Step timed out while step is verifying the SSM Agent availability on the target instance(s). SSM Agent on Instances: [i-xxxxxxx] are not functioning. Please refer to Automation Service Troubleshooting Guide for more diagnosis details.
AWS PV ドライバーのバージョンが古く、インスタンスのステータスチェックが失敗してインスタンスに接続できない状況において発生します。8.3.5にアップグレードすることにより対応することができました。(AWSマネジメントコンソールより対象インスタンスのシステムログを参照することで現在インストールされているAWS PVドライバーを確認できます)
[System.Net.ServicePointManager]::SecurityProtocol = 'TLS12'
Invoke-WebRequest https://s3.amazonaws.com/ec2-windows-drivers-downloads/AWSPV/8.3.5/AWSPVDriver.zip -outfile $env:USERPROFILE\pv_driver.zip
Expand-Archive $env:userprofile\pv_driver.zip -DestinationPath $env:userprofile\pv_drivers
Start-Process $env:userprofile\pv_drivers\AWSPVDriverSetup.msi
なお、$PSVersionTable で PSVersion 4.0の場合には、Expand-Archiveが失敗するため、手動で解凍する必要があります。
Top comments (0)