방법: 게시 및 배포 해제(복제 Transact-SQL 프로그래밍)

복제 저장 프로시저를 사용하여 게시 및 배포를 프로그래밍 방식으로 해제할 수 있습니다.

게시 및 배포를 해제하려면

  1. 모든 복제 관련 작업을 중지합니다. 작업 이름 목록은 복제 에이전트 보안 모델의 "SQL Server 에이전트의 에이전트 보안" 섹션을 참조하십시오.

  2. 구독 데이터베이스의 각 구독자에서 sp_removedbreplication을 실행하여 데이터베이스에서 복제 개체를 제거합니다. 이 저장 프로시저는 배포자의 복제 작업은 제거하지 않습니다.

  3. 게시 데이터베이스의 게시자에서 sp_removedbreplication을 실행하여 데이터베이스에서 복제 개체를 제거합니다.

  4. 게시자가 원격 배포자를 사용하는 경우 sp_dropdistributor를 실행합니다.

  5. 배포자에서 sp_dropdistpublisher를 실행합니다. 이 저장 프로시저는 배포자에 등록된 각 게시자에 대해 한 번만 실행해야 합니다.

  6. 배포자에서 sp_dropdistributiondb를 실행하여 배포 데이터베이스를 삭제합니다. 이 저장 프로시저는 배포자의 각 배포 데이터베이스에 대해 한 번만 실행해야 합니다. 그러면 배포 데이터베이스와 연결된 모든 큐 판독기 에이전트 작업도 제거됩니다.

  7. 배포자에서 sp_dropdistributor를 실행하여 서버에서 배포자 지정을 제거합니다.

    [!참고]

    모든 복제 게시 및 배포 개체가 삭제되지 않은 상태로 sp_dropdistpublishersp_dropdistributor를 실행하면 오류가 반환됩니다. 게시자 또는 배포자를 삭제할 때 모든 복제 관련 개체를 삭제하려면 @no_checks 매개 변수를 1로 설정해야 합니다. 게시자 또는 배포자가 오프라인이거나 연결할 수 없는 경우에는 @ignore_distributor 매개 변수를 1로 설정하여 삭제할 수 있습니다. 그러나 삭제되지 않고 남은 모든 게시 및 배포 개체는 수동으로 제거해야 합니다.

다음 스크립트 예에서는 구독 데이터베이스에서 복제 개체를 제거합니다.

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

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

다음 스크립트 예에서는 게시자 및 배포자 역할의 서버에서 게시 및 배포를 해제하고 배포 데이터베이스를 삭제합니다.

-- 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'AdventureWorks';

-- Disable the publication database.
USE [AdventureWorks]
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