InfoGrab Docs

AWS 데이터베이스 자동 검색

요약

Teleport는 AWS에서 호스팅되는 데이터베이스를 자동으로 검색하여 Teleport 클러스터에 등록하도록 구성할 수 있습니다. 이 가이드에서는 AWS 데이터베이스 자동 검색을 설정하는 방법을 보여줍니다. Teleport database auto-discovery involves two components:

Teleport는 AWS에서 호스팅되는 데이터베이스를 자동으로 검색하여 Teleport 클러스터에 등록하도록 구성할 수 있습니다.

이 가이드에서는 AWS 데이터베이스 자동 검색을 설정하는 방법을 보여줍니다.

작동 방식#

Teleport database auto-discovery involves two components:

  1. The Teleport Discovery Service that watches for new databases or changes to previously discovered databases. It dynamically registers each discovered database as a db resource in your Teleport cluster. It does not need connectivity to the databases it discovers.
  2. The Teleport Database Service that monitors the dynamic db resources registered by the Discovery Service. It proxies communications between users and the database.

사전 요구 사항#

  • A running Teleport cluster. If you want to get started with Teleport, sign up for a free trial or set up a demo environment.

  • The tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Determine the version of your Teleport cluster. The tctl and tsh clients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at /v1/webapi/find and use a JSON query tool to obtain your cluster version. Replace with the web address of your Teleport Proxy Service:

      $ TELEPORT_DOMAIN=
      $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')"
      
    2. Follow the instructions for your platform to install tctl and tsh clients:

  • IAM 정책을 생성하고 연결할 권한이 있는 AWS 계정.
  • Teleport 데이터베이스 서비스를 실행할 호스트.
  • Teleport 데이터베이스 서비스를 실행할 호스트.
  • AWS에서 호스팅되는 하나 이상의 데이터베이스.

1/8단계. Teleport 설치#

Teleport 검색 서비스와 Teleport 데이터베이스 서비스를 실행할 호스트에 Teleport를 설치합니다.

데이터베이스 서비스는 데이터베이스에 대한 네트워크 연결이 필요하지만 검색 서비스는 그렇지 않습니다.

To install a Teleport Agent on your Linux server:

The recommended installation method is the cluster install script. It will select the correct version, edition, and installation mode for your cluster.

  1. Assign to your Teleport cluster hostname and port, but not the scheme (https://).

  2. Run your cluster's install script:

    $ curl "https:///scripts/install.sh" | sudo bash
    

2/8단계. 검색 서비스 IAM 권한#

Grant the Discovery Service access to credentials that it can use to authenticate to AWS.

  • If you are running the Discovery Service on an EC2 instance, you may use the EC2 Instance Metadata Service method
  • If you are running the Discovery Service in Kubernetes, you can use IAM Roles for Service Accounts (IRSA)
  • Otherwise, you must use environment variables
Have multiple sources of AWS credentials?

Teleport's AWS client loads credentials from different sources in the following order:

  • Environment Variables
  • Shared credentials file
  • Shared configuration file (Teleport always enables shared configuration)
  • EC2 Instance Metadata (credentials only)

While you can provide AWS credentials via a shared credentials file or shared configuration file, you will need to run the Discovery Service with the AWS_PROFILE environment variable assigned to the name of your profile of choice.

If you have a specific use case that the instructions above do not account for, consult the documentation for the AWS SDK for Go for a detailed description of credential loading behavior.

AWS IAM 권한 부여#

검색 서비스 AWS IAM 역할에 다음 AWS IAM 권한을 연결합니다:

3/8단계. 검색 서비스 배포#

Teleport 구성 파일 생성#

데이터베이스 서비스를 실행할 호스트에 teleport.yaml 구성 파일을 생성합니다. discovery_group 값을 그대로 두거나 더 설명적인 이름으로 변경할 수 있습니다.

version: v3
teleport:
  join_params:
    token_name: "/tmp/token"
    method: token
  proxy_server: "



참여 토큰 생성#

The Discovery Service requires a valid join token to join your Teleport cluster. Run the following tctl command and save the token output in /tmp/token on the server that will run the Discovery Service:

$ tctl tokens add --type=discovery --format=text
(=presets.tokens.first=)
Alternative methods

For users with a lot of infrastructure in AWS, or who might create or recreate many instances, consider alternative methods for joining new EC2 instances running Teleport:

검색 서비스 시작#

Configure the Discovery Service to start automatically when the host boots up by creating a systemd service for it. The instructions depend on how you installed the Discovery Service.

You can check the status of the Discovery Service with systemctl status teleport and view its logs with journalctl -fu teleport.

4/8단계. 검색 그룹 구성#

tctl을 사용할 수 있는 호스트에 파일을 생성하고 저장합니다.

discovery_config를 생성합니다:

$ tctl create 

이전에 구성한 검색 서비스는 이 discovery_config와 동일한 discovery_group에 있으며, AWS 데이터베이스를 검색하기 위해 discovery_config를 사용하기 시작합니다. 데이터베이스를 검색하면 검색 서비스는 해당 데이터베이스를 Teleport 클러스터의 db 리소스로 등록합니다.

Info

Teleport db 리소스는 Teleport 데이터베이스 서비스가 데이터베이스에 대한 접근을 제공하는 데 사용할 수 있는 데이터베이스 사양을 나타냅니다. 데이터베이스 서비스 인스턴스가 레이블 선택기를 통해 db 리소스와 매칭되면, 클러스터에서 단기 db_server 리소스를 정기적으로 생성하여 데이터베이스를 하트비트하기 시작합니다. tsh db lstctl db ls와 같은 도구는 db_server 리소스만 표시합니다. 즉, 데이터베이스 서비스 인스턴스가 접근을 제공하는 데이터베이스만 표시됩니다.

5/8단계. 등록된 데이터베이스 목록 확인#

검색된 데이터베이스에 대한 접근을 제공하도록 데이터베이스 서비스를 설정하기 전에, 검색 서비스가 실제로 데이터베이스를 검색하고 있는지 확인해야 합니다.

tctl로 동적으로 등록된 데이터베이스를 나열할 수 있습니다. 검색 서비스는 Teleport 클러스터에 등록하는 모든 데이터베이스에 teleport.dev/origin: cloud 레이블을 추가합니다.

검색 서비스가 검색될 것으로 예상하는 데이터베이스에 대한 db 리소스를 등록했는지 확인합니다:

$ tctl get db

또는 특정 데이터베이스를 확인합니다:

$ tctl get db/<database-name>

검색된 것으로 생각하는 데이터베이스에 해당하는 db 리소스가 표시되지 않으면 검색 서비스 문제 해결을 참조하세요.

검색된 데이터베이스 이름 각 검색된 데이터베이스의 이름에는 고유성을 보장하기 위해 추가 식별 정보가 추가됩니다. 추가 정보에는 다음이 포함될 수 있습니다: - 엔드포인트 유형(예: "reader" 엔드포인트) - 매처 유형 - AWS 리전 - AWS 계정 ID.

예를 들어 "my-postgres"라는 RDS Aurora 데이터베이스가 AWS 계정 "123456789012"의 us-east-1 리전에서 검색되면 Teleport에서 "my-postgres-rds-aurora-us-east-1-123456789012"로 이름이 지정됩니다.

검색된 데이터베이스에는 AWS 데이터베이스 이름과 엔드포인트 유형으로만 구성된 짧은 표시 이름도 있습니다. 예를 들어 "my-postgres" 또는 "my-postgres-reader"입니다. tctltsh 명령에는 전체 이름이나 표시 이름을 사용할 수 있지만, 표시 이름이 모호한 경우 전체 이름을 사용해야 합니다.

AWS 데이터베이스 리소스에 TeleportDatabaseName AWS 태그를 적용하여 데이터베이스 이름을 재정의할 수 있습니다. 이 값이 db 이름으로 그대로 사용되므로 추가 식별 정보가 추가되지 않습니다.

6/8단계. 데이터베이스 서비스 IAM 권한#

Grant the Database Service access to credentials that it can use to authenticate to AWS.

  • If you are running the Database Service on an EC2 instance, you may use the EC2 Instance Metadata Service method
  • If you are running the Database Service in Kubernetes, you can use IAM Roles for Service Accounts (IRSA)
  • Otherwise, you must use environment variables
Have multiple sources of AWS credentials?

Teleport's AWS client loads credentials from different sources in the following order:

  • Environment Variables
  • Shared credentials file
  • Shared configuration file (Teleport always enables shared configuration)
  • EC2 Instance Metadata (credentials only)

While you can provide AWS credentials via a shared credentials file or shared configuration file, you will need to run the Database Service with the AWS_PROFILE environment variable assigned to the name of your profile of choice.

If you have a specific use case that the instructions above do not account for, consult the documentation for the AWS SDK for Go for a detailed description of credential loading behavior.

데이터베이스 서비스를 위한 AWS IAM 역할을 생성하고 다음 권한을 연결합니다:

7/8단계. 데이터베이스 서비스 배포#

데이터베이스 연결성 구성#

검색 서비스와 달리 데이터베이스 서비스는 Teleport 클러스터에 데이터베이스 접근을 제공하기 위해 데이터베이스에 대한 네트워크 연결이 있어야 합니다. 데이터베이스 서비스에 대한 여러 네트워크 도달성 요구 사항을 충족해야 합니다:

  1. 데이터베이스 서비스가 데이터베이스로의 네트워크 경로를 가짐
  2. 데이터베이스 서비스가 Teleport 클러스터로의 네트워크 경로를 가짐
  3. 데이터베이스 서비스 보안 그룹이 데이터베이스로의 아웃바운드 트래픽을 허용
  4. 데이터베이스 서비스 보안 그룹이 Teleport 클러스터로의 아웃바운드 트래픽을 허용
  5. 데이터베이스 보안 그룹이 데이터베이스 서비스로부터의 인바운드 트래픽을 허용

엄격한 보안 그룹이 연결된 프라이빗 서브넷에 데이터베이스가 배포된 경우, 일반적으로 동일한 VPC 내에, 가능하면 동일한 서브넷에 데이터베이스 서비스 인스턴스를 배포하고 데이터베이스가 인바운드 트래픽을 허용하는 보안 그룹을 연결해야 합니다. Teleport 데이터베이스 서비스는 Teleport 클러스터에 접근하기 위해 AWS NAT 게이트웨이 또는 인터넷 게이트웨이를 통해 공용 인터넷으로의 경로가 필요할 수 있습니다.

이는 특정 네트워킹 설정에 따라 달라지므로 모든 네트워크 요구 사항이나 제안을 포괄하는 목록이 아닙니다.

Teleport 구성 파일 생성#

데이터베이스 서비스를 실행할 호스트에 teleport.yaml 구성 파일을 생성합니다:

version: v3
teleport:
  join_params:
    token_name: "/tmp/token"
    method: token
  proxy_server: "

AWS 데이터베이스에 연결된 AWS 태그는 일부 다른 식별 메타데이터 외에 Teleport db 레이블로 가져옵니다. 사용 가능한 데이터베이스 레이블에 대한 자세한 내용은 데이터베이스 레이블 참조를 참조하세요.

참여 토큰 생성#

The Database Service requires a valid join token to join your Teleport cluster. Run the following tctl command and save the token output in /tmp/token on the server that will run the Database Service:

$ tctl tokens add --type=db --format=text
(=presets.tokens.first=)
Alternative methods

For users with a lot of infrastructure in AWS, or who might create or recreate many instances, consider alternative methods for joining new EC2 instances running Teleport:

데이터베이스 서비스 시작#

Configure the Database Service to start automatically when the host boots up by creating a systemd service for it. The instructions depend on how you installed the Database Service.

You can check the status of the Database Service with systemctl status teleport and view its logs with journalctl -fu teleport.

8/8단계. 데이터베이스 서버 목록 확인#

데이터베이스 서비스가 검색된 데이터베이스를 프록시하고 있는지 확인하려면 다음 tctl 명령을 실행합니다:

## 필요에 따라 쉼표로 구분된 필터링 레이블을 조정합니다
$ tctl db ls teleport.dev/origin=cloud,teleport.dev/cloud=AWS,region=,account-id="*"

예상한 데이터베이스가 표시되지 않으면 아래의 데이터베이스 서비스 문제 해결을 참조하세요.

Note

이 가이드는 검색 서비스와 데이터베이스 서비스를 사용하여 AWS 데이터베이스 자동 검색을 설정하는 방법을 보여주지만, 데이터베이스 사용자 프로비저닝은 다루지 않습니다.

검색된 데이터베이스에 Teleport를 통해 연결하려면 추가적인 Teleport RBAC 구성과 IAM 구성이 필요할 수 있습니다.

데이터베이스 사용자 프로비저닝 및 구성에 대한 정보는 AWS 데이터베이스 등록의 적절한 가이드를 참조하세요.

다음 단계#

  • Teleport 데이터베이스 서비스의 동적 등록에 대해 알아보기
  • 데이터베이스 연결을 시작하세요.
  • 외부 AWS 계정에서 AWS 데이터베이스를 연결하세요.
  • 데이터베이스 사용자 프로비저닝 및 구성에 대한 정보는 AWS 데이터베이스 등록의 적절한 가이드를 참조하세요.

문제 해결#

Discovery Service troubleshooting#

First, check if any databases have been discovered. To do this, you can use the tctl get db command and check if the expected databases have already been registered with your Teleport cluster.

If some databases do not appear in the list, check if the Discovery Service selector labels match the missing database tags or look into the Discovery Service logs for permission errors.

Check that the Discovery Service is running with credentials for the correct AWS account. It can discover resources in another AWS account, but it must be configured to assume a role in the other AWS account if that's the case.

Check if there is more than one Discovery Services running:

$ tctl inventory status --connected

If you are running multiple Discovery Services, you must ensure that each service is configured with the same discovery_group value if they are watching the same cloud databases or a different value if they are watching different cloud databases. If this is not configured correctly, a typical symptom is db resources being intermittently deleted from your Teleport cluster's registry.

Database Service troubleshooting#

Databases do not appear in tctl db ls#

If the tctl get db command returns the discovered databases you expect, but the tctl db ls command does not include them, check that you have set the db_service.resources section correctly, for example:

db_service:
  enabled: true
  resources:
  - labels:
      "env": "prod"

If the section is correctly configured, but databases still do not appear, check that you have the correct permissions to list databases in Teleport. You should have a Teleport role that matches the database labels and allows the "read" and "list" verbs for db and db_server objects. Here's an example that grants those permissions for every database in your cluster:

kind: role
version: v6
metadata:
  name: view-all-databases
spec:
  allow:
    db_labels:
      '*': '*'
    rules:
      - resources: [db_server, db]
        verbs: [read, list]

Errors when connecting to a database#

If there are connection errors when you try to connect to a database, then first check if there are multiple db_server heartbeat resources for the target database: tctl get db_server/yourDatabaseName. If there are, it means that multiple Teleport Database Service instances are proxying the database - this is an HA setup that will complicate troubleshooting. Teleport will choose one of those Database Service instances at random to proxy the connection and if one of them can't reach the database endpoint or lacks permissions, then you will see random connection errors.

Even if connection errors are consistent, you should scale down or reconfigure your Teleport Database Service instances such that only one matches the target db while you are troubleshooting errors. Verify that there is only one db_server with tctl get db_server/yourDatabaseName and then try the connection again.

Check the Teleport Database Service logs with DEBUG level logging enabled and look for network or permissions errors.

Refer to the Database Service troubleshooting guide for more general troubleshooting steps.

Additionally, a guide specific to the type of database in Enroll AWS Databases. may have more specific troubleshooting information.

AWS 데이터베이스 자동 검색

원문 보기
요약

Teleport는 AWS에서 호스팅되는 데이터베이스를 자동으로 검색하여 Teleport 클러스터에 등록하도록 구성할 수 있습니다. 이 가이드에서는 AWS 데이터베이스 자동 검색을 설정하는 방법을 보여줍니다. Teleport database auto-discovery involves two components:

Teleport는 AWS에서 호스팅되는 데이터베이스를 자동으로 검색하여 Teleport 클러스터에 등록하도록 구성할 수 있습니다.

이 가이드에서는 AWS 데이터베이스 자동 검색을 설정하는 방법을 보여줍니다.

작동 방식#

Teleport database auto-discovery involves two components:

  1. The Teleport Discovery Service that watches for new databases or changes to previously discovered databases. It dynamically registers each discovered database as a db resource in your Teleport cluster. It does not need connectivity to the databases it discovers.
  2. The Teleport Database Service that monitors the dynamic db resources registered by the Discovery Service. It proxies communications between users and the database.

사전 요구 사항#

  • A running Teleport cluster. If you want to get started with Teleport, sign up for a free trial or set up a demo environment.

  • The tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Determine the version of your Teleport cluster. The tctl and tsh clients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at /v1/webapi/find and use a JSON query tool to obtain your cluster version. Replace with the web address of your Teleport Proxy Service:

      $ TELEPORT_DOMAIN=
      $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')"
      
    2. Follow the instructions for your platform to install tctl and tsh clients:

  • IAM 정책을 생성하고 연결할 권한이 있는 AWS 계정.
  • Teleport 데이터베이스 서비스를 실행할 호스트.
  • Teleport 데이터베이스 서비스를 실행할 호스트.
  • AWS에서 호스팅되는 하나 이상의 데이터베이스.

1/8단계. Teleport 설치#

Teleport 검색 서비스와 Teleport 데이터베이스 서비스를 실행할 호스트에 Teleport를 설치합니다.

데이터베이스 서비스는 데이터베이스에 대한 네트워크 연결이 필요하지만 검색 서비스는 그렇지 않습니다.

To install a Teleport Agent on your Linux server:

The recommended installation method is the cluster install script. It will select the correct version, edition, and installation mode for your cluster.

  1. Assign to your Teleport cluster hostname and port, but not the scheme (https://).

  2. Run your cluster's install script:

    $ curl "https:///scripts/install.sh" | sudo bash
    

2/8단계. 검색 서비스 IAM 권한#

Grant the Discovery Service access to credentials that it can use to authenticate to AWS.

  • If you are running the Discovery Service on an EC2 instance, you may use the EC2 Instance Metadata Service method
  • If you are running the Discovery Service in Kubernetes, you can use IAM Roles for Service Accounts (IRSA)
  • Otherwise, you must use environment variables
Have multiple sources of AWS credentials?

Teleport's AWS client loads credentials from different sources in the following order:

  • Environment Variables
  • Shared credentials file
  • Shared configuration file (Teleport always enables shared configuration)
  • EC2 Instance Metadata (credentials only)

While you can provide AWS credentials via a shared credentials file or shared configuration file, you will need to run the Discovery Service with the AWS_PROFILE environment variable assigned to the name of your profile of choice.

If you have a specific use case that the instructions above do not account for, consult the documentation for the AWS SDK for Go for a detailed description of credential loading behavior.

AWS IAM 권한 부여#

검색 서비스 AWS IAM 역할에 다음 AWS IAM 권한을 연결합니다:

3/8단계. 검색 서비스 배포#

Teleport 구성 파일 생성#

데이터베이스 서비스를 실행할 호스트에 teleport.yaml 구성 파일을 생성합니다. discovery_group 값을 그대로 두거나 더 설명적인 이름으로 변경할 수 있습니다.

version: v3
teleport:
  join_params:
    token_name: "/tmp/token"
    method: token
  proxy_server: "



참여 토큰 생성#

The Discovery Service requires a valid join token to join your Teleport cluster. Run the following tctl command and save the token output in /tmp/token on the server that will run the Discovery Service:

$ tctl tokens add --type=discovery --format=text
(=presets.tokens.first=)
Alternative methods

For users with a lot of infrastructure in AWS, or who might create or recreate many instances, consider alternative methods for joining new EC2 instances running Teleport:

검색 서비스 시작#

Configure the Discovery Service to start automatically when the host boots up by creating a systemd service for it. The instructions depend on how you installed the Discovery Service.

You can check the status of the Discovery Service with systemctl status teleport and view its logs with journalctl -fu teleport.

4/8단계. 검색 그룹 구성#

tctl을 사용할 수 있는 호스트에 파일을 생성하고 저장합니다.

discovery_config를 생성합니다:

$ tctl create 

이전에 구성한 검색 서비스는 이 discovery_config와 동일한 discovery_group에 있으며, AWS 데이터베이스를 검색하기 위해 discovery_config를 사용하기 시작합니다. 데이터베이스를 검색하면 검색 서비스는 해당 데이터베이스를 Teleport 클러스터의 db 리소스로 등록합니다.

Info

Teleport db 리소스는 Teleport 데이터베이스 서비스가 데이터베이스에 대한 접근을 제공하는 데 사용할 수 있는 데이터베이스 사양을 나타냅니다. 데이터베이스 서비스 인스턴스가 레이블 선택기를 통해 db 리소스와 매칭되면, 클러스터에서 단기 db_server 리소스를 정기적으로 생성하여 데이터베이스를 하트비트하기 시작합니다. tsh db lstctl db ls와 같은 도구는 db_server 리소스만 표시합니다. 즉, 데이터베이스 서비스 인스턴스가 접근을 제공하는 데이터베이스만 표시됩니다.

5/8단계. 등록된 데이터베이스 목록 확인#

검색된 데이터베이스에 대한 접근을 제공하도록 데이터베이스 서비스를 설정하기 전에, 검색 서비스가 실제로 데이터베이스를 검색하고 있는지 확인해야 합니다.

tctl로 동적으로 등록된 데이터베이스를 나열할 수 있습니다. 검색 서비스는 Teleport 클러스터에 등록하는 모든 데이터베이스에 teleport.dev/origin: cloud 레이블을 추가합니다.

검색 서비스가 검색될 것으로 예상하는 데이터베이스에 대한 db 리소스를 등록했는지 확인합니다:

$ tctl get db

또는 특정 데이터베이스를 확인합니다:

$ tctl get db/<database-name>

검색된 것으로 생각하는 데이터베이스에 해당하는 db 리소스가 표시되지 않으면 검색 서비스 문제 해결을 참조하세요.

검색된 데이터베이스 이름 각 검색된 데이터베이스의 이름에는 고유성을 보장하기 위해 추가 식별 정보가 추가됩니다. 추가 정보에는 다음이 포함될 수 있습니다: - 엔드포인트 유형(예: "reader" 엔드포인트) - 매처 유형 - AWS 리전 - AWS 계정 ID.

예를 들어 "my-postgres"라는 RDS Aurora 데이터베이스가 AWS 계정 "123456789012"의 us-east-1 리전에서 검색되면 Teleport에서 "my-postgres-rds-aurora-us-east-1-123456789012"로 이름이 지정됩니다.

검색된 데이터베이스에는 AWS 데이터베이스 이름과 엔드포인트 유형으로만 구성된 짧은 표시 이름도 있습니다. 예를 들어 "my-postgres" 또는 "my-postgres-reader"입니다. tctltsh 명령에는 전체 이름이나 표시 이름을 사용할 수 있지만, 표시 이름이 모호한 경우 전체 이름을 사용해야 합니다.

AWS 데이터베이스 리소스에 TeleportDatabaseName AWS 태그를 적용하여 데이터베이스 이름을 재정의할 수 있습니다. 이 값이 db 이름으로 그대로 사용되므로 추가 식별 정보가 추가되지 않습니다.

6/8단계. 데이터베이스 서비스 IAM 권한#

Grant the Database Service access to credentials that it can use to authenticate to AWS.

  • If you are running the Database Service on an EC2 instance, you may use the EC2 Instance Metadata Service method
  • If you are running the Database Service in Kubernetes, you can use IAM Roles for Service Accounts (IRSA)
  • Otherwise, you must use environment variables
Have multiple sources of AWS credentials?

Teleport's AWS client loads credentials from different sources in the following order:

  • Environment Variables
  • Shared credentials file
  • Shared configuration file (Teleport always enables shared configuration)
  • EC2 Instance Metadata (credentials only)

While you can provide AWS credentials via a shared credentials file or shared configuration file, you will need to run the Database Service with the AWS_PROFILE environment variable assigned to the name of your profile of choice.

If you have a specific use case that the instructions above do not account for, consult the documentation for the AWS SDK for Go for a detailed description of credential loading behavior.

데이터베이스 서비스를 위한 AWS IAM 역할을 생성하고 다음 권한을 연결합니다:

7/8단계. 데이터베이스 서비스 배포#

데이터베이스 연결성 구성#

검색 서비스와 달리 데이터베이스 서비스는 Teleport 클러스터에 데이터베이스 접근을 제공하기 위해 데이터베이스에 대한 네트워크 연결이 있어야 합니다. 데이터베이스 서비스에 대한 여러 네트워크 도달성 요구 사항을 충족해야 합니다:

  1. 데이터베이스 서비스가 데이터베이스로의 네트워크 경로를 가짐
  2. 데이터베이스 서비스가 Teleport 클러스터로의 네트워크 경로를 가짐
  3. 데이터베이스 서비스 보안 그룹이 데이터베이스로의 아웃바운드 트래픽을 허용
  4. 데이터베이스 서비스 보안 그룹이 Teleport 클러스터로의 아웃바운드 트래픽을 허용
  5. 데이터베이스 보안 그룹이 데이터베이스 서비스로부터의 인바운드 트래픽을 허용

엄격한 보안 그룹이 연결된 프라이빗 서브넷에 데이터베이스가 배포된 경우, 일반적으로 동일한 VPC 내에, 가능하면 동일한 서브넷에 데이터베이스 서비스 인스턴스를 배포하고 데이터베이스가 인바운드 트래픽을 허용하는 보안 그룹을 연결해야 합니다. Teleport 데이터베이스 서비스는 Teleport 클러스터에 접근하기 위해 AWS NAT 게이트웨이 또는 인터넷 게이트웨이를 통해 공용 인터넷으로의 경로가 필요할 수 있습니다.

이는 특정 네트워킹 설정에 따라 달라지므로 모든 네트워크 요구 사항이나 제안을 포괄하는 목록이 아닙니다.

Teleport 구성 파일 생성#

데이터베이스 서비스를 실행할 호스트에 teleport.yaml 구성 파일을 생성합니다:

version: v3
teleport:
  join_params:
    token_name: "/tmp/token"
    method: token
  proxy_server: "

AWS 데이터베이스에 연결된 AWS 태그는 일부 다른 식별 메타데이터 외에 Teleport db 레이블로 가져옵니다. 사용 가능한 데이터베이스 레이블에 대한 자세한 내용은 데이터베이스 레이블 참조를 참조하세요.

참여 토큰 생성#

The Database Service requires a valid join token to join your Teleport cluster. Run the following tctl command and save the token output in /tmp/token on the server that will run the Database Service:

$ tctl tokens add --type=db --format=text
(=presets.tokens.first=)
Alternative methods

For users with a lot of infrastructure in AWS, or who might create or recreate many instances, consider alternative methods for joining new EC2 instances running Teleport:

데이터베이스 서비스 시작#

Configure the Database Service to start automatically when the host boots up by creating a systemd service for it. The instructions depend on how you installed the Database Service.

You can check the status of the Database Service with systemctl status teleport and view its logs with journalctl -fu teleport.

8/8단계. 데이터베이스 서버 목록 확인#

데이터베이스 서비스가 검색된 데이터베이스를 프록시하고 있는지 확인하려면 다음 tctl 명령을 실행합니다:

## 필요에 따라 쉼표로 구분된 필터링 레이블을 조정합니다
$ tctl db ls teleport.dev/origin=cloud,teleport.dev/cloud=AWS,region=,account-id="*"

예상한 데이터베이스가 표시되지 않으면 아래의 데이터베이스 서비스 문제 해결을 참조하세요.

Note

이 가이드는 검색 서비스와 데이터베이스 서비스를 사용하여 AWS 데이터베이스 자동 검색을 설정하는 방법을 보여주지만, 데이터베이스 사용자 프로비저닝은 다루지 않습니다.

검색된 데이터베이스에 Teleport를 통해 연결하려면 추가적인 Teleport RBAC 구성과 IAM 구성이 필요할 수 있습니다.

데이터베이스 사용자 프로비저닝 및 구성에 대한 정보는 AWS 데이터베이스 등록의 적절한 가이드를 참조하세요.

다음 단계#

  • Teleport 데이터베이스 서비스의 동적 등록에 대해 알아보기
  • 데이터베이스 연결을 시작하세요.
  • 외부 AWS 계정에서 AWS 데이터베이스를 연결하세요.
  • 데이터베이스 사용자 프로비저닝 및 구성에 대한 정보는 AWS 데이터베이스 등록의 적절한 가이드를 참조하세요.

문제 해결#

Discovery Service troubleshooting#

First, check if any databases have been discovered. To do this, you can use the tctl get db command and check if the expected databases have already been registered with your Teleport cluster.

If some databases do not appear in the list, check if the Discovery Service selector labels match the missing database tags or look into the Discovery Service logs for permission errors.

Check that the Discovery Service is running with credentials for the correct AWS account. It can discover resources in another AWS account, but it must be configured to assume a role in the other AWS account if that's the case.

Check if there is more than one Discovery Services running:

$ tctl inventory status --connected

If you are running multiple Discovery Services, you must ensure that each service is configured with the same discovery_group value if they are watching the same cloud databases or a different value if they are watching different cloud databases. If this is not configured correctly, a typical symptom is db resources being intermittently deleted from your Teleport cluster's registry.

Database Service troubleshooting#

Databases do not appear in tctl db ls#

If the tctl get db command returns the discovered databases you expect, but the tctl db ls command does not include them, check that you have set the db_service.resources section correctly, for example:

db_service:
  enabled: true
  resources:
  - labels:
      "env": "prod"

If the section is correctly configured, but databases still do not appear, check that you have the correct permissions to list databases in Teleport. You should have a Teleport role that matches the database labels and allows the "read" and "list" verbs for db and db_server objects. Here's an example that grants those permissions for every database in your cluster:

kind: role
version: v6
metadata:
  name: view-all-databases
spec:
  allow:
    db_labels:
      '*': '*'
    rules:
      - resources: [db_server, db]
        verbs: [read, list]

Errors when connecting to a database#

If there are connection errors when you try to connect to a database, then first check if there are multiple db_server heartbeat resources for the target database: tctl get db_server/yourDatabaseName. If there are, it means that multiple Teleport Database Service instances are proxying the database - this is an HA setup that will complicate troubleshooting. Teleport will choose one of those Database Service instances at random to proxy the connection and if one of them can't reach the database endpoint or lacks permissions, then you will see random connection errors.

Even if connection errors are consistent, you should scale down or reconfigure your Teleport Database Service instances such that only one matches the target db while you are troubleshooting errors. Verify that there is only one db_server with tctl get db_server/yourDatabaseName and then try the connection again.

Check the Teleport Database Service logs with DEBUG level logging enabled and look for network or permissions errors.

Refer to the Database Service troubleshooting guide for more general troubleshooting steps.

Additionally, a guide specific to the type of database in Enroll AWS Databases. may have more specific troubleshooting information.