다음을 통해 공유


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 ]
    [ , [ @encrypt_distributor_connection = ] N'encrypt_distributor_connection' ]
    [ , [ @trust_distributor_certificate = ] N'trust_distributor_certificate' ]
    [ , [ @host_name_in_distributor_certificate = ] N'host_name_in_distributor_certificate' ]
[ ; ]

인수

[ @distributor = ] N'distributor'

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

참고 항목

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

[ @heartbeat_interval = ] heartbeat_interval

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

[ @password = ] N'password'

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

Important

가능한 경우 런타임 시 사용자에게 보안 자격 증명을 입력하라는 메시지가 표시됩니다. 스크립트 파일에 자격 증명을 저장하는 경우에는 무단으로 액세스하지 못하도록 파일에 보안을 설정해야 합니다.

[ @from_scripting = ] from_scripting

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

[ @encrypt_distributor_connection = ] N'encrypt_distributor_connection'

적용 대상: SQL Server 2025(17.x) 이상 버전.

게시자에서 배포자에 대한 내부 연결된 서버 연결이 암호화되는지 여부를 확인합니다. 값은 OLE DB 공급자의 Encrypt 속성에 매핑됩니다. @encrypt_distributor_connectionnvarchar(10)이며, 될 수 없습니다 NULL.

@encrypt_distributor_connection 다음 값 중 하나일 수 있습니다.

  • mandatory (Microsoft OLE DB 공급자 19의 기본값)
  • no 또는 false (Microsoft OLE DB 공급자 18의 기본값)
  • true 또는 yes
  • optional
  • strict

[ @trust_distributor_certificate = ] N'trust_distributor_certificate'

적용 대상: SQL Server 2025(17.x) 이상 버전.

배포자의 TLS 인증서를 유효성 검사 없이 신뢰할 수 있는지 여부를 나타냅니다. 값은 OLE DB 공급자의 TrustServerCertificate 속성에 매핑되며, 일반적으로 자체 서명된 인증서를 Mandatory 사용할 때 암호화 설정과 함께 사용됩니다. @trust_distributor_certificatenvarchar(5)이며, 될 수 없습니다 NULL.

@trust_distributor_certificate 다음 값 중 하나일 수 있습니다.

  • no(기본값)
  • yes

참고 항목

보안 기본값은 보안을 향상시키는 기본 OLEDB 공급자 19와 관련이 있습니다. 기본값을 재정의하는 옵션은 신뢰할 수 있는 인증서를 사용하도록 인스턴스를 구성하는 것보다 안전하지 않습니다. 기본값을 재정의한 후 인증서를 사용하도록 SQL Server를 구성한 다음 sp_changedistributor_property 저장 프로시저를 사용하여 속성을 다시 보안 기본값으로 설정하는 trust_distributor_certificate=no 옵션이 있습니다.

[ @host_name_in_distributor_certificate = ] N'host_name_in_distributor_certificate'

적용 대상: SQL Server 2025(17.x) 이상 버전.

IP 주소 또는 DNS 별칭을 배포자 이름으로 사용하는 경우와 같이 배포자 이름과 다른 경우 배포자 인증서의 호스트 이름을 지정합니다. 인증서의 호스트 이름이 배포자 이름과 일치하는 경우 @host_name_in_distributor_certificate 매개 변수를 비워 둡니다. @host_name_in_distributor_certificate 문자열 값의 nvarchar(255) 이며 기본값은 .입니다 NULL.

반환 코드 값

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

설명

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

예제

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

자체 서명된 인증서를 신뢰하도록 배포자 구성

OLEDB 19 공급자의 보안 기본값을 재정의하고 배포자가 자체 서명된 인증서를 신뢰하도록 설정 trust_distributor_certificate=yes 하려면 다음 예제를 사용합니다.

EXECUTE sys.sp_adddistributor @trust_distributor_certificate = 'yes';

참고 항목

보안 기본값은 보안을 향상시키는 기본 OLEDB 공급자 19와 관련이 있습니다. 기본값을 재정의하는 옵션은 신뢰할 수 있는 인증서를 사용하도록 인스턴스를 구성하는 것보다 안전하지 않습니다. 기본값을 재정의한 후 인증서를 사용하도록 SQL Server를 구성한 다음 sp_changedistributor_property 저장 프로시저를 사용하여 속성을 다시 보안 기본값으로 설정하는 trust_distributor_certificate=no 옵션이 있습니다.

자세한 내용은 SQL Server 2025의 원격 배포자 변경 사항을 검토해 보세요.

사용 권한

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