홈/엔지니어/클라우드/AWS RDS 설정 가이드 — 인스턴스·파라미터·백…
클라우드중급awsrdspostgresql

AWS RDS 설정 가이드 — 인스턴스·파라미터·백업·스냅샷

RDS 인스턴스 생성, 보안그룹 설정, 파라미터 그룹 튜닝, 자동 백업과 스냅샷 관리, 읽기 전용 복제본 생성까지 실무 설정을 정리합니다.

목차
  1. RDS 인스턴스 생성 (CLI)
  2. 보안 그룹 설정
  3. 파라미터 그룹 튜닝
  4. 백업 및 스냅샷
  5. 읽기 전용 복제본 (Read Replica)
  6. 엔드포인트 확인 및 연결
  7. 비용 최적화 팁

RDS 인스턴스 생성 (CLI)

Bash
# PostgreSQL 인스턴스 생성
aws rds create-db-instance \
  --db-instance-identifier my-postgres \
  --db-instance-class db.t3.medium \
  --engine postgres \
  --engine-version 16.2 \
  --master-username admin \
  --master-user-password "SecurePass123!" \
  --allocated-storage 100 \
  --storage-type gp3 \
  --storage-encrypted \
  --vpc-security-group-ids sg-xxxxxxxx \
  --db-subnet-group-name my-subnet-group \
  --backup-retention-period 7 \
  --no-publicly-accessible \
  --multi-az \
  --deletion-protection

# 생성 상태 확인
aws rds describe-db-instances \
  --db-instance-identifier my-postgres \
  --query 'DBInstances[0].DBInstanceStatus'

보안 그룹 설정

RDS는 퍼블릭 접근을 차단하고 애플리케이션 서버의 보안 그룹에서만 접근을 허용합니다.

Bash
# RDS 보안 그룹 — 앱 서버 SG에서만 5432 허용
aws ec2 authorize-security-group-ingress \
  --group-id sg-rds-xxxxxx \
  --protocol tcp \
  --port 5432 \
  --source-group sg-app-xxxxxx

# 퍼블릭 접근 확인
aws rds describe-db-instances \
  --query 'DBInstances[0].PubliclyAccessible'

파라미터 그룹 튜닝

Bash
# 파라미터 그룹 생성
aws rds create-db-parameter-group \
  --db-parameter-group-name my-postgres16 \
  --db-parameter-group-family postgres16 \
  --description "Custom PostgreSQL 16 params"

# 파라미터 수정
aws rds modify-db-parameter-group \
  --db-parameter-group-name my-postgres16 \
  --parameters \
    "ParameterName=shared_buffers,ParameterValue={DBInstanceClassMemory/4},ApplyMethod=pending-reboot" \
    "ParameterName=log_min_duration_statement,ParameterValue=1000,ApplyMethod=immediate" \
    "ParameterName=max_connections,ParameterValue=200,ApplyMethod=pending-reboot"

# 인스턴스에 파라미터 그룹 적용
aws rds modify-db-instance \
  --db-instance-identifier my-postgres \
  --db-parameter-group-name my-postgres16 \
  --apply-immediately

백업 및 스냅샷

Bash
# 자동 백업 설정 확인
aws rds describe-db-instances \
  --db-instance-identifier my-postgres \
  --query 'DBInstances[0].{Backup:BackupRetentionPeriod,Window:PreferredBackupWindow}'

# 수동 스냅샷 생성
aws rds create-db-snapshot \
  --db-instance-identifier my-postgres \
  --db-snapshot-identifier my-postgres-snap-$(date +%Y%m%d)

# 스냅샷 목록
aws rds describe-db-snapshots \
  --db-instance-identifier my-postgres \
  --query 'DBSnapshots[*].[DBSnapshotIdentifier,SnapshotCreateTime,Status]' \
  --output table

# 스냅샷에서 복원
aws rds restore-db-instance-from-db-snapshot \
  --db-instance-identifier my-postgres-restored \
  --db-snapshot-identifier my-postgres-snap-20250527

읽기 전용 복제본 (Read Replica)

Bash
# 읽기 복제본 생성
aws rds create-db-instance-read-replica \
  --db-instance-identifier my-postgres-reader \
  --source-db-instance-identifier my-postgres \
  --db-instance-class db.t3.small

# 복제본 엔드포인트 확인
aws rds describe-db-instances \
  --db-instance-identifier my-postgres-reader \
  --query 'DBInstances[0].Endpoint'

엔드포인트 확인 및 연결

Bash
# 엔드포인트 조회
aws rds describe-db-instances \
  --db-instance-identifier my-postgres \
  --query 'DBInstances[0].Endpoint.Address' \
  --output text

# EC2에서 연결 테스트
psql -h my-postgres.xxxxxxxx.ap-northeast-2.rds.amazonaws.com \
  -U admin -d postgres -p 5432

비용 최적화 팁

  • 개발 환경은 db.t3.micro + 단일 AZ
  • 스토리지는 gp3 (gp2보다 저렴하고 성능 독립적)
  • 사용하지 않을 때는 RDS 인스턴스 중지 (최대 7일)
  • Aurora Serverless v2는 트래픽이 불규칙한 환경에 적합
#aws#rds#postgresql#mysql#데이터베이스#backup
편집 안내 · Editorial Note

AI 도구가 초안 작성에 사용될 수 있습니다. 명령어의 실행 여부와 검증 환경은 각 가이드에 기재된 근거를 확인하세요. 적용 전 사용 중인 버전의 공식 문서를 확인하고, 오류는 이메일로 알려주세요. 이메일로 제보

주제 관련 공식 문서(자동 연결 · 문장별 근거 아님)PostgreSQL 공식 문서 ↗MySQL 공식 매뉴얼 ↗AWS 공식 문서 ↗

질문 & 답변 (Q&A)

이 가이드에 대해 궁금한 점을 질문해보세요. 확인 후 답변드립니다.