Openflow Connector for SQL Server 설정¶
참고
This connector is subject to the Snowflake Connector Terms.
This topic describes how to set up the Openflow Connector for SQL Server.
증분 로드 프로세스에 대한 내용은 :doc:`증분 복제<incremental-replication>`를 참조하세요.
전제 조건¶
커넥터를 설정하기 전에 다음 전제 조건을 완료했는지 확인합니다.
Openflow Connector for SQL Server 정보 을 검토했는지 확인합니다.
지원되는 SQL 서버 버전 을 검토했는지 확인합니다.
런타임 배포를 설정했는지 확인합니다. 자세한 내용은 다음 항목을 참조하십시오.
If you use Openflow - Snowflake Deployments, ensure that you have reviewed configuring required domains and have granted access to the required domains for the SQL 서버 connector.
Set up your SQL Server instance¶
커넥터를 설정하기 전에 SQL Server 환경에서 다음 작업을 수행합니다.
참고
이러한 작업은 데이터베이스 관리자로 수행해야 합니다.
Enable change tracking on the databases and tables that you plan to replicate, as shown in the following SQL Server example:
ALTER DATABASE <database> SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON); ALTER TABLE <schema>.<table> ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON);
참고
복제하려는 모든 데이터베이스와 테이블에 대해 이러한 명령을 실행합니다.
커넥터를 사용하려면 복제를 시작하기 전에 데이터베이스와 테이블에서 변경 내용 추적을 활성화해야 합니다. 복제하려는 모든 테이블에서 변경 내용 추적이 활성화되어 있는지 확인합니다. 커넥터가 실행되는 동안 추가 테이블에서 변경 내용 추적을 활성화할 수도 있습니다.
SQL Server 인스턴스에 대한 로그인을 생성합니다.
CREATE LOGIN <user_name> WITH PASSWORD = '<password>';
이 로그인은 복제하려는 데이터베이스의 사용자를 생성하는 데 사용됩니다.
각 데이터베이스의 SQL Server 명령을 실행하여 복제 중인 각 데이터베이스에 대한 사용자를 생성합니다.
USE <source_database>; CREATE USER <user_name> FOR LOGIN <user_name>;
복제 중인 각 데이터베이스에 대한 SELECT 및 VIEW CHANGE TRACKING 권한을 사용자에게 부여합니다.
GRANT SELECT ON <database>.<schema>.<table> TO <user_name>; GRANT VIEW CHANGE TRACKING ON <database>.<schema>.<table> TO <user_name>;
복제하려는 모든 테이블에 대해 각 데이터베이스에서 이러한 명령을 실행합니다. 이러한 권한은 이전 단계에서 생성한 각 데이터베이스의 사용자에게 부여되어야 합니다.
(Optional) Configure SSL connection.
If you use an SSL connection to connect SQL Server, create the root certificate for your database server. This is required when configuring the connector.
Snowflake 환경 설정하기¶
As a Snowflake administrator, perform the following tasks:
Snowflake에 대상 데이터베이스를 생성하여 복제된 데이터를 저장합니다.
CREATE DATABASE <destination_database>;
Snowflake :ref:`서비스 사용자<label-user-type-property>`를 생성합니다.
CREATE USER <openflow_user> TYPE = SERVICE COMMENT='Service user for automated access of Openflow';
커넥터에 대한 Snowflake 역할을 생성하고 필요한 권한을 부여합니다.
CREATE ROLE <openflow_role>; GRANT ROLE <openflow_role> TO USER <openflow_user>; GRANT USAGE ON DATABASE <destination_database> TO ROLE <openflow_role>; GRANT CREATE SCHEMA ON DATABASE <destination_database> TO ROLE <openflow_role>;
이 역할을 사용하여 Snowflake 데이터베이스에 대한 커넥터의 액세스를 관리합니다.
대상 데이터베이스에 오브젝트를 생성하려면 액세스를 관리하는 데 사용되는 역할에 데이터베이스에 대한 :ref:`USAGE 및 CREATE SCHEMA 권한<label-database_privileges>`을 부여해야 합니다.
커넥터에 대한 Snowflake 웨어하우스를 생성하고 필요한 권한을 부여합니다.
CREATE WAREHOUSE <openflow_warehouse> WITH WAREHOUSE_SIZE = 'MEDIUM' AUTO_SUSPEND = 300 AUTO_RESUME = TRUE; GRANT USAGE, OPERATE ON WAREHOUSE <openflow_warehouse> TO ROLE <openflow_role>;
Snowflake recommends starting with a MEDIUM warehouse size, then experimenting with size depending on the number of tables being replicated and the amount of data transferred. Large numbers of tables typically scale better with multi-cluster warehouses, rather than a larger warehouse size. For more information, see multi-cluster warehouses.
Set up the public and private keys for key pair authentication:
한 쌍의 보안 키(공개 및 비공개)를 생성합니다.
Store the private key for the user in a file to supply to the connector’s configuration.
Snowflake 서비스 사용자에게 공개 키를 할당합니다.
ALTER USER <openflow_user> SET RSA_PUBLIC_KEY = 'thekey';
자세한 내용은 키 페어 인증 및 키 페어 순환 섹션을 참조하십시오.
커넥터 구성¶
As a data engineer, install and configure the connector using the following sections.
커넥터 설치하기¶
Navigate to the Openflow overview page. In the Featured connectors section, select View more connectors.
Openflow Connector 페이지에서 커넥터를 찾아 Add to runtime 을 선택합니다.
In the Select runtime dialog, select your runtime from the Available runtimes drop-down list and click Add.
참고
커넥터를 설치하기 전에 커넥터가 수집한 데이터를 저장할 수 있도록 Snowflake에서 데이터베이스와 스키마를 생성했는지 확인하십시오.
Snowflake 계정 자격 증명으로 배포를 인증하고 런타임 애플리케이션이 Snowflake 계정에 액세스할 수 있도록 허용할지 묻는 메시지가 표시되면 Allow 를 선택합니다. 커넥터 설치 프로세스를 완료하는 데 몇 분 정도 걸립니다.
Snowflake 계정 자격 증명으로 런타임에 인증합니다.
커넥터 프로세스 그룹이 추가된 Openflow 캔버스가 표시됩니다.
커넥터 구성¶
To configure the connector, perform the following steps:
가져온 프로세스 그룹을 마우스 오른쪽 버튼으로 클릭하고 :ui:`Parameters`를 선택합니다.
Populate the required parameter values as described in 플로우 매개 변수.
플로우 매개 변수¶
Start by setting the parameters of the SQLServer Source Parameters context, then the SQLServer Destination Parameters context. After you complete this, enable the connector. The connector connects to both SQLServer and Snowflake and starts running. However, the connector does not replicate any data until any tables to be replicated are explicitly added to its configuration.
복제를 위해 특정 테이블을 구성하려면 SQLServer 수집 매개 변수 컨텍스트를 편집합니다. SQLServer 수집 매개 변수 컨텍스트에 변경 사항을 적용하면 커넥터에 의해 구성이 선택되고 모든 테이블에 대해 복제 수명 주기가 시작됩니다.
SQLServer 소스 매개 변수 컨텍스트¶
매개 변수 |
설명 |
|---|---|
SQL 서버 연결 URL |
소스 데이터베이스에 대한 전체 JDBC URL. 예:
|
SQL 서버 JDBC 드라이버 |
Select the Reference asset checkbox to upload the SQL Server JDBC driver. |
SQL 서버 사용자 이름 |
The user name for the connector. |
SQL 서버 비밀번호 |
커넥터의 비밀번호입니다. |
SQLServer 대상 매개 변수 컨텍스트¶
매개 변수 |
설명 |
필수 |
|---|---|---|
대상 데이터베이스 |
The database where data is persisted. It must already exist in Snowflake. The name is case-sensitive. For unquoted identifiers, provide the name in uppercase. |
예 |
Snowflake Authentication Strategy |
사용하는 경우:
|
예 |
Snowflake 계정 식별자 |
사용하는 경우:
|
예 |
Snowflake Connection Strategy |
KEY_PAIR를 사용하는 경우 Snowflake에 연결하기 위한 전략을 지정합니다.
|
KEY_PAIR가 있는 BYOC에만 필요하며, 그렇지 않은 경우는 무시됩니다. |
Snowflake Object Identifier Resolution |
Snowflake에서 스키마, 테이블, 열 이름과 같은 소스 오브젝트 식별자를 저장하고 쿼리하는 방법을 지정합니다. 이 설정은 SQL 쿼리에서 큰따옴표를 사용해야 하는지 여부를 결정합니다. 옵션 1: 기본값으로, 대/소문자를 구분하지 않습니다(권장).
참고 데이터베이스 오브젝트 이름의 대문자와 소문자가 혼합되지 않을 것으로 예상되는 경우 이 옵션을 사용하는 것이 좋습니다. 중요 커넥터 수집이 시작된 후에는 이 설정을 변경하지 마세요. 수집이 시작된 후 이 설정을 변경하면 기존 수집이 중단됩니다. 이 설정을 변경해야 하는 경우 새 커넥터 인스턴스를 만드세요. 옵션 2: 대/소문자를 구분합니다.
참고 레거시 또는 호환성을 위해 소스의 대문자 및 소문자를 유지해야 하는 경우 이 옵션을 사용하는 것이 좋습니다. 예를 들어, 소스 데이터베이스에 |
예 |
Snowflake 개인 키 |
사용하는 경우:
|
아니요 |
Snowflake 개인 키 파일 |
사용하는 경우:
|
아니요 |
Snowflake 개인 키 비밀번호 |
사용하는 경우:
|
아니요 |
Snowflake 역할 |
사용하는 경우:
|
예 |
Snowflake 사용자 이름 |
사용하는 경우:
|
예 |
Snowflake 웨어하우스 |
쿼리 실행에 사용되는 Snowflake 웨어하우스입니다. |
예 |
SQLServer 수집 매개 변수 컨텍스트¶
매개 변수 |
설명 |
|---|---|
포함된 테이블 이름 |
A comma-separated list of source table paths, including their databases and schemas, for example:
|
포함된 테이블 Regex |
A regular expression to match against table paths, including database and schema names. Every path matching the expression is replicated, and new tables matching the pattern that are created later are also included automatically, for example:
|
필터 JSON |
A JSON containing a list of fully-qualified table names and a regex pattern for column names that should be included into replication. 다음 예제에는
|
작업 일정 CRON 병합하기 |
CRON 식은 저널에서 대상 테이블로의 병합 작업이 트리거되는 기간을 정의하는 식입니다. 연속 병합을 원하거나 웨어하우스 실행 시간을 제한하는 시간 예약을 하려면 예:
추가 정보 및 예제는 Quartz 설명서 의 cron 트리거 자습서를 참조하십시오. |
복제에 테이블을 제거했다가 다시 추가하기¶
To remove a table from replication, remove it from the Included Table Names or Included Table Regex parameters in the Replication Parameters context.
To re-add the table to replication later, first delete the corresponding destination table in Snowflake.
Afterward, add the table back to the Included Table Names or Included Table Regex parameters.
This ensures that the replication process starts fresh for the table.
이 접근법은 실패한 테이블 복제 시나리오에서 복구하는 데에도 사용할 수 있습니다.
테이블에서 열의 하위 집합 복제하기¶
The connector filters the data replicated per table to a subset of configured columns.
열에 필터를 적용하려면 복제 매개 변수 컨텍스트에서 열 필터 속성을 수정하여 필터를 적용하려는 모든 테이블에 대해 1개의 항목씩 구성 배열을 추가합니다.
Include or exclude columns by name or pattern. You can apply a single condition per table, or combine multiple conditions, with exclusions always taking precedence over inclusions.
다음 예제는 사용 가능한 필드를 보여줍니다. schema 및 table 필드는 필수 입력 사항입니다. included, excluded, includedPattern, excludedPattern 중 하나 이상이 필요합니다.
[
{
"schema": "<source table schema>",
"table" : "<source table name>",
"included": ["<column name>", "<column name>"],
"excluded": ["<column name>", "<column name>"],
"includedPattern": "<regular expression>",
"excludedPattern": "<regular expression>",
}
]
테이블의 데이터 변경 사항 추적¶
The connector replicates the current state of data from the source tables, as well as every state of every row from every changeset. This data is stored in journal tables created in the same schema as the destination table.
저널 테이블 이름은 ``<source table name>_JOURNAL_<timestamp>_<schema generation> 형식입니다. 여기서 <timestamp>는 소스 테이블이 복제본에 추가된 시점의 epoch 초 값이며, <schema generation>``은 소스 테이블에서 스키마가 변경될 때마다 증가하는 정수입니다. 결과적으로, 스키마가 변경되는 원본 테이블에는 여러 저널 테이블이 포함되게 됩니다.
When you remove a table from replication, then add it back, the <timestamp> value changes, and <schema generation> starts again from 1.
중요
Snowflake recommends not altering the structure of journal tables in any way. The connector uses them to update the destination table as part of the replication process.
The connector never drops journal tables, but uses the latest journal for every replicated source table, only reading append-only streams on top of journals. To reclaim the storage, you can:
언제든지 모든 저널 테이블을 자를 수 있습니다.
복제에서 제거된 원본 테이블과 관련된 저널 테이블을 삭제할 수 있습니다.
능동적으로 복제된 테이블에 대한 최신 세대 저널 테이블을 제외한 모든 저널 테이블을 삭제할 수 있습니다.
예를 들어, 커넥터가 소스 테이블 orders 를 적극적으로 복제하도록 설정되어 있고 이전에 테이블 customers 를 복제에서 제거한 경우 다음과 같은 저널 테이블이 있을 수 있습니다. 이 경우 orders_5678_2 를 제외하고 모두 삭제할 수 있습니다.
customers_1234_1
customers_1234_2
orders_5678_1
orders_5678_2
병합 작업 예약 구성하기¶
커넥터는 데이터 웨어하우스를 사용하여 변경 데이터 캡처(CDC) 데이터를 대상 테이블에 병합합니다. 이 작업은 MergeSnowflakeJournalTable 프로세서에 의해 트리거됩니다. 새로운 변경 사항이 없거나 MergeSnowflakeJournalTable 큐에 대기 중인 새 플로우 파일이 없는 경우 병합이 트리거되지 않고 웨어하우스가 자동 일시 중단됩니다.
Use the CRON expression in the Merge task Schedule CRON parameter to limit the warehouse cost and limit merges to only scheduled time. It throttles the flow files coming to the MergeSnowflakeJournalTable processor and merges are triggered only in a dedicated period of time. For more information about scheduling, see Scheduling strategy.
플로우 실행¶
평면을 마우스 오른쪽 버튼으로 클릭하고 Enable all Controller Services 를 선택합니다.
가져온 프로세스 그룹을 마우스 오른쪽 버튼으로 클릭하고 Start 를 선택합니다. 커넥터가 데이터 수집을 시작합니다.