sp_adddistributor(Transact-SQL)

적용 대상:SQL ServerAzure SQL Managed Instance

sys.servers 테이블에 항목을 만들고(없는 경우) 서버 항목을 배포자로 표시하고 속성 정보를 저장합니다. 이 저장 프로시저는 데이터베이스의 배포자 master 에서 실행되어 서버를 배포자로 등록하고 표시합니다. 원격 배포자의 경우 데이터베이스에서 게시자에서 master 실행되어 원격 배포자를 등록합니다.

Transact-SQL 구문 표기 규칙

구문

sp_adddistributor
    [ @distributor = ] N'distributor'
    [ , [ @heartbeat_interval = ] heartbeat_interval ]
    [ , [ @password = ] N'password' ]
    [ , [ @from_scripting = ] from_scripting ]
[ ; ]

인수

[ @distributor = ] N'distributor'

배포 서버 이름입니다. @distributor 기본값이 없는 sysname입니다. 이 매개 변수는 원격 배포자를 설정하는 경우에만 사용됩니다. 테이블의 배포자 속성에 msdb..MSdistributor 대한 항목을 추가합니다.

참고 항목

서버 이름은 .로 <Hostname>,<PortNumber>지정할 수 있습니다. SQL Server가 사용자 지정 포트를 사용하여 Linux 또는 Windows에 배포되고 브라우저 서비스를 사용할 수 없는 경우 연결의 포트 번호를 지정합니다. 원격 배포자에 대한 사용자 지정 포트 번호의 사용은 SQL Server 2019(15.x) 이상 버전에 적용됩니다.

[ @heartbeat_interval = ] heartbeat_interval

진행률 메시지를 로깅하지 않고 에이전트가 갈 수 있는 최대 시간(분)입니다. @heartbeat_interval int이며 기본값은 분입니다10. 실행 중인 복제본(replica)tion 에이전트의 상태 검사 위해 이 간격에 실행되는 SQL Server 에이전트 작업이 만들어집니다.

[ @password = ] N'password'

distributor_admin 로그인의 암호입니다. @password sysname이며 기본값은 .입니다NULL. 암호가 NULL 빈 문자열 인 경우 @password 임의 값으로 다시 설정됩니다. 첫 번째 원격 배포자를 추가할 때 암호를 구성해야 합니다. distributor_admin 로그인 및 @password 로컬 연결을 포함하여 배포자 RPC 연결에 사용되는 연결된 서버 항목에 대해 저장됩니다. 배포자의 로컬이면 distributor_admin 암호가 새 값으로 설정됩니다. 원격 배포자가 있는 게시자의 경우 게시자와 배포자 모두에서 실행할 sp_adddistributor 때 @password 동일한 값을 지정해야 합니다. sp_changedistributor_password 배포자 암호를 변경하는 데 사용할 수 있습니다.

Important

가능한 경우 런타임 시 사용자에게 보안 자격 증명을 입력하라는 메시지가 표시됩니다. 스크립트 파일에 자격 증명을 저장해야 하는 경우 무단 액세스를 방지하기 위해 파일을 보호해야 합니다.

[ @from_scripting = ] from_scripting

@from_scripting 비트이며 기본값은 .입니다0. 정보를 제공하기 위해서만 확인됩니다. 지원 안 됨 향후 호환성은 보장되지 않습니다.

반환 코드 값

0 (성공) 또는 1 (실패).

설명

sp_adddistributor는 스냅샷 복제본(replica)tion, 트랜잭션 복제본(replica) 및 병합 복제본(replica)에 사용됩니다.

예제

-- 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".

-- Install the Distributor and the distribution database.
DECLARE @distributor AS sysname;
DECLARE @distributionDB AS sysname;
DECLARE @publisher AS sysname;
DECLARE @directory AS nvarchar(500);
DECLARE @publicationDB AS sysname;
-- Specify the Distributor name.
SET @distributor = $(DistPubServer);
-- Specify the distribution database.
SET @distributionDB = N'distribution';
-- Specify the Publisher name.
SET @publisher = $(DistPubServer);
-- Specify the replication working directory.
SET @directory = N'\\' + $(DistPubServer) + '\repldata';
-- Specify the publication database.
SET @publicationDB = N'AdventureWorks2022'; 

-- Install the server MYDISTPUB as a Distributor using the defaults,
-- including autogenerating the distributor password.
USE master
EXEC sp_adddistributor @distributor = @distributor;

-- Create a new distribution database using the defaults, including
-- using Windows Authentication.
USE master
EXEC sp_adddistributiondb @database = @distributionDB, 
    @security_mode = 1;
GO

-- Create a Publisher and enable AdventureWorks2022 for replication.
-- Add MYDISTPUB as a publisher with MYDISTPUB as a local distributor
-- and use Windows Authentication.
DECLARE @distributionDB AS sysname;
DECLARE @publisher AS sysname;
-- Specify the distribution database.
SET @distributionDB = N'distribution';
-- Specify the Publisher name.
SET @publisher = $(DistPubServer);

USE [distribution]
EXEC sp_adddistpublisher @publisher=@publisher, 
    @distribution_db=@distributionDB, 
    @security_mode = 1;
GO

사용 권한

sysadmin 고정 서버 역할의 멤버만 실행할 sp_adddistributor수 있습니다.