PostgreSQL 대화형 터미널(psql)을 사용하여 Aurora DSQL에 액세스
AWS CloudShell을 사용하여 PostgreSQL 대화형 터미널(psql)에서 Aurora DSQL에 액세스
다음 절차에 따라에서 PostgreSQL 대화형 터미널을 사용하여 AWS CloudShell에서 Aurora DSQL에 액세스합니다. 자세한 내용은 AWS CloudShell란 무엇인가요?를 참조하세요.
AWS CloudShell을 사용하여 연결
-
Aurora DSQL 콘솔
에 로그인합니다. -
CloudShell에서 열려는 클러스터를 선택합니다. 클러스터를 아직 생성하지 않은 경우 1단계: Aurora DSQL 단일 리전 클러스터 생성 또는 다중 리전 클러스터 생성의 단계를 따릅니다.
-
쿼리 편집기로 연결을 선택한 다음 CloudShell로 연결을 선택합니다.
-
admin으로 연결할지, 아니면 사용자 지정 데이터베이스 역할로 연결할지를 선택합니다.
-
CloudShell에서 시작을 선택하고 다음 CloudShell 대화 상자에서 실행을 선택합니다.
로컬 CLI를 사용하여 PostgreSQL 대화형 터미널(psql)을 사용하여 Aurora DSQL에 액세스
터미널 기반 프런트 엔드에서 PostgreSQL 유틸리티인 psql을 사용하여 쿼리에 대화식으로 입력하고, PostgreSQL에 발급하고, 쿼리 결과를 볼 수 있습니다.
참고
쿼리 응답 시간을 개선하려면 PostgreSQL 버전 17 클라이언트를 사용합니다. 다른 환경에서 CLI를 사용하는 경우 Python 버전 3.8+ 및 psql 버전 14+를 수동으로 설정해야 합니다.
PostgreSQL Downloadspsql에 대한 자세한 내용은 PostgreSQL 웹 사이트의 PostgreSQL 클라이언트 애플리케이션
AWS CLI가 이미 설치되어 있는 경우 다음 예시를 사용하여 클러스터에 연결합니다.
# Aurora DSQL requires a valid IAM token as the password when connecting. # Aurora DSQL provides tools for this and here we're using Python. export PGPASSWORD=$(aws dsql generate-db-connect-admin-auth-token \ --regionus-east-1\ --expires-in 3600 \ --hostnameyour_cluster_endpoint) # Aurora DSQL requires SSL and will reject your connection without it. export PGSSLMODE=require # Connect with psql, which automatically uses the values set in PGPASSWORD and PGSSLMODE. # Quiet mode suppresses unnecessary warnings and chatty responses but still outputs errors. psql --quiet \ --username admin \ --dbname postgres \ --hostyour_cluster_endpoint