活动目录的复制之细节

转载自:http://teamapproach.ca/trouble/Replication.htmWindows Server Troubleshooting - Replication

Replicating directory information in Windows NT servers is simple because only the PDC Primary Domain Controller can accept updates and these updates are sent directly from the primary to the BDC Backup Domain Controllers. The problem with this simple scheme is that no updates can be accepted if the Primary Domain Controller fails.

NT Domain                                           AD Multimaster Replication
ïð                    óó
BDC            PDC          BCD                     DC              DC             DC
Only PDC accept updates                         Any DC can accept updates

To provide better fault tolerance, the Active Directory supports multimaster replication. With multimaster replication, any domain controller can accept updates. All updates must then be replicated to all other domain controllers to try to achieve a consistent database. When network links and servers go down, the consistency between the distributed database cannot be guaranteed at any point in time. Because of this situation, the Active Directory is said to be loosely consistent. The Active Directory is designed to cope with loose consistency by continuously trying to get the databases to converge. Eventually updates will replicate to all Domain Controllers and then the Active Directory has convergence.

If every server had to replicate changes to every other server, there would be an excessive number of server connections.

To simplify the replication topology and to reduce the network traffic, the Active Directory uses a store-and-forward replication model as shown in the following diagram.

ó
    ô õö ô
        ÷ø
ó
Excessive connections
ÄÊ
ÇÃ
Store-and-Forward
Replication

The store-and-forward model has a reduced number of replication partners with whom domain controllers exchange information.

Each domain controller stores three NC naming contexts, schema, configuration, and domain, each of which is replicated separately.

 

     
 

ó
Domain1 NC

 

óó
Domain2 NC


Domain3 NC

 All servers replicate the configuration and schema NCs

A service called the KCC Knowledge Consistency Checker determines which servers are replication partners. It starts by forming a replication ring and then adds connections that divide the ring until there is no more that 3 hops between servers. In the following diagram, 3 connections must be added to divide the 10-server ring to ensure no more than 3 hops.  

óóó
   ô

   ô

ó

   ô

   ô
óóó
 Replication Ring 

Update Sequence Numbers

Any change to any object attribute in the Active Directory must be replicated to all other domain controllers. To keep track of changes, every attribute update is assigned a 64-bit sequence number called the USN update sequence number. The following diagram is a simplified view of his this works and shows how each attribute update is assigned a simple update sequence number.

USNAttribute 
1238AttributeQ
1237AttributeX
1236AttributeB
1234AttributeZ 
1234AttributeN 
 ... ... 

In the following example, if Server2 is a new domain controller then all attributes from Server1 are replicated to Server2. Server2 maintains its own independent USN update sequence numbers. Server2 must record the highest USN from Server1. This highest USN is know as the high-watermark vector. The next time replication occurs, only attributes with a higher USN need be copied

Existing directory on Server1New directory on Server2
USNAttribute USNAttribute 
1238AttributeQReplicatedè325AttributeQ
1237AttributeX324AttributeX
1236AttributeB323AttributeB
1234AttributeZ

       

322AttributeZ 
1234AttributeN321AttributeN 
 ... ...  ... ... 
   High-watermark for Server1 = 1238

Domain Controllers must also record for every attribute update,

  • Is this an originating update that was made on this server? or
  • Is this a replicated update and on which server did it originate?
USNAttributeOriginated where? 
9880AttributeYReplicated from Server2
9879AttributeCReplicated from Server3
9878AttributeFOriginated here
9877AttributeWReplicated from Server2
9876AttributePOriginated here
 ... ... ...

To understand how the USN is used to notify domain controller replication partners, consider the following example. The diagram shows the state of the attribute updates before and after a replication cycle. The italics text represents the new information after the replication cycle. Initially, Server1 is updated to USN 1241. Its replication partners Server2 and Server3 have a high-watermark for Server1 of 1238 and 1240 respectively, set from the previous replication cycle. Only attribute updates with a USN higher than the high-watermark need to be replicated and are represented by the text in italics with the gray background. After the replication cycle, both servers will update their high-watermark to Server1's USN of 1241.

When attribute changes occur, domain controllers delay the notification of replication partners for 5 minutes in an attempt to accumulate multiple changes. Sending multiple changes together will result in less network traffic than sending each update separately. 

 

Existing directory on Server1Directory on Server2
USNAttribute USNAttribute 
1241AttributeMReplicatedè325AttributeM
1240AttributeG324AttributeG
1239AttributeV323AttributeV
1238AttributeQ

 

325AttributeQ 
1237AttributeX324AttributeX 
 ... ...  ... ... 
  ReplicatedHigh-watermark for Server1 = 1238
    îHigh-watermark for Server1 = 1241
    
 Directory on Server3
   USNAttribute 
   9881AttributeM
  9880AttributeY
  9879AttributeC
  

       

9878AttributeF 
  9877AttributeW 
    ... ... 
   High-watermark for Server1 = 1240
   High-watermark for Server1 = 1241

If a domain controller is offline for an extended period of time, its high-watermark vectors will not be updated. When it does come back online, it will then receive all updates without any loss of information.

Up-to-dateness Vector

Although we see that changes get replicated even when servers fail, we do not yet have the complete story of how replication works. Based on what has been described above, there is a problem if Server2 and Server3 replicate to each other. Because their USNs have now increased, they would replicated these changes to each other. But Server2 and Server3 already got these changes from Server1. They would also try to replicate these changes back to Server1. Server1's USN would increase again and it would replicate these same changes back to Server2 and Server3, thus creating a vicious replication loop. To prevent this, the domain controllers need to have another mechanism to represent how up-to-date they are with the source of the attribute updates. The Active Directory has an up-to-dateness vector to record the highest USN for updates that originate from each domain controller and have been received. The following table provides a summary.

VectorDescriptionFor which DCs
High-watermarkHighest USN received fromReplication Partners
Up-to-datenessHighest USN originating fromAll DCs with same name context

The up-to-dateness vector prevents changes from replicating when they have already been received from a different source. The up-to-dateness vector ensures that a domain controller knows how up to date it is with changes that originated on a particular domain controller.

 Server1 Server2 My information with respect to Server1 is up-to-date to USN 1240 so only send me changes that originate at Server1 with a USN greater than 1240.
USNAttribute î 
1241AttributeM Server4
1240AttributeGì__
1239AttributeVîì 
1238AttributeQ Up-to-dateness of Server1 = 1240
1237AttributeX   
 ... ... Server3  

Resolving Conflicts

What happens if the same attribute is changed independently on two different domain controllers?  The conflict needs to be resolved as the change replicates between the domain controllers. In the end the attribute change must converge to a consistent value. For each attribute, the Active Directory stores its value, but also

  • an incrementing version number
  • the time that the change was originated
  • the server where the change originated
AttributeValueVersionOriginating timeOriginating server
 

incremented


 
 

Conflicts are resolved by examining this additional information in the following sequence. Normally the last value that is written is used.

  • the highest version number is used
  • the latest originating time is used
  • the originating server is identified by a GUID number, if the version and time are the same then the value of the GUID is arbitrarily used to break the tie.

There is a problem to resolve in the case of an object being added or moved to a container on one domain controller and that same container is deleted on another domain controller. In such cases, the objects are placed in the LostAndFound container.

Server1Server2
èAdd user to containerDelete container
To resolve the conflict AD stores the user in the LostAndFound container

Another problem occurs if objects are added to two different domain controllers with the same object name. In this case, the first added object keeps its name, but the second object gets a name in the format RDN*CNF:<GUID> where <GUID> is the globally unique identifying number for the object which is guaranteed to be unique. RDN stands for Relative Distinguished Name, CNF stand for Conflict, and * is a reserved character.

I want to be called Bob
Added 09:30
I want to be called Bob
Added 09:31
    
The 1st object will be named
Bob
The 2nd object will be named
RDN*CNF:1234567890

REPADMIN /SHOWMETA

To see the USNs, originating time, and version numbers  for each attribute, use the REPADMIN command as shown below.

C:\>repadmin /showmeta cn=administrator,cn=users,dc=newdomain,dc=com

33 entries.
Loc.USN Originating DC              Org.USN Org.Time/Date     Ver Attribute
======= ===============           ========= =============     === =========
 8194 Default-First-Site-Name\WIN2003  8194 2003-02-11 11:31:37 1 objectClass
 8194 Default-First-Site-Name\WIN2003  8194 2003-02-11 11:31:37 1 cn
16429 Default-First-Site-Name\WIN2003 16429 2003-04-23 19:45:04 3 description
16427 Default-First-Site-Name\WIN2003 16427 2003-04-23 19:44:14 1 physicalDeliveryOfficeName
 8194 Default-First-Site-Name\WIN2003  8194 2003-02-11 11:31:37 1 instanceType
 8194 Default-First-Site-Name\WIN2003  8194 2003-02-11 11:31:37 1 whenCreated
16432 Default-First-Site-Name\WIN2003 16432 2003-04-23 19:45:53 4 displayName
13893 Default-First-Site-Name\WIN2003 13893 2003-02-11 12:00:00 2 nTSecurityDescriptor

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值