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는 트래픽이 불규칙한 환경에 적합
편집 안내 · Editorial Note
이 가이드는 AI 도구를 활용해 초안을 구성하고 사람이 명령어·문맥을 검토해 발행했습니다. 운영체제와 도구 버전에 따라 결과가 달라질 수 있으므로 적용 전 공식 문서를 함께 확인하세요. 오류를 발견하시면 이메일로 제보해 주세요.
질문 & 답변 (Q&A)
이 가이드에 대해 궁금한 점을 질문해보세요. 확인 후 답변드립니다.