게시자 및 배포자 속성 보기 및 수정

적용 대상:SQL ServerAzure SQL Managed Instance

이 항목에서는 SQL Server Management Studio, Transact-SQL 또는 RMO(복제 관리 개체)를 사용하여 SQL Server에서 배포자 및 게시자 속성을 보고 수정하는 방법을 설명합니다.

항목 내용

시작하기 전에

권장 사항

  • Microsoft SQL Server 2005(9.x) 이전 버전을 실행하는 게시자의 경우 sysadmin 고정 서버 역할의 사용자가 구독자 페이지에 구독자를 등록할 수 있습니다. SQL Server 2005(9.x)부터는 더 이상 복제본(replica) 구독자를 명시적으로 등록할 필요가 없습니다.

보안

가능한 경우 런타임 시 사용자에게 보안 자격 증명을 입력하라는 메시지가 표시됩니다.

SQL Server Management Studio 사용

배포자 속성을 보고 수정하려면

  1. SQL Server Management Studio의 배포자에 커넥트 서버 노드를 확장합니다.

  2. 복제 폴더를 마우스 오른쪽 단추로 클릭한 다음 배포자 속성을 클릭합니다.

  3. 배포자 속성 - <배포자> 대화 상자에서 속성을 보고 수정합니다.

    • 배포 데이터베이스의 속성을 보고 수정하려면 대화 상자의 일반 페이지에서 해당 데이터베이스에 대한 속성 단추(...)를 클릭합니다.

    • 배포자와 연결된 게시자 속성을 보고 수정하려면 대화 상자의 게시자 페이지에서 게시자에 대한 속성 단추(...)를 클릭합니다.

    • 복제본(replica) 에이전트의 프로필에 액세스하려면 대화 상자의 일반 페이지에서 프로필 기본값 단추를 클릭합니다. 자세한 내용은 복제 에이전트 프로필을 참조 하세요.

    • 관리 저장 프로시저가 게시자에서 실행되고 배포자에서 정보를 업데이트할 때 사용되는 계정의 암호를 변경하려면 대화 상자의 게시자 페이지에서 암호암호 확인 상자에 새 암호를 입력합니다. 자세한 내용은 배포자 보안을 참조하세요.

  4. 필요한 경우 속성을 수정한 다음 확인을 클릭합니다.

게시자 속성을 보고 수정하려면

  1. SQL Server Management Studio에서 게시자에 커넥트 서버 노드를 확장합니다.

  2. 복제 폴더를 마우스 오른쪽 단추로 클릭한 다음 게시자 속성을 클릭합니다.

  3. 게시자 속성 - < 게시자>대화 상자에서 속성을 보고 수정합니다.

    • sysadmin 고정 서버 역할의 사용자는 게시 데이터베이스 페이지에서 데이터베이스를 복제본(replica)할 수 있습니다. 데이터베이스를 설정한다고 해서 그 데이터베이스가 게시되는 것은 아닙니다. 데이터베이스를 설정하면 설정된 데이터베이스에 대한 db_owner 고정 데이터베이스 역할의 사용자가 그 데이터베이스에 하나 이상의 게시를 만들 수 있습니다.
  4. 필요한 경우 속성을 수정한 다음 확인을 클릭합니다.

Transact-SQL 사용

게시자 및 배포자 속성은 복제본(replica)tion 저장 프로시저를 사용하여 프로그래밍 방식으로 볼 수 있습니다.

배포자 및 배포 데이터베이스 속성을 보려면

  1. sp_helpdistributor 실행하여 배포자, 배포 데이터베이스 및 작업 디렉터리에 대한 정보를 반환합니다.

  2. 지정한 배포 데이터베이스에 대한 속성을 반환하려면 sp_helpdistributiondb 를 실행합니다.

배포자 및 배포 데이터베이스 속성을 변경하려면

  1. 배포자 속성을 수정하려면 배포자에서 sp_changedistributor_property 를 실행합니다.

  2. 배포자에서 sp_changedistributiondb 실행하여 배포 데이터베이스 속성을 수정합니다.

  3. 배포자에서 sp_changedistributor_password 실행하여 배포자 암호를 변경합니다.

    Important

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

  4. 배포자에서 sp_changedistpublisher 실행하여 배포자를 사용하여 게시자의 속성을 변경합니다.

예제(Transact-SQL)

다음 예제 Transact-SQL 스크립트는 배포자 및 배포 데이터베이스에 대한 정보를 반환합니다.

-- View information about the Distributor, distribution database, 
-- working directory, and SQL Server Agent user account. 
USE master
EXEC sp_helpdistributor;
GO
-- View information about the specified distribution database. 
USE distribution
EXEC sp_helpdistributiondb;
GO

다음은 배포자에 대한 보존 기간, 배포자에 연결할 때 사용되는 암호 및 배포자에서 다양한 복제본(replica)tion 에이전트의 상태 검사 간격(하트비트 간격이라고도 함)을 변경하는 예제입니다.

Important

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


-- Change the heartbeat interval at the Distributor to 5 minutes. 
USE master 
exec sp_changedistributor_property 
    @property = N'heartbeat_interval', 
    @value = 5;
GO
DECLARE @distributionDB AS sysname;
SET @distributionDB = N'distribution';

-- Change the history retention period to 24 hours and the
-- maximum retention period to 48 hours.  
USE distribution
EXEC sp_changedistributiondb @distributionDB, N'history_retention', 24
EXEC sp_changedistributiondb @distributionDB, N'max_distretention', 48
GO
-- Change the password on the Distributor. 
-- To avoid storing the password in the script file, the value is passed 
-- into SQLCMD as a scripting variable. 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".
USE master
EXEC sp_changedistributor_password $(Password)
GO

RMO(복제 관리 개체) 사용

배포자 속성을 보고 수정하려면

  1. ServerConnection 클래스를 사용하여 배포자 연결을 만듭니다.

  2. ReplicationServer 클래스의 인스턴스를 만듭니다. 1단계에서 만든 ServerConnection 개체를 전달합니다.

  3. (선택 사항) IsDistributor 속성을 확인하여 현재 연결된 서버가 배포자인지 확인합니다.

  4. 메서드를 Load 호출하여 서버에서 속성을 가져옵니다.

  5. (선택 사항) 속성을 변경하려면 개체에 설정할 수 있는 하나 이상의 배포자 속성에 대해 ReplicationServer 새 값을 설정합니다.

  6. (선택 사항) 개체의 CachePropertyChanges 속성 ReplicationServer 이 true설정된 경우 메서드를 CommitPropertyChanges 호출하여 변경 내용을 서버에 커밋합니다.

배포 데이터베이스 속성을 보고 수정하려면

  1. ServerConnection 클래스를 사용하여 배포자 연결을 만듭니다.

  2. DistributionDatabase 클래스의 인스턴스를 만듭니다. 이름 속성을 지정하고 1단계에서 개체를 ServerConnection 전달합니다.

  3. 메서드를 LoadProperties 호출하여 서버에서 속성을 가져옵니다. 이 메서드가 false를 반환하는 경우 지정된 이름의 데이터베이스가 서버에 없는 것입니다.

  4. (선택 사항) 속성을 변경하려면 설정할 수 있는 속성 중 DistributionDatabase 하나에 대해 새 값을 설정합니다.

  5. (선택 사항) 개체의 CachePropertyChanges 속성 DistributionDatabase 이 true설정된 경우 메서드를 CommitPropertyChanges 호출하여 변경 내용을 서버에 커밋합니다.

게시자 속성을 보고 수정하려면

  1. ServerConnection 클래스를 사용하여 게시자 연결을 만듭니다.

  2. DistributionPublisher 클래스의 인스턴스를 만듭니다. Name 속성을 지정하고 1단계에서 개체를 ServerConnection 전달합니다.

  3. (선택 사항) 속성을 변경하려면 설정할 수 있는 속성 중 DistributionPublisher 하나에 대해 새 값을 설정합니다.

  4. (선택 사항) 개체의 CachePropertyChanges 속성 DistributionPublisher 이 true설정된 경우 메서드를 CommitPropertyChanges 호출하여 변경 내용을 서버에 커밋합니다.

관리자 연결의 암호를 게시자에서 배포자로 변경하려면

  1. ServerConnection 클래스를 사용하여 배포자 연결을 만듭니다.

  2. ReplicationServer 클래스의 인스턴스를 만듭니다.

  3. ConnectionContext 속성을 1단계에서 만든 연결로 설정합니다.

  4. Load 메서드를 호출하여 개체 속성을 가져옵니다.

  5. ChangeDistributorPassword 메서드를 호출합니다. 암호 매개 변수에 대한 새 암호 값을 전달합니다 .

    Important

    가능한 경우 런타임 시 사용자에게 보안 자격 증명을 입력하라는 메시지가 표시됩니다. 자격 증명을 저장해야 하는 경우 Microsoft Windows .NET Framework에서 제공하는 암호화 서비스를 사용합니다.

  6. (옵션) 다음 단계를 수행하여 이 배포자를 사용하는 각 원격 게시자에서 암호를 변경합니다.

    1. ServerConnection 클래스를 사용하여 게시자 연결을 만듭니다.

    2. ReplicationServer 클래스의 인스턴스를 만듭니다.

    3. ConnectionContext 속성을 6a단계에서 만든 연결로 설정합니다.

    4. Load 메서드를 호출하여 개체 속성을 가져옵니다.

    5. ChangeDistributorPassword 메서드를 호출합니다. 암호 매개 변수에 대해 5단계의 새 암호 값을 전달합니다 .

예제(RMO)

이 예에서는 배포 및 배포 데이터베이스 속성을 변경하는 방법을 보여 줍니다.

Important

자격 증명을 코드에 저장하지 않도록 런타임에 새 배포자 암호가 제공됩니다.

// Set the Distributor and distribution database names.
string distributionDbName = "distribution";
string distributorName = publisherInstance;

ReplicationServer distributor;
DistributionDatabase distributionDb;

// Create a connection to the Distributor using Windows Authentication.
ServerConnection conn = new ServerConnection(distributorName);

try
{
    // Open the connection. 
    conn.Connect();

    distributor = new ReplicationServer(conn);

    // Load Distributor properties, if it is installed.
    if (distributor.LoadProperties())
    {
        // Password supplied at runtime.
        distributor.ChangeDistributorPassword(password);
        distributor.AgentCheckupInterval = 5;

        // Save changes to the Distributor properties.
        distributor.CommitPropertyChanges();
    }
    else
    {
        throw new ApplicationException(
            String.Format("{0} is not a Distributor.", publisherInstance));
    }

    // Create an object for the distribution database 
    // using the open Distributor connection.
    distributionDb = new DistributionDatabase(distributionDbName, conn);

    // Change distribution database properties.
    if (distributionDb.LoadProperties())
    {
        // Change maximum retention period to 48 hours and history retention 
        // period to 24 hours.
        distributionDb.MaxDistributionRetention = 48;
        distributionDb.HistoryRetention = 24;

        // Save changes to the distribution database properties.
        distributionDb.CommitPropertyChanges();
    }
    else
    {
        // Do something here if the distribution database does not exist.
    }
}
catch (Exception ex)
{
    // Implement the appropriate error handling here. 
    throw new ApplicationException("An error occurred when changing Distributor " +
        " or distribution database properties.", ex);
}
finally
{
    conn.Disconnect();
}
' Set the Distributor and distribution database names.
Dim distributionDbName As String = "distribution"
Dim distributorName As String = publisherInstance

Dim distributor As ReplicationServer
Dim distributionDb As DistributionDatabase

' Create a connection to the Distributor using Windows Authentication.
Dim conn As ServerConnection = New ServerConnection(distributorName)

Try
    ' Open the connection. 
    conn.Connect()

    distributor = New ReplicationServer(conn)

    ' Load Distributor properties, if it is installed.
    If distributor.LoadProperties() Then
        ' Password supplied at runtime.
        distributor.ChangeDistributorPassword(password)
        distributor.AgentCheckupInterval = 5

        ' Save changes to the Distributor properties.
        distributor.CommitPropertyChanges()
    Else
        Throw New ApplicationException( _
            String.Format("{0} is not a Distributor.", publisherInstance))
    End If

    ' Create an object for the distribution database 
    ' using the open Distributor connection.
    distributionDb = New DistributionDatabase(distributionDbName, conn)

    ' Change distribution database properties.
    If distributionDb.LoadProperties() Then
        ' Change maximum retention period to 48 hours and history retention 
        ' period to 24 hours.
        distributionDb.MaxDistributionRetention = 48
        distributionDb.HistoryRetention = 24

        ' Save changes to the distribution database properties.
        distributionDb.CommitPropertyChanges()
    Else
        ' Do something here if the distribution database does not exist.
    End If
Catch ex As Exception
    ' Implement the appropriate error handling here. 
    Throw New ApplicationException("An error occurred when changing Distributor " + _
        " or distribution database properties.", ex)
Finally
    conn.Disconnect()
End Try

참고 항목

Replication Management Objects Concepts
게시 및 배포 해제
배포 구성
Replication Management Objects Concepts
배포자 및 게시자 정보 스크립트
Replication System Stored Procedures Concepts
게시자에 대한 정보 보기 및 작업 수행(복제 모니터)