如何同步已加入 Windows 網域的執行個體與 AWS Managed Microsoft AD 之間的時間?
我想要使用群組政策,透過 AWS Directory Service for Microsoft Active Directory 為 Microsoft Windows 機器設定時間同步。
簡短說明
Windows 機器在加入 AWS Managed Microsoft AD 網域前,登錄中可能已預設網路時間通訊協定 (NTP) 伺服器。Windows 機器加入網域後,會透過所有可用機制自動同步時間。不過,如果來源 NTP 伺服器的時間不同,此設定可能會導致時間偏移相關問題。
在此範例中,執行個體加入 AWS Managed Microsoft AD 網域前,NtpServer 參數已預先填入 169.254.169.123,0x9。不過,加入網域後,Type 參數會變更為 AllSync。此組態變更可能會造成時間偏移。
加入網域前:
PS C:\> w32tm /dumpreg /subkey:parameters | findstr /i "NtpServer Type" Value Name Value Type Value Data NtpServer REG_SZ 169.254.169.123,0x9 Type REG_SZ NTP
PS C:\> w32tm /query /configuration | findstr /i "Type NTPServer:" Type: AllSync (Local) NtpServer: 169.254.169.123,0x9 time.windows.com,0x8 (Local)
加入網域後:
PS C:\> w32tm /dumpreg /subkey:parameters | findstr /i "NtpServer Type" Value Name Value Type Value Data NtpServer REG_SZ 169.254.169.123,0x9 time.windows.com,0x8 Type REG_SZ AllSync
PS C:\> w32tm /query /configuration | findstr /i "Type NTPServer:" Type: AllSync (Local) NtpServer: 169.254.169.123,0x9 time.windows.com,0x8 (Local)
解決方法
最佳實務是使用網域控制站,確保已加入 Windows 網域的機器透過 AWS Managed Microsoft AD 網域階層同步時間。如需更多資訊,請參閱 Microsoft 網站上的 Windows Time 服務的運作方式和 Windows Time 服務工具與設定。
先決條件
請確認您完成以下先決條件:
- 在已加入網域的 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體上安裝 Active Directory 管理工具。
PS C:\> Install-windowsFeature RSAT-ADDS,RSAT-AD-AdminCenter,RSAT-ADDS-Tools,GPMC,RSAT-DNS-Server Success Restart Needed Exit Code Feature Result ------- -------------- --------- -------------- True No Success {Group Policy Management, DNS Server Tools, . . . }
- 確認 EC2 執行個體已加入您要設定時間同步網域階層的 AWS Managed Microsoft AD 網域。如需更多資訊,請參閱手動加入 Windows 執行個體。
設定 AWS Managed AD 網域時間階層
使用群組政策設定,在 AWS Managed AD 網域階層中同步時間:
- 使用遠端桌面通訊協定 (RDP) 登入 EC2 執行個體。然後,將網域使用者設定為管理員。如需更多資訊,請參閱使用 RDP 連線至您的 Windows 執行個體。
- 執行 GPMC.msc 以開啟群組政策管理主控台。
- 選擇 Domains (網域),然後選擇 [Domain Name], [Directory NetBIOS name]、Computers (電腦)。
- 選擇 Computers (電腦),然後選擇 Create a GPO in this domain and Link it here: (在此網域中建立 GPO 並連結至此處:)
注意: 電腦物件必須位於組織單位 (OU) 中,或位於相同階層內的其他 OU 下方。 - 命名 GPO。例如,您可以使用 Domhier Time Syn。然後,選擇 OK (確定)。
- 選擇您剛建立的 GPO,然後選擇 Edit (編輯)。
- 選擇 Computer Configuration (電腦組態),然後選擇 Administrative Templates (系統管理範本)、System (系統)、WindowsTime Service (Windows Time 服務)、Time Providers (時間提供者)。
- 選擇 Enable Windows NTP Client (啟用 Windows NTP 用戶端),然後選取 Enabled (已啟用)。
- 選擇 OK (確定)。
- 選擇 Configure NTP Client (設定 NTP 用戶端)。
- 選取 Enabled (已啟用),然後變更以下參數:
在 Type (類型),輸入 NT5DS。
在 SpecialPoolInterval,,輸入 900。 - 選擇 OK (確定)。
確認 EC2 執行個體使用時間同步階層
完成以下步驟,以確認網域控制站透過 AWS Managed Microsoft AD 網域階層同步時間。
如需更多資訊,請參閱 Microsoft 網站上的群組政策:初學者的基本疑難排解步驟。
-
使用上一節中的執行個體,強制更新網域政策。以提高權限提示字元或管理員身分開啟 Windows PowerShell 提示字元,然後執行此命令:
PS C:\> gpupdate /force Updating policy... Computer Policy update has completed successfully. User Policy update has completed successfully. -
確認 NT5DS 已生效。
PS C:\> w32tm /query /configuration | findstr /i "Type NTPServer:" Type: NT5DS (Policy) -
強制探索時間來源:
PS C:\> w32tm /resync /rediscover Sending resync command to local computer The command completed successfully. -
識別執行個體的同步伺服器。在此範例中,IP-C61301F5 是時間來源。
PS C:\> w32tm /query /status Leap Indicator: 0(no warning) Stratum: 5 (secondary reference - syncd by (S)NTP) Precision: -23 (119.209ns per tick) Root Delay: 0.0017265s Root Dispersion: 0.2926529s ReferenceId: 0xAC1F0DC6 (source IP: 172.31.13.198) Last Successful Sync Time: 4/18/2023 12:45:37 PM Source: IP-C61301F5.corp.example.com Poll Interval: 7 (128s) -
確認伺服器是網域控制站:
PS C:\> Get-ADDomainController -Filter * | select name name ---- IP-C61301F5 IP-C6130214注意: 同步時間的網域控制站可能會在設定期間變更。此變更不會造成時間同步問題。
-
檢查執行個體與網域控制站之間的時間同步。理想情況下,時間差距應盡可能接近零。如需更多資訊,請參閱 Microsoft 網站上的 W32tm。
PS C:\> w32tm /stripchart /computer:IP-C61301F5.corp.example.com /samples:3 Tracking IP-C61301F5.corp.example.com [172.31.13.198:123]. Collecting 3 samples. The current time is 4/18/2023 12:43:11 PM. 12:43:11, d:+00.0010085s o:-00.0012111s [ * ] 12:43:13, d:+00.0015748s o:-00.0011228s [ * ] 12:43:15, error: 0x80072733
相關資訊
相關內容
已提問 1 年前

