Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

201 lines
8.5 KiB

  1. #
  2. # The following script constructs 3 member replica sets in a hub and spoke
  3. # environment. Each replica set has a primary hub member, a backup hub member
  4. # and a branch member. The only difference between primary and backup hub
  5. # members is the schedule. The schedule on the primary is set to trigger
  6. # first and so the primary should take most (or all) of the replication traffic.
  7. # The backup schedule is set to trigger later and so it should take little
  8. # or no traffic except in the case where the primary hub is offline.
  9. # This eliminates a hub from being a single point of failure for both nightly
  10. # replication and remote access from employees when operating from their
  11. # non-home branch.
  12. #
  13. #
  14. # Restriction: script variables must be prefixed with "$".
  15. #
  16. $stage = "D:\\staging"; ## NOTE: double slash needed when variable is used.
  17. $DC_OU_DN = "ou=domain controllers,dc=frs1221,dc=nttest,dc=microsoft,dc=com";
  18. #
  19. # The hub server table (This can be supplied in a seperate file using "require")
  20. # The tag "HUB:" identifies a set of objects for later reference. In the
  21. # case below three hub servers are defined and are all objects in the "HUB" set.
  22. # The FRS_SERVER command does not actually create any FRS objects in the DS,
  23. # rather it defines the parameters for each server.
  24. #
  25. HUB: FRS_SERVER (/RP="E:\RSB" /SP="$stage"
  26. /COMPUTER='frs1221\sudarctest1$' ## note use of single quote because of $
  27. /DNS_NAME="sudarctest1.frs1221.nttest.microsoft.com" )
  28. HUB: FRS_SERVER (/RP="E:\RSB" /SP="$stage"
  29. /COMPUTER='frs1221\sudarctest2$'
  30. /DNS_NAME="sudarctest2.frs1221.nttest.microsoft.com" )
  31. #HUB: FRS_SERVER (/RP="E:\RSB" /SP="$stage"
  32. # /COMPUTER='frs1221\sudarctest3$'
  33. # /DNS_NAME="sudarctest3.frs1221.nttest.microsoft.com" )
  34. #
  35. # The branch server table. This uses a for loop to create the branches but
  36. # this data could also come from a file using "require".
  37. # All of the branch servers are members of the "BCH" set.
  38. #
  39. foreach $b ("sudarctest4", "DREWSAM-SRV", "sudarctest3", "DREWSAM-SRV" ) {
  40. $Nt4Acct = "frs1221\\$b\$";
  41. BCH: FRS_SERVER (/RP="D:\RSB" /SP="D:\staging"
  42. /COMPUTER=$Nt4Acct
  43. /id="-$b"
  44. /DNS_NAME="$b.frs1221.nttest.microsoft.com"
  45. /rep_set_name="WD-$b" )
  46. }
  47. #
  48. # Define the two schedules to use.
  49. # The FRS_SCHEDULE command does not actually create any FRS objects in the DS,
  50. # rather it defines the parameters to use when creating a schedule.
  51. #
  52. # Restriction: Any time with a ":" must be enclosed in quotes. See /REPL_DURATION,
  53. # /TIME_ZONE and /DISABLE below.
  54. #
  55. PRIMARY_SCH: FRS_SCHEDULE (/REPL_INTERVAL=12 /REPL_DURATION="1:30"
  56. /TIME_ZONE="-1" /REPL_OFFSET=0 /STAGGER=2
  57. /METHOD=1 /NAME='Primary Sched'
  58. /DISABLE="mo:07:30-mo:18:00,tu:07:30-tu:18:00,we:07:30-we:18:00,th:07:30-th:18:00,fr:07:30-fr:18:00"
  59. )
  60. BACKUP_SCH: FRS_SCHEDULE (/REPL_INTERVAL=12 /REPL_DURATION="1:30"
  61. /TIME_ZONE="-1" /REPL_OFFSET=4 /STAGGER=2
  62. /METHOD=1 /NAME='Backup Sched'
  63. /DISABLE="mo:07:30-mo:18:00,tu:07:30-tu:18:00,we:07:30-we:18:00,th:07:30-th:18:00,fr:07:30-fr:18:00"
  64. )
  65. #
  66. # define a "subroutine" to do the actual creation of the three member
  67. # replica set. Each user defined calling parameter is defined with an
  68. # associated argument type for use when the "subroutine" is called.
  69. #
  70. # Restriction: All "subroutines" must be defined before they are first called.
  71. #
  72. FRS_SUB CREATE_WORK_RS(/HA=SET_ELEMENT # Primary Hub server
  73. /HB=SET_ELEMENT # backup hub server
  74. /B=VARCON # Branch server
  75. /SC1=SCHEDULE # Primary schedule
  76. /SC2=SCHEDULE # backup schedule
  77. /SETTINGSDN=SET_ELEMENT ) # The parent Settings object
  78. #
  79. # Define an FRS replica set object under the settingsdn object.
  80. # The object name for the FRS Replica Set object is based on the {rep_set_name}
  81. # parameter from the branch server object.
  82. #
  83. # Restriction: All subroutine argument refs are surrounded by "%".
  84. # References to parameters in other objects use the
  85. # notation "->{...}".
  86. #
  87. SET: FRS_REPLICASET (/UNDER=%SETTINGSDN% /TYPE=DFS /ONAME=%B%->{rep_set_name})
  88. #
  89. # Create the three FRS member objects underneath the SET object just created.
  90. # Paramters for the member object attributes come from the /SERVER argument
  91. # but they can also be replaced paramters to the FRS_MEMBER command.
  92. # For example, the staging path comes from the /SERVER argument but the
  93. # root path on the two hub members (MHA and MHB) have an override supplied.
  94. # The Root path on MHA is a concatenation (use of ".") of the rootpath
  95. # supplied in the HA argument (the primary hub) and the id parameter
  96. # supplied in the B argument for the branch. This is an FRS restriction
  97. # that two replica sets can not have overlapping roots so we build a
  98. # unique hub root path using the id parameter.
  99. #
  100. # Restriction: References to tags that name a set of objects are
  101. # surrounded by angle brackets. So "<SET>" below refers
  102. # the FRS_REPLICASET object just defined above.
  103. #
  104. MHA: FRS_MEMBER (/UNDER=<SET> /SERVER=%HA% /COMPUTER=%HA%->{COMPUTER}
  105. /ONAME="Primary Hub" /RP=%HA%->{RP}.%B%->{id})
  106. MHB: FRS_MEMBER (/UNDER=<SET> /SERVER=%HB% /COMPUTER=%HB%->{COMPUTER}
  107. /ONAME="Backup Hub" /RP=%HA%->{RP}.%B%->{id})
  108. MB: FRS_MEMBER (/UNDER=<SET> /SERVER=%B% /COMPUTER=%B%->{COMPUTER}
  109. /ONAME="Branch")
  110. #
  111. # Create the connection objects between the members defined above.
  112. # Note use of angle brackets. The primary and backup schedules come
  113. # from the calling parameters. For the two interhub connections the
  114. # schedule is always on since they are well connected by fast links.
  115. #
  116. FRS_CONNECTION (/BINDDC=SUDARCTEST1 /TO=<MB> /FROM=<MHA> /ONAME="FROM-PRIMARY-HUB" /SCHED=%SC1%)
  117. FRS_CONNECTION (/TO=<MB> /FROM=<MHB> /ONAME="FROM-BACKUP-HUB" /SCHED=%SC2%)
  118. FRS_CONNECTION (/TO=<MHA> /FROM=<MB> /ONAME="FROM-BRANCH-PRIMARY" /SCHED=%SC1%)
  119. FRS_CONNECTION (/TO=<MHB> /FROM=<MB> /ONAME="FROM-BRANCH-BACKUP" /SCHED=%SC2%)
  120. FRS_CONNECTION (/TO=<MHA> /FROM=<MHB> /ONAME="INTER-HUB1" /SCHED=ON)
  121. FRS_CONNECTION (/TO=<MHB> /FROM=<MHA> /ONAME="INTER-HUB2" /SCHED=ON)
  122. #
  123. # The tags defined above (i.e. SET, MHA, MHB and MB) are local to the
  124. # subroutine. They are undefined when the subroutine completes.
  125. #
  126. FRS_END_SUB
  127. #
  128. # The main loop creates a replica set for each branch. It distributes the
  129. # branches across the set of hub servers and advances the schedule by the
  130. # stagger amount after each complete sweep through the set of hub servers.
  131. #
  132. #
  133. # $Hx is used as an index into the set of hub servers.
  134. #
  135. $Hx = 0;
  136. $NHub = FRS_COUNT_SET(/SET=<HUB>);
  137. print " NHUB = $NHub\n\n";
  138. #
  139. # Define the FRS Settings Object.
  140. #
  141. SETTINGS: FRS_SETTINGS (
  142. /DN="cn=services,cn=configuration,dc=frs1221,dc=nttest,dc=microsoft,dc=com"
  143. /ONAME="cn=ntfrs test settings")
  144. #
  145. # Iterate through all branch servers in the "BCH" set. The $Branch variable
  146. # refers to one of the FRS_SERVER objects defined above.
  147. #
  148. foreach $Branch (FRS_ARRAY(/SET=<BCH>)) {
  149. #
  150. # Call the subroutine defined above to create a replica set for this branch.
  151. # The notation <HUB>[$Hx] is like an array reference in that it selects
  152. # a single item from the "HUB" server set defined above. The index value
  153. # can be an expression as shown in /HB parameter below. Also note that
  154. # set tags declared outside a subroutine are global.
  155. #
  156. CREATE_WORK_RS ( /HA=<HUB>[$Hx] /HB = <HUB>[($Hx+1) % $NHub] /B=$Branch
  157. /SC1=<PRIMARY_SCH> /SC2=<BACKUP_SCH> /SETTINGSDN=<SETTINGS>)
  158. #
  159. # Jump to the next hub server for load balancing.
  160. #
  161. $Hx=($Hx+1) % $NHub;
  162. #
  163. # If we have completed a sweep through all servers in the "HUB" set then
  164. # apply the stagger amount to each schedule to use in the next sweep.
  165. #
  166. if ($Hx == 0) {
  167. FRS_STAGGER (/SCHED=<PRIMARY_SCH>)
  168. FRS_STAGGER (/SCHED=<BACKUP_SCH>)
  169. }
  170. }