Облачная платформаAdvanced

Connecting to an RDS for PostgreSQL Instance

Язык статьи: Английский
Перевести

Before connecting to a DB instance, you must create one first. For details about how to create a DB instance, see Buying an RDS for PostgreSQL Instance. You can connect to an RDS for PostgreSQL instance through a command-line interface (CLI), graphical user interface (GUI), or using Java database connectivity (JDBC).

Connection Methods

Table 1 Connection methods

Connection Method

Description

Connecting to an Instance Through the psql CLI Client

In Linux, you need to install a PostgreSQL client on the ECS and connect to the instance through the psql CLI over a private or public network.

  • A floating IP address is provided by default.

    When your applications are deployed on an ECS that is in the same region and VPC as your RDS instance, you are advised to use a floating IP address to connect to the RDS for PostgreSQL instance through the ECS.

  • If you cannot access your RDS for PostgreSQL instance through a floating IP address, bind an EIP to the instance and connect to the instance through the ECS.

Connecting to an RDS for PostgreSQL Instance Using pgAdmin

In Windows, you can use the pgAdmin client to connect to an RDS for PostgreSQL instance.

Connecting to an RDS for PostgreSQL Instance Through JDBC

RDS for PostgreSQL is compatible with the community ecosystem and does not provide driver services. You can select a community driver version as required.

If you are connecting to an instance through JDBC, the SSL certificate is optional. For security reasons, you are advised to download the SSL certificate to encrypt the connection.

Connecting to a DB Instance over a Private or Public Network Using a CLI

Table 2 lists how to use a CLI to connect to an RDS for PostgreSQL instance over a private or public network.

Table 2 Connecting to a DB instance over a private or public network

Connection Method

IP Address

Security Group Rules

Description

Private network

Floating IP address

  • If the ECS and RDS instance are in the same security group, they can communicate with each other over a private network by default. No security group rules need to be configured.
  • If they are in different security groups, configure security group rules for them, separately.
    • RDS instance: Configure an inbound rule for the security group with which the RDS instance is associated. For details, see Configuring Security Group Rules.
    • ECS: The default security group rule allows all outgoing data packets. In this case, you do not need to configure a security group rule for the ECS. If not all outbound traffic is allowed in the security group, you need to configure an outbound rule for the ECS.
  • Secure and high-performance
  • Recommended

Public network

You need to purchase an EIP.

To access a DB instance from resources outside the security group that the DB instance is associated with, you need to configure an inbound rule for the security group. For details, see Configuring Security Group Rules.

  • Less secure
  • To achieve a higher transmission rate and security level, you are advised to migrate your applications to an ECS that is in the same VPC as your RDS instance and use a floating IP address to access the DB instance.

Figure 1 Connecting to a DB instance over a private or public network