Amazon RDS 프록시를 사용하여 Amazon RDS for MySQL DB 인스턴스 또는 Aurora MySQL-Compatible DB 클러스터에 연결하려면 어떻게 해야 합니까?

3분 분량
0

Amazon Relational Database Service(Amazon RDS) Proxy를 사용하여 Amazon RDS for MySQL DB 인스턴스 또는 Amazon Aurora MySQL 호환 에디션 DB 클러스터에 연결하려고 합니다.

해결 방법

전제 조건: 프록시는 데이터베이스와 동일한 가상 프라이빗 클라우드(VPC)에 있어야 합니다. 데이터베이스에 공개적으로 액세스할 수 있도록 설정할 수 있지만 프록시에는 공개적으로 액세스할 수 없습니다.

프록시를 생성하여 DB 인스턴스에 연결

다음 단계를 완료하십시오.

  1. AWS Secrets Manager에서 데이터베이스 보안 인증을 생성합니다.
    참고: 시크릿을 생성할 때 데이터베이스와 동일한 사용자 이름과 암호를 사용하십시오.

  2. (선택 사항) AWS Identity and Access Management(IAM) 정책과 IAM 역할을 생성합니다.
    참고: Amazon RDS 프록시는 IAM 역할을 자동으로 생성합니다. 하지만 자체 IAM 역할을 생성할 수 있습니다.

  3. 프록시를 생성합니다.

  4. 다음 명령을 실행하여 프록시 엔드포인트에 연결할 수 있는지 확인합니다.

    nc -zv proxy_endpoint 3306

    참고: proxy_endpoint를 프록시 서버의 주소로 바꾸십시오. 프록시와 동일한 VPC에 있는 Amazon Elastic Compute Cloud(Amazon EC2) 머신에서만 앞의 명령을 실행합니다. 로컬 머신에서는 이 명령이 실행되지 않습니다.
    출력 예시:

    Connection to test-proxy.proxy-#############.eu-west-1.rds.amazonaws.com 3306 port [tcp/mysql] succeeded
  5. 다음 명령을 실행하여 프록시를 사용하여 RDS DB 인스턴스에 연결합니다.

    mysql -h proxy_endpoint -u username -p

    참고: proxy_endpoint를 프록시 서버의 주소로 바꾸십시오.
    출력 예시:

    Server version: 5.7.28-log
    
    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql>

(선택 사항) TLS/SSL 연결에서 프록시 사용

다음 단계를 완료하십시오.

  1. 프록시를 생성할 때 전송 계층 보안 필요를 켭니다. 기존 프록시를 수정할 수도 있습니다.
    참고: TLS/SSL 프로토콜을 사용하는 경우 프록시는 일반 텍스트 연결을 거부합니다.

  2. Amazon Trust Services에서 Amazon Root CA 1 트러스트 스토어 .pem 파일을 다운로드합니다.

    wget https://www.amazontrust.com/repository/AmazonRootCA1.pem
  3. 다음 명령을 실행하여 TLS/SSL을 사용하여 DB 인스턴스에 연결합니다.

    mysql -h test-proxy.proxy-#############.eu-west-1.rds.amazonaws.com -u admin --ssl-mode=REQUIRED --ssl-ca=AmazonRootCA1.pem -p

    또는 TLS/SSL VERIFY_IDENTITY 모드에서 다음 명령을 실행하여 DB 인스턴스에 연결할 수 있습니다.

    mysql -h test-proxy.proxy-#############.eu-west-1.rds.amazonaws.com -u admin --ssl-mode=VERIFY_IDENTITY --ssl-ca=AmazonRootCA1.pem -p

    참고: 프록시는 와일드카드 인증서를 사용합니다. MySQL 클라이언트를 사용하여 TLS/SSL VERIFY_IDENTITY 모드로 연결하는 경우 MySQL 8.0 호환 mysql 명령을 사용해야 합니다.
    출력 예제:

    Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 12659040
    Server version: 5.7.28-log
    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
    Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

관련 정보

RDS Proxy 문제 해결

Amazon RDS Proxy