복제 에이전트 실행 파일 개념

다음과 같은 방법으로 복제 에이전트를 프로그래밍 방식으로 제어할 수 있습니다.

  • Microsoft.SqlServer.Replication 네임스페이스의 관리되는 에이전트 프로그래밍 인터페이스를 사용합니다.

  • 제공된 매개 변수 집합을 사용하여 명령 프롬프트에서 에이전트 실행 파일을 호출합니다.

명령 프롬프트에서 복제 에이전트를 직접 호출하면 배치 파일의 명령줄 스크립팅을 통해 에이전트에 프로그래밍 방식으로 액세스할 수 있습니다. 명령 프롬프트에서 호출된 에이전트는 에이전트를 호출하거나 배치 파일을 시작한 사용자의 Microsoft Windows 보안 계정으로 실행됩니다.

실행 파일을 사용하면 다음과 같은 복제 에이전트 인스턴스를 실행할 수 있습니다.

복제 에이전트를 호출할 때 성능 프로필을 사용하여 에이전트 실행 파일에 정의된 매개 변수 집합을 자동으로 전달할 수 있습니다. 자세한 내용은 복제 에이전트 프로필을 참조하십시오.

다음 예에서는 명령 프롬프트에서 복제 에이전트를 호출하는 방법을 보여 줍니다. RMO(복제 관리 개체)를 사용하여 복제 에이전트를 호출할 수도 있습니다. 자세한 내용은 구독 동기화(복제)를 참조하십시오.

[!참고]

이 예에서는 가독성을 높이기 위해 줄 바꿈이 추가되었지만 배치 파일에서 명령은 단일 행으로 작성해야 합니다.

스냅숏 에이전트 실행

이 배치 파일 예는 명령 프롬프트에서 스냅숏 에이전트를 호출하여 AdvWorksSalesOrdersMerge 게시에 대한 스냅숏을 생성합니다.

REM -- Declare variables
SET Publisher=%InstanceName%
SET PublicationDB=AdventureWorks2012 
SET Publication=AdvWorksSalesOrdersMerge 

REM --Start the Snapshot Agent to generate the snapshot for AdvWorksSalesOrdersMerge.
"C:\Program Files\Microsoft SQL Server\110\COM\SNAPSHOT.EXE" -Publication %Publication% 
-Publisher %Publisher% -Distributor %Publisher% -PublisherDB %PublicationDB% 
-ReplicationType 2 -OutputVerboseLevel 1 -DistributorSecurityMode 1 

배포 에이전트 실행

이 배치 파일 예는 명령 프롬프트에서 배포 에이전트를 호출하여 AdvWorksProductTran 게시의 변경 내용을 밀어넣기 구독자에게 계속 복제합니다.

REM -- Declare the variables.
SET Publisher=%instancename%
SET Subscriber=%instancename%
SET PublicationDB=AdventureWorks2012
SET SubscriptionDB=AdventureWorks2012Replica 
SET Publication=AdvWorksProductsTran

REM -- Start the Distribution Agent with four subscription streams.
REM -- The following command must be supplied without line breaks.
"C:\Program Files\Microsoft SQL Server\110\COM\DISTRIB.EXE" -Subscriber %Subscriber% 
-SubscriberDB %SubscriptionDB% -SubscriberSecurityMode 1 -Publication %Publication% 
-Publisher %Publisher% -PublisherDB %PublicationDB% -Distributor %Publisher% 
-DistributorSecurityMode 1 -Continuous -SubscriptionType 0 -SubscriptionStreams 4 

병합 에이전트 실행

이 배치 파일 예는 명령 프롬프트에서 병합 에이전트를 호출하여 끌어오기 구독을 AdvWorksSalesOrdersMerge 게시에 동기화합니다.

REM -- Declare the variables.
SET Publisher=%instancename%
SET Subscriber=%instancename%
SET PublicationDB=AdventureWorks2012
SET SubscriptionDB=AdventureWorks2012Replica 
SET Publication=AdvWorksSalesOrdersMerge

REM --Start the Merge Agent with concurrent upload and download processes.
REM -- The following command must be supplied without line breaks.
"C:\Program Files\Microsoft SQL Server\110\COM\REPLMERG.EXE" -Publication %Publication%  
-Publisher %Publisher%  -Subscriber  %Subscriber%  -Distributor %Publisher%  
-PublisherDB %PublicationDB%  -SubscriberDB %SubscriptionDB% -PublisherSecurityMode 1  
-OutputVerboseLevel 2  -SubscriberSecurityMode 1  -SubscriptionType 1 -DistributorSecurityMode 1  
-Validate 3  -ParallelUploadDownload 1