예제 #1
0
 public void CleanUp()
 {
     if (AGHelper.IsAGExist(agName, primary))
     {
         AGHelper.DropAG(agName, primary);
     }
     CleanupDatabases();
     StopBackup();
 }
예제 #2
0
        // When we called this primary and secondary should being create
        public void TestCreateAGWithTwoReplicasWithoutDatabase()
        {
            Smo.Server        primary = replicas[0];
            AvailabilityGroup ag      = new AvailabilityGroup(primary, agName);

            List <Smo.Server> secondaries = replicas.GetRange(1, replicas.Count - 1);

            for (int i = 0; i < replicas.Count; ++i)
            {
                AvailabilityReplica ar = ARHelper.BuildAR(ag, replicas[i].Name, replicaEndpointUrls[i]);
                ag.AvailabilityReplicas.Add(ar);
            }


            try
            {
                Console.WriteLine("Creating availability group '{0}' on server '{1}",
                                  ag.Name, primary.Name);

                ag.Create();
                Thread.Sleep(1000); //Sleep a tick to let AG create take effect

                foreach (Smo.Server srv in secondaries)
                {
                    srv.JoinAvailabilityGroup(agName);
                }
                CreateAGListener();
                // enable autoseeding in secondary
                //secondary.GrantAvailabilityGroupCreateDatabasePrivilege(agName);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Failed to create AG {0}", ag.Name);
                AGHelper.DropAG(ag.Name, primary);
            }
        }
예제 #3
0
 /// <summary>
 /// Drop the given ag using Smo and wait until, the ag is dropped in all servers.
 /// </summary>
 /// <param name="agName">Availability group name.</param>
 /// <param name="targetServer">Server on which the AG needs to be dropped</param>
 /// <param name="otherServer">Check whether the AG is dropped on this server</param>
 public static void DropAGAndWaitForDrop(string agName, Smo.Server targetServer, Smo.Server otherServer)
 {
     AGHelper.DropAG(agName, targetServer);
 }