sp_adddistpublisher(Transact-SQL)

적용 대상:SQL ServerAzure SQL Managed Instance

지정된 배포 데이터베이스를 사용하도록 게시자를 구성합니다. 이 저장 프로시저는 모든 데이터베이스의 배포자에서 실행됩니다. 저장 프로시저 sp_adddistributor(Transact-SQL)sp_adddistributiondb(Transact-SQL) 는 이 저장 프로시저를 사용하기 전에 실행되어야 합니다.

Transact-SQL 구문 표기 규칙

구문

sp_adddistpublisher
    [ @publisher = ] N'publisher'
    , [ @distribution_db = ] N'distribution_db'
    [ , [ @security_mode = ] security_mode ]
    [ , [ @login = ] N'login' ]
    [ , [ @password = ] N'password' ]
    [ , [ @working_directory = ] N'working_directory' ]
    [ , [ @trusted = ] N'trusted' ]
    [ , [ @encrypted_password = ] encrypted_password ]
    [ , [ @thirdparty_flag = ] thirdparty_flag ]
    [ , [ @publisher_type = ] N'publisher_type' ]
    [ , [ @storage_connection_string = ] N'storage_connection_string' ]
[ ; ]

인수

[ @publisher = ] N'publisher'

게시자 이름입니다. @publisher 기본값이 없는 sysname입니다.

참고 항목

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

[ @distribution_db = ] N'distribution_db'

배포 데이터베이스의 이름입니다. @distribution_db sysname이며 기본값은 없습니다. 이 매개 변수는 복제본(replica) 에이전트에서 게시자에 연결하는 데 사용됩니다.

[ @security_mode = ] security_mode

구현된 보안 모드입니다. 이 매개 변수는 복제본(replica) 에이전트가 지연 업데이트 구독 또는 SQL Server 이외 게시자를 사용하여 게시자에 연결하는 데만 사용됩니다. @security_mode int이며 이러한 값 중 하나일 수 있습니다.

설명
0 배포자의 복제 에이전트는 SQL Server 인증을 사용하여 게시자에 연결합니다.
1 (기본값) 배포자의 복제 에이전트는 Windows 인증을 사용하여 게시자에 연결합니다.

[ @login = ] N'login'

로그인입니다. 이 매개 변수는 security_mode0경우 필요합니다. @login sysname이며 기본값은 .입니다NULL. 이 매개 변수는 복제본(replica) 에이전트에서 게시자에 연결하는 데 사용됩니다.

[ @password = ] N'password'

암호입니다. @password sysname이며 기본값은 .입니다NULL. 이 매개 변수는 복제본(replica) 에이전트에서 게시자에 연결하는 데 사용됩니다.

Important

빈 암호를 사용하지 마세요. 강력한 암호를 사용하세요.

[ @working_directory = ] N'working_directory'

게시할 데이터 및 스키마 파일을 저장하기 위해 사용하는 작업 디렉터리의 이름입니다. @working_directory nvarchar(255)이며, 기본적으로 이 SQL Server 인스턴스의 폴더로 설정 ReplData 됩니다. 예: C:\Program Files\Microsoft SQL Server\MSSQL\MSSQL.1\ReplData. 이름은 UNC 형식으로 지정해야 합니다.

Azure SQL Database의 경우 .\\<storage_account>.file.core.windows.net\<share>

[ @trusted = ] N'trusted'

@trusted 사용되지 않으며 이전 버전과의 호환성을 위해서만 제공됩니다. @trusted 기본값false인 nvarchar(5)입니다. 이 매개 변수를 오류로만 설정하면 오류가 false 발생합니다.

[ @encrypted_password = ] encrypted_password

이 매개 변수 설정은 더 이상 지원되지 않습니다. @encrypted_password 비트이며 기본값은 .입니다0. 이 매개 변수를 설정하면 1 오류가 발생합니다.

[ @thirdparty_flag = ] thirdparty_flag

게시자가 SQL Server인 경우를 지정합니다. @thirdparty_flag 비트이며 다음 값 중 하나일 수 있습니다.

설명
0(기본값) SQL Server 데이터베이스.
1 SQL Server 이외의 데이터베이스입니다.

[ @publisher_type = ] N'publisher_type'

게시자가 SQL Server가 아닌 경우 게시자 유형을 지정합니다. @publisher_type sysname이며 다음 값 중 하나일 수 있습니다.

설명
MSSQLSERVER(기본값) SQL Server 게시자를 지정합니다.
ORACLE 표준 Oracle 게시자를 지정합니다.
ORACLE GATEWAY Oracle Gateway 게시자를 지정합니다.

Oracle 게시자와 Oracle 게이트웨이 게시자의 차이점에 대한 자세한 내용은 Oracle 게시자 구성을 참조하세요.

[ @storage_connection_string = ] N'storage_connection_string'

Azure SQL Database에 필요합니다. @storage_connection_string 기본값NULL인 nvarchar(255)입니다. Azure Portal의 Storage > 설정 액세스 키를 사용합니다.

참고 항목

Azure SQL Database의 게시자 및 배포자 데이터베이스에는 SQL Managed Instance가 필요합니다. 자세한 내용은 Azure SQL Database를 사용한 복제를 참조 하세요.

반환 코드 값

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

설명

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

예제

-- 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_adddistpublisher수 있습니다.