Yayımlama ve dağıtım devre dışı bırakma

Yayımlama ve dağıtım devre dışı bırakma yöntemi açıklanmıştır SQL Server 2012kullanarak SQL Server Management Studio, Transact-SQL, ya da Çoğaltma Yönetimi Nesneleri'ni (rmo).

Aşağıdakileri yapabilirsiniz:

  • Dağıtımcı tüm dağıtım veritabanlarını silin.

  • Bu yayıncılar tüm yayınlarda silmek ve dağıtımcı kullanan tüm yayımcılar devre dışı bırakın.

  • Tüm yayınları abonelikleri silmek. Veri yayını ve abonelik veritabanları silinmez; Ancak, herhangi bir yayını veritabanları Eşitleme ilişkisini kaybeder. Silinecek abone veri isterseniz, el ile silmelisiniz.

Bu Konuda

  • Başlamadan Önce

    Ön Koşullar

  • Yayımlama ve dağıtım devre dışı bırakmak için kullanma:

    SQL Server Management Studio

    Transact-SQL

    Çoğaltma Yönetimi Nesneleri'ni (rmo)

Başlamadan Önce

Ön Koşullar

  • Yayımlama ve dağıtım devre dışı bırakmak için tüm dağıtım ve yayın veritabanlarına çevrimiçi olması gerekir. Varsa veritabanı anlık dağıtımı veya yayını veritabanları için var, onlar önce yayımlama ve dağıtım devre dışı bırakılan gerekir. Veritabanı snapshot veritabanı salt okunur çevrimdışı kopya ve bir çoğaltma anlık ilgili değil. Daha fazla bilgi için, bkz. Anlık görüntüleri veritabanı (SQL Server).

Başa Dön bağlantısıyla kullanılan ok simgesi[Top]

SQL Server Management Studio Kullanarak

Yayımlama ve dağıtım devre dışı yayımlama ve Dağıtım Sihirbazı'nı kullanarak devre dışı bırakın.

Yayımlama ve dağıtım devre dışı bırakmak için

  1. Yayımcının veya dağıtıcı olarak devre dışı bırakmak istediğiniz bağlanmak Microsoft   SQL Server Management Studiove sonra sunucu düğümünü genişletin.

  2. Sağ çoğaltma klasörünü ve sonra devre dışı yayımlama ve dağıtım.

  3. Devre dışı yayımlama ve Dağıtım Sihirbazı'ndaki adımları tamamlayın.

Başa Dön bağlantısıyla kullanılan ok simgesi[Top]

Transact-SQL'i Kullanma

Yayımlama ve dağıtma programlı olarak çoğaltma depolanmış yordamları kullanarak devre dışı bırakılabilir.

Yayımlama ve dağıtım devre dışı bırakmak için

  1. Tüm çoğaltma ile ilgili işleri durdurun. Proje adlarının listesi için bkz: "Agent güvenlik altında SQL Server Agent" bölümünde Çoğaltma aracısı güvenlik modeli.

  2. Abonelik veritabanının her abone adresindeki idam sp_removedbreplication çoğaltma nesneleri veritabanından kaldırmak için. Bu saklı yordam dağıtımcı adresindeki çoğaltma işleri kaldırmaz.

  3. Yayını veritabanı üzerinde Yayımcı tarafında idam sp_removedbreplication çoğaltma nesneleri veritabanından kaldırmak için.

  4. Yayımcı uzak bir dağıtımcı kullanıyorsa, idam sp_dropdistributor.

  5. Dağıtıcı idam sp_dropdistpublisher. Bu saklı yordam her Publisher dağıtımcı kayıtlı bir kez çalıştırılması gerekir.

  6. Dağıtıcı idam sp_dropdistributiondb distribution veritabanını silmek için. Bu saklı yordam, dağıtıcı her dağıtım veritabanı için bir kez çalıştırılmalıdır. Bu da dağıtım veritabanı ile ilişkili herhangi bir sıra Okuyucu Aracısı işleri kaldırır.

  7. Dağıtıcı idam sp_dropdistributor sunucu dağıtımcı atamasını kaldırmak için.

    [!NOT]

    Eğer sen çalıştırmadan önce tüm çoğaltma yayımlama ve dağıtım nesneleri bırakılan değil sp_dropdistpublisher ve sp_dropdistributor, bu yordamları bir hata döndürecektir. Bir Publisher veya Dağıtıcı bırakılan tüm çoğaltma ilgili nesneleri düşmesi @ no_checks1 parametresi ayarlanmalıdır 1. Bir Publisher veya Dağıtıcı çevrimdışı veya ulaşılamaz, ise @ ignore_distributor parametresi ayarlanabilir 1 onlar kesilmesini böylece; Ancak, herhangi bir yayımlama ve geride nesnelerini dağıtma el ile kaldırılması gerekir.

Örnekler (Transact-SQL)

Bu örnek komut, çoğaltma nesneleri abonelik veritabanından kaldırır.

-- Remove replication objects from the subscription database on MYSUB.
DECLARE @subscriptionDB AS sysname
SET @subscriptionDB = N'AdventureWorks2012Replica'

-- Remove replication objects from a subscription database (if necessary).
USE master
EXEC sp_removedbreplication @subscriptionDB
GO

Bu örnek komut, yayımlama ve dağıtım yayımcı ve dağıtıcı ve dağıtım veritabanı sıska bir sunucuda devre dışı bırakır.

-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). For information about how to use scripting variables  
-- on the command line and in SQL Server Management Studio, see the 
-- "Executing Replication Scripts" section in the topic
-- "Programming Replication Using System Stored Procedures".

-- Disable publishing and distribution.
DECLARE @distributionDB AS sysname;
DECLARE @publisher AS sysname;
DECLARE @publicationDB as sysname;
SET @distributionDB = N'distribution';
SET @publisher = $(DistPubServer);
SET @publicationDB = N'AdventureWorks2012';

-- Disable the publication database.
USE [AdventureWorks2012]
EXEC sp_removedbreplication @publicationDB;

-- Remove the registration of the local Publisher at the Distributor.
USE master
EXEC sp_dropdistpublisher @publisher;

-- Delete the distribution database.
EXEC sp_dropdistributiondb @distributionDB;

-- Remove the local server as a Distributor.
EXEC sp_dropdistributor;
GO

Başa Dön bağlantısıyla kullanılan ok simgesi[Top]

Çoğaltma Yönetimi Nesneleri'ni (rmo) kullanarak

Yayımlama ve dağıtım devre dışı bırakmak için

  1. Tüm abonelikleri dağıtımcı kullanan yayınlar için kaldırın. Daha fazla bilgi için Çekme abonelik silmekve Itme abonelik silme.

  2. Dağıtımcı kullanan tüm yayınlar çıkarmak ve varsa Publisher ve dağıtımcı aynı sunucuda yayımlamayı tüm veritabanları için devre dışı. Daha fazla bilgi için, bkz. Yayını Sil.

  3. Dağıtımcı bir bağlantı kullanarak oluşturmak Serverconnectionsınıf

  4. Örneğini DistributionPublishersınıf Belirtmek name()özelliği ve geçmek ServerConnectionAdım 3'den nesneden.

  5. (İsteğe bağlı) Arama LoadPropertiesnesnesinin özelliklerini ve Publisher'ın varlığını doğrulamak için yöntemi. Bu yöntem ise false, adım 4'te ayarla yayımcı adını yanlış veya Publisher bu Dağıtıcı tarafından kullanılan değil.

  6. Arama Remove(Boolean)yöntemi. Değeri geçmek trueiçin forcevarsa Publisher ve dağıtımcı farklı sunucularda ve yayımcı dağıtımcı yayınları Publisher artık var olmayan ilk doğrulama olmadan kaldırılmalıdır.

  7. Örneğini ReplicationServersınıf Geçmek ServerConnectionnesne adım 3.

  8. Arama UninstallDistributoryöntemi. Değeri geçmek trueiçin forcetüm yerel yayımlama veritabanlarını devre dışı bırakıldı ve Dağıtım veritabanlarını kaldırılmış tüm çoğaltma nesneleri dağıtımcı ilk doğrulama olmadan kaldırılacak.

Örnekler (rmo)

Bu örnek Dağıtıcı yayımcı kaydı kaldırır, damla dağıtım veritabanı ve dağıtımcı kaldırır.

           // Set the Distributor and publication database names.
            // Publisher and Distributor are on the same server instance.
            string publisherName = publisherInstance;
            string distributorName = publisherInstance;
            string distributionDbName = "distribution";
            string publicationDbName = "AdventureWorks2012";

            // Create connections to the Publisher and Distributor
            // using Windows Authentication.
            ServerConnection publisherConn = new ServerConnection(publisherName);
            ServerConnection distributorConn = new ServerConnection(distributorName);

            // Create the objects we need.
            ReplicationServer distributor =
                new ReplicationServer(distributorConn);
            DistributionPublisher publisher;
            DistributionDatabase distributionDb =
                new DistributionDatabase(distributionDbName, distributorConn);
            ReplicationDatabase publicationDb;
            publicationDb = new ReplicationDatabase(publicationDbName, publisherConn);

            try
            {
                // Connect to the Publisher and Distributor.
                publisherConn.Connect();
                distributorConn.Connect();

                // Disable all publishing on the AdventureWorks2012 database.
                if (publicationDb.LoadProperties())
                {
                    if (publicationDb.EnabledMergePublishing)
                    {
                        publicationDb.EnabledMergePublishing = false;
                    }
                    else if (publicationDb.EnabledTransPublishing)
                    {
                        publicationDb.EnabledTransPublishing = false;
                    }
                }
                else
                {
                    throw new ApplicationException(
                        String.Format("The {0} database does not exist.", publicationDbName));
                }

                // We cannot uninstall the Publisher if there are still Subscribers.
                if (distributor.RegisteredSubscribers.Count == 0)
                {
                    // Uninstall the Publisher, if it exists.
                    publisher = new DistributionPublisher(publisherName, distributorConn);
                    if (publisher.LoadProperties())
                    {
                        publisher.Remove(false);
                    }
                    else
                    {
                        // Do something here if the Publisher does not exist.
                        throw new ApplicationException(String.Format(
                            "{0} is not a Publisher for {1}.", publisherName, distributorName));
                    }

                    // Drop the distribution database.
                    if (distributionDb.LoadProperties())
                    {
                        distributionDb.Remove();
                    }
                    else
                    {
                        // Do something here if the distribition DB does not exist.
                        throw new ApplicationException(String.Format(
                            "The distribution database '{0}' does not exist on {1}.",
                            distributionDbName, distributorName));
                    }

                    // Uninstall the Distributor, if it exists.
                    if (distributor.LoadProperties())
                    {
                        // Passing a value of false means that the Publisher 
                        // and distribution databases must already be uninstalled,
                        // and that no local databases be enabled for publishing.
                        distributor.UninstallDistributor(false);
                    }
                    else
                    {
                        //Do something here if the distributor does not exist.
                        throw new ApplicationException(String.Format(
                            "The Distributor '{0}' does not exist.", distributorName));
                    }
                }
                else
                {
                    throw new ApplicationException("You must first delete all subscriptions.");
                }
            }
            catch (Exception ex)
            {
                // Implement appropriate error handling here.
                throw new ApplicationException("The Publisher and Distributor could not be uninstalled", ex);
            }
            finally
            {
                publisherConn.Disconnect();
                distributorConn.Disconnect();
            }
' Set the Distributor and publication database names.
' Publisher and Distributor are on the same server instance.
Dim publisherName As String = publisherInstance
Dim distributorName As String = subscriberInstance
Dim distributionDbName As String = "distribution"
Dim publicationDbName As String = "AdventureWorks2012"

' Create connections to the Publisher and Distributor
' using Windows Authentication.
Dim publisherConn As ServerConnection = New ServerConnection(publisherName)
Dim distributorConn As ServerConnection = New ServerConnection(distributorName)

' Create the objects we need.
Dim distributor As ReplicationServer
distributor = New ReplicationServer(distributorConn)
Dim publisher As DistributionPublisher
Dim distributionDb As DistributionDatabase
distributionDb = New DistributionDatabase(distributionDbName, distributorConn)
Dim publicationDb As ReplicationDatabase
publicationDb = New ReplicationDatabase(publicationDbName, publisherConn)

Try
    ' Connect to the Publisher and Distributor.
    publisherConn.Connect()
    distributorConn.Connect()

    ' Disable all publishing on the AdventureWorks2012 database.
    If publicationDb.LoadProperties() Then
        If publicationDb.EnabledMergePublishing Then
            publicationDb.EnabledMergePublishing = False
        ElseIf publicationDb.EnabledTransPublishing Then
            publicationDb.EnabledTransPublishing = False
        End If
    Else
        Throw New ApplicationException( _
            String.Format("The {0} database does not exist.", publicationDbName))
    End If

    ' We cannot uninstall the Publisher if there are still Subscribers.
    If distributor.RegisteredSubscribers.Count = 0 Then
        ' Uninstall the Publisher, if it exists.
        publisher = New DistributionPublisher(publisherName, distributorConn)
        If publisher.LoadProperties() Then
            publisher.Remove(False)
        Else
            ' Do something here if the Publisher does not exist.
            Throw New ApplicationException(String.Format( _
                "{0} is not a Publisher for {1}.", publisherName, distributorName))
        End If

        ' Drop the distribution database.
        If distributionDb.LoadProperties() Then
            distributionDb.Remove()
        Else
            ' Do something here if the distribition DB does not exist.
            Throw New ApplicationException(String.Format( _
             "The distribution database '{0}' does not exist on {1}.", _
             distributionDbName, distributorName))
        End If

        ' Uninstall the Distributor, if it exists.
        If distributor.LoadProperties() Then
            ' Passing a value of false means that the Publisher 
            ' and distribution databases must already be uninstalled,
            ' and that no local databases be enabled for publishing.
            distributor.UninstallDistributor(False)
        Else
            'Do something here if the distributor does not exist.
            Throw New ApplicationException(String.Format( _
                "The Distributor '{0}' does not exist.", distributorName))
        End If
    Else
        Throw New ApplicationException("You must first delete all subscriptions.")
    End If

Catch ex As Exception
    ' Implement appropriate error handling here.
    Throw New ApplicationException("The Publisher and Distributor could not be uninstalled", ex)

Finally
    publisherConn.Disconnect()
    distributorConn.Disconnect()

End Try

Bu örnekte, ilk yerel yayımlama veritabanlarını devre dışı bırakma veya distribution veritabanını bırakma dağıtımcı kaldırır.

         // Set the Distributor and publication database names.
            // Publisher and Distributor are on the same server instance.
            string distributorName = publisherInstance;

            // Create connections to the Distributor
            // using Windows Authentication.
            ServerConnection conn = new ServerConnection(distributorName);
            conn.DatabaseName = "master";

            // Create the objects we need.
            ReplicationServer distributor = new ReplicationServer(conn);

            try
            {
                // Connect to the Publisher and Distributor.
                conn.Connect();


                // Uninstall the Distributor, if it exists.
                // Use the force parameter to remove everthing.  
                if (distributor.IsDistributor && distributor.LoadProperties())
                {
                    // Passing a value of true means that the Distributor 
                    // is uninstalled even when publishing objects, subscriptions,
                    // and distribution databases exist on the server.
                    distributor.UninstallDistributor(true);
                }
                else
                {
                    //Do something here if the distributor does not exist.
                }
            }
            catch (Exception ex)
            {
                // Implement appropriate error handling here.
                throw new ApplicationException("The Publisher and Distributor could not be uninstalled", ex);
            }
            finally
            {
                conn.Disconnect();
            }
' Set the Distributor and publication database names.
' Publisher and Distributor are on the same server instance.
Dim distributorName As String = publisherInstance

' Create connections to the Distributor
' using Windows Authentication.
Dim conn As ServerConnection = New ServerConnection(distributorName)
conn.DatabaseName = "master"

' Create the objects we need.
Dim distributor As ReplicationServer = New ReplicationServer(conn)

Try
    ' Connect to the Publisher and Distributor.
    conn.Connect()


    ' Uninstall the Distributor, if it exists.
    ' Use the force parameter to remove everthing.  
    If distributor.IsDistributor And distributor.LoadProperties() Then
        ' Passing a value of true means that the Distributor 
        ' is uninstalled even when publishing objects, subscriptions,
        ' and distribution databases exist on the server.
        distributor.UninstallDistributor(True)
    Else
        'Do something here if the distributor does not exist.
    End If

Catch ex As Exception
    ' Implement appropriate error handling here.
    Throw New ApplicationException("The Publisher and Distributor could not be uninstalled", ex)

Finally
    conn.Disconnect()

End Try

Başa Dön bağlantısıyla kullanılan ok simgesi[Top]

Ayrıca bkz.

Kavramlar

Çoğaltma Management Objects kavramları

Yineleme sistem saklı yordamlar kavramları