Decode repadmin /replsum แบบ Pro ก่อนที่ AD จะพัง

ถ้า Active Directory Replication มีปัญหา ผลกระทบกระเพื่อมไปทั่ว — login ช้า, policy ไม่ apply, password เปลี่ยนแล้วยังเข้าไม่ได้ คำสั่งแรกที่ Admin ทุกคนควรรู้จักคือ repadmin /replsum มันให้ภาพรวมของ replication health ทั้ง forest ในหน้าเดียว บทความนี้จะพาถอดรหัสทีละบรรทัด

 

 รู้จัก repadmin /replsum

คำสั่ง repadmin /replsum ดึง replication metadata จาก domain controllers ทั้งหมดใน forest แล้วสรุปออกมาเป็นตาราง 2 ส่วนหลัก: ต้นทาง (source) และ ปลายทาง (destination) ของการ replicate แต่ละ DC
 
 
### PowerShell / CMD

# Run on any DC หรือ PC ที่ลง RSAT แล้ว
repadmin /replsum

# เพิ่ม /errorsonly เพื่อกรองเฉพาะ DC ที่มีปัญหา
repadmin /replsum /errorsonly

# Export เก็บไฟล์
repadmin /replsum > C:\replsum_$(Get-Date -f yyyyMMdd).txt 

 

กายวิภาค Output ทีละส่วน

Output มีโครงสร้าง 3 ส่วนหลักดังนี้

ส่วนที่ 1 — Replication Summary Begin
บรรทัดแรกๆ บอกขอบเขตที่คำสั่งทำงาน
 
# Output

Replication Summary Start

Beginning data collection for replication summary, this may take awhile:
   .....

Source DSA          largest delta    fails/total %%   error
 DC01.corp.local            17m:23s    0 /  36   0%
 DC02.corp.local            15m:08s    0 /  36   0%
 DC03.corp.local            3d.02h:15m    8 /  36  22%   -2146893022 (0x80090322)

Destination DSA      largest delta    fails/total %%   error
 DC01.corp.local            17m:23s    0 /  36   0%
 DC02.corp.local            19m:47s    0 /  36   0%
 DC03.corp.local            3d.02h:15m    8 /  36  22%   -2146893022 (0x80090322)

 

อ่าน Column Header ให้ครบทุกอัน 

Columnความหมายสัญญาณอันตราย
Source / Destination DSAชื่อ FQDN ของ DC ที่เป็น แหล่งส่ง หรือ ผู้รับ replication-
largest deltaช่วงเวลานานที่สุดตั้งแต่ replicate สำเร็จครั้งล่าสุด ไม่ว่า NC ไหนก็ตาม> 1 ชั่วโมง ต้องหาสาเหตุ
fails / totalจำนวนครั้งที่ fail / ทั้งหมดที่ replicate ใน 24h ที่ผ่านมาfail > 0 ต้องดูต่อ
%%เปอร์เซ็นต์ fail rate รวมทุก NC ของ DC นั้น> 0% มีปัญหา
errorWin32 error code (decimal) และ hex ในวงเล็บ คำนี้บอกสาเหตุได้เลย

มี code = ต้องแก้

 

💡 Pro tip: ฝั่ง Source vs Destination
ถ้า Source fail — DC ต้นทางส่งข้อมูลออกไม่ได้
ถ้า Destination fail — DC ปลายทางรับข้อมูลไม่ได้
ถ้า fail ทั้ง 2 ฝั่งพร้อมกันบน DC เดียวกัน มักเป็นปัญหาที่ตัว DC นั้นเอง 

 

ส่วนที่ 2 — Failure Summary

ด้านล่างสุดของ output จะมีส่วนสรุปรวมแบบ group by error code

Output — Failure Summary

Experienced the following operational errors trying to retrieve
replication information:

    58 - DC03.corp.local

The following replication errors were found since 2025-03-16:

Source DSA          Destination DSA  Largest Delta  Fails  Total %%  Error
 DC03.corp.local   DC01.corp.local  3d.02h:15m  8   36 22%
                                                              -2146893022 (0x80090322):
                                                               SEC_E_WRONG_PRINCIPAL

Error Codes ที่เจอบ่อย + วิเคราะห์

error code คือ "ลายเซ็น" ของปัญหา รู้ code รู้ทิศทาง fix ได้ทันที 
 
0x80090322 / -2146893022
SEC_E_WRONG_PRINCIPAL
Kerberos ยืนยันตัวตนไม่ผ่าน — มักเกิดจาก SPN หาย, DNS ผิด หรือ clock skew เกิน 5 นาที
 
 
0x00002EFE / -1722
RPC Server Unavailable
เชื่อม DC ปลายทางผ่าน RPC ไม่ได้ — ตรวจ firewall port 135, 49152-65535, DNS resolution
 
 
0x0000200A / 8202
The DSA object GUID expired
Lingering objects — DC ถูกปิดยาวเกิน tombstone lifetime (default 60 หรือ 180 วัน)
 
 
0x00002105 / 8453
Replication Access Denied
Permission ของ NTDS Settings object ไม่ถูกต้อง หรือ "Replicating Directory Changes" ถูกเอาออก
 
 
0x00000057 / 87
The parameter is incorrect
มักเกิดจาก USN rollback ที่ DC ถูก restore โดยไม่ใช้ snapshot-aware process
 
 
0x00000005 / 5
Access is Denied
Computer account ของ DC ถูก disable หรือ Secure Channel เสียหาย
 
 

 Troubleshoot Flow เมื่อเจอ Fail

เวลาเจอ fail ใน /replsum ให้เดินตาม 6 ขั้นตอนนี้ทีละขั้น อย่าข้าม

1
ระบุ DC ที่มีปัญหาและ error code
จาก /replsum จดชื่อ DC, largest delta, fail rate และ error code ก่อนเสมอ อย่าเพิ่งรีบแก้
2
ตรวจสอบ connectivity พื้นฐาน
ping FQDN, nslookup, test-netconnection port 135 และ 3268 จาก DC คู่ replication — ถ้า network ขาดอยู่ ขั้นตอนต่อไปไม่มีประโยชน์
3
ขยายผลด้วย repadmin /showrepl
repadmin /showrepl <DCname> แสดง replication link ระดับ NC พร้อม error message ละเอียดกว่า ดูว่า NC ไหน fail และกี่ consecutive failures
4
ตรวจ Event Log บน DC ที่มีปัญหา
ดู Directory Service log และ System log หา Event ID 1864, 2087, 2088, 1311 — เหล่านี้คือ witness ที่ดีที่สุด
5
Force sync และดูผล
repadmin /syncall /AdeP บังคับ sync ทุก DC ทุก NC พร้อมกัน หลังรันดู output ว่า fail อีกไหม ถ้าผ่านคือ transient error
6
แก้ตาม error code แล้วรัน /replsum ซ้ำ
Fix ตาม root cause (DNS, Kerberos, firewall, USN rollback) แล้วรัน /replsum ยืนยันว่า fail rate กลับเป็น 0% ก่อน close งาน

🗒️Command Cheatsheet ที่ใช้คู่กัน 

#PowerShell / CMD

# ดู replication status ละเอียดรายตัว
repadmin /showrepl DC03.corp.local

# ดูทุก DC ทั้ง forest ในครั้งเดียว
repadmin /showrepl * /csv > C:\repl_detail.csv

# Force sync ทุก NC ทุก DC (A=all, d=disable staggered, e=enterprise, P=push)
repadmin /syncall /AdeP

# ตรวจ KCC topology
repadmin /kcc

# เช็ค USN — ถ้า CurrentUSN < HighestCommittedUSN อาจมี rollback
repadmin /showutdvec DC03.corp.local dc=corp,dc=local

# ตรวจ Lingering Objects
repadmin /removelingeringobjects DC03.corp.local DC01.corp.local dc=corp,dc=local /Advisory

# ตรวจ clock skew (ต้องไม่เกิน 5 นาที)
w32tm /query /status /verbose
 
ระวัง: USN Rollback

ถ้า DC ถูก restore จาก snapshot โดยไม่ผ่าน VM-GenerationID-aware hypervisor, DC นั้นอาจอยู่ในสถานะ "quarantine" — repadmin /showrepl จะแสดง 00000057 (The parameter is incorrect) และ DC อาจทำตัวเป็น authoritative โดยไม่รู้ตัวว่าข้อมูลย้อนหลังไป


Event ID สำคัญที่ต้องรู้

Event IDLogความหมายระดับ
1864Directory ServiceDC ไม่ได้รับ replication มานานเกิน tombstone lifetime — ใกล้ isolation แล้วCritical
2087Directory ServiceDNS lookup ล้มเหลว, replication ถูก abandonError
2088Directory ServiceDNS lookup ล้มเหลวแต่ใช้ IP fallback — replication สำเร็จแต่ DNS ต้องแก้Warning
1311Directory ServiceKCC ไม่สามารถสร้าง replication topology ครบได้ — มักมี DC ออฟไลน์Error
1925Directory Serviceไม่สามารถสร้าง connection object ไปยัง DC ได้ — ตรวจ port/firewallWarning
5723System (NETLOGON)Secure channel ของ DC สร้างไม่ได้ — computer account อาจเสียError
✅ ค่า threshold ที่ควรจำ

largest delta < 60 นาที = ปกติ | largest delta > 24 ชั่วโมง = แดงแล้ว
clock skew ต้องไม่เกิน 5 นาทีจาก DC ทุกตัว
tombstone lifetime default = 60 วัน (Windows 2003) หรือ 180 วัน (2008+)

 
🚨 ห้ามทำถ้าไม่แน่ใจ

อย่า seize FSMO roles, อย่า metadata cleanup, อย่า demote DC กระทันหัน โดยไม่มี replication สมบูรณ์เป็น baseline ก่อน — ถ้าทำผิดลำดับอาจได้ USN rollback หรือ split-brain ที่แก้ยากมาก

 

#Identity #ActiveDirectory #AD #Repadmin

Comments

Popular posts from this blog

ปลดล็อกพลัง Microsoft Defender for Endpoint: 5 Tips & Tricks ที่ Admin สายลุยต้องรู้! (ฉบับปี 2026)

Azure Active Directory / Entra ID: แนวทางการจัดการ Identity อย่างมืออาชีพในยุค Cloud

ทำความรู้จัก Microsoft Defender XDR: เปลี่ยนจาก "วิ่งไล่จับ" เป็น "คุมทั้งเกม" ด้านความปลอดภัย