

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# pglogical을 사용하여 Amazon EC2의 PostgreSQL에서 Amazon RDS for PostgreSQL로 마이그레이션합니다.
<a name="migrate-from-postgresql-on-amazon-ec2-to-amazon-rds-for-postgresql-using-pglogical"></a>

*Rajesh Madiwale, Amazon Web Services*

## 요약
<a name="migrate-from-postgresql-on-amazon-ec2-to-amazon-rds-for-postgresql-using-pglogical-summary"></a>

**이 패턴은 PostgreSQL pglogical** 확장 프로그램을 사용하여 PostgreSQL 데이터베이스(버전 9.5 이상)를 Amazon Elastic Compute Cloud(Amazon EC2)에서 PostgreSQL용 Amazon Relational Database Service(Amazon RDS)로 마이그레이션하는 단계를 설명합니다. Amazon RDS는 이제 PostgreSQL 버전 10의 pglogical 확장을 지원합니다.

## 사전 조건 및 제한 사항
<a name="migrate-from-postgresql-on-amazon-ec2-to-amazon-rds-for-postgresql-using-pglogical-prereqs"></a>

**사전 조건**
+ 적절한 유형의 Amazon RDS 인스턴스를 선택합니다. 자세한 내용은 [Amazon RDS 인스턴스 유형](https://aws.amazon.com/rds/instance-types/)을 참조하세요.
+ PostgreSQL의 소스 버전과 대상 버전이 동일한지 확인합니다.  
+ Amazon EC2에서 [**pglogical** 확장 프로그램을 PostgreSQL](https://github.com/2ndQuadrant/pglogical)과 함께 설치하고 통합합니다.

**제품 버전**
+ Amazon RDS에서 지원되는 기능을 포함한 Amazon RDS의 PostgreSQL 버전 10 이상입니다(AWS 설명서의 [Amazon RDS에서의 PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts) 참조). 이 패턴은 Amazon RDS에서 PostgreSQL 9.5를 PostgreSQL 버전 10으로 마이그레이션하여 테스트했지만, Amazon RDS의 PostgreSQL 이후 버전에도 적용됩니다.

## 아키텍처
<a name="migrate-from-postgresql-on-amazon-ec2-to-amazon-rds-for-postgresql-using-pglogical-architecture"></a>

**데이터 마이그레이션 아키텍처**

![\[Amazon RDS의 PostgreSQL에 대한 데이터 마이그레이션 아키텍처\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/images/pattern-img/29af3931-48de-499f-9c4b-e10a98e4bba5/images/5f5b906f-dc1a-49a5-ae3f-3e10ae854784.png)


## 도구
<a name="migrate-from-postgresql-on-amazon-ec2-to-amazon-rds-for-postgresql-using-pglogical-tools"></a>
+ [https://github.com/2ndQuadrant/pglogical](https://github.com/2ndQuadrant/pglogical) 확장 프로그램
+ PostgreSQL 네이티브 유틸리티: [https://www.postgresql.org/docs/9.5/app-pgdump.html](https://www.postgresql.org/docs/9.5/app-pgdump.html) 및 [https://www.postgresql.org/docs/9.6/app-pgrestore.html](https://www.postgresql.org/docs/9.6/app-pgrestore.html)

## 에픽
<a name="migrate-from-postgresql-on-amazon-ec2-to-amazon-rds-for-postgresql-using-pglogical-epics"></a>

### pglogical 확장 프로그램을 사용하여 데이터를 마이그레이션합니다.
<a name="migrate-data-by-using-the-pglogical-extension"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| Amazon RDS PostgreSQL DB 인스턴스를 생성합니다. | Amazon RDS에서 PostgreSQL DB 인스턴스를 설정합니다. 자세한 지침은 [Amazon RDS for PostgreSQL 설명서](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.CreatingConnecting.PostgreSQL.html)를 참조하세요. | DBA | 
| 소스 PostgreSQL 데이터베이스에서 스키마 덤프를 가져와 대상 PostgreSQL 데이터베이스로 복원합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/migrate-from-postgresql-on-amazon-ec2-to-amazon-rds-for-postgresql-using-pglogical.html) | DBA | 
| 논리적 디코딩을 사용 설정합니다. | Amazon RDS DB 파라미터 그룹의 `rds.logical_replication` 정적 파라미터를 1로 설정합니다. 자세한 지침은 [Amazon RDS 설명서](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.FeatureSupport.LogicalDecoding)를 참조하세요. | DBA | 
| 소스 및 대상 데이터베이스에 pglogical 확장 프로그램을 생성합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/migrate-from-postgresql-on-amazon-ec2-to-amazon-rds-for-postgresql-using-pglogical.html) | DBA | 
| 소스 PostgreSQL 데이터베이스에 게시자를 생성합니다. | 게시자를 만들려면 다음을 실행합니다.<pre>psql -d dbname -p 5432 <<EOF<br />SELECT pglogical.create_node( node_name := 'provider1', dsn := 'host=<ec2-endpoint> port=5432 dbname=source-dbname user=source-dbuser' );<br />EOF</pre> | DBA | 
| 복제 세트를 만들고, 테이블과 시퀀스를 추가합니다. | 소스 PostgreSQL 데이터베이스에 복제 세트를 생성하고 복제 세트에 테이블과 시퀀스를 추가하려면 다음을 실행합니다.<pre>psql -d dbname -p 5432 <<EOF<br />SELECT pglogical.replication_set_add_all_tables('default', '{public}'::text[],synchronize_data := true);<br />EOF</pre> | DBA | 
| 구독자를 생성합니다. | 대상 PostgreSQL 데이터베이스에 구독자를 생성하려면 다음을 실행합니다.<pre>psql -h <rds-endpoint> -d target-dbname -U target-dbuser  <<EOF<br />SELECT pglogical.create_node(<br />    node_name := 'subscriber1',<br />    dsn := 'host=<rds-endpoint> port=5432 dbname=target-dbname password=postgres user=target-dbuser'<br />);<br />EOF</pre> | DBA | 
| 구독을 생성합니다. | 대상 PostgreSQL 데이터베이스에서 구독을 생성하려면 다음을 실행합니다.<pre>psql -h <rds-endpoint> -d target -U postgres  <<EOF<br />SELECT pglogical.create_subscription(<br /> subscription_name := 'subscription1',<br /> replication_sets := array['default'],<br />    provider_dsn := 'host=<ec2-endpoint> port=5432 dbname=<source-dbname> password=<password> user=source-dbuser'<br />);</pre> | DBA | 

### 데이터 검증
<a name="validate-your-data"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 소스 및 대상 데이터베이스를 검사합니다. | 소스 및 대상 데이터베이스를 검사하여 데이터가 성공적으로 복제되고 있는지 확인합니다. 소스 및 대상 테이블에서 `select count(1)`를 사용하여 기본 검증을 수행할 수 있습니다. | DBA | 

## 관련 리소스
<a name="migrate-from-postgresql-on-amazon-ec2-to-amazon-rds-for-postgresql-using-pglogical-resources"></a>
+ [Amazon RDS](https://aws.amazon.com/rds/)
+ [Amazon RDS의 PostgreSQL에 대한 논리적 복제](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.FeatureSupport.LogicalReplication)(Amazon RDS 설명서)
+ [pglogical](https://github.com/2ndQuadrant/pglogical)(GitHub 리포지토리)
+ [pglogical의 한계](https://github.com/2ndQuadrant/pglogical#limitations-and-restrictions)(GitHub 리포지토리 README 파일)
+ [논리적 복제를 사용하여 PostgreSQL을 온프레미스 또는 Amazon EC2에서 Amazon RDS로 마이그레이션하기](https://aws.amazon.com/blogs/database/migrating-postgresql-from-on-premises-or-amazon-ec2-to-amazon-rds-using-logical-replication/)(AWS 데이터베이스 블로그)