This topic describes how to create a database link from a PolarDB for PostgreSQL(Compatible with Oracle) cluster to a self-managed PostgreSQL database hosted on an Elastic Compute Service (ECS) instance.

For more information about how to create a database link from a PolarDB for PostgreSQL(Compatible with Oracle) cluster to a PolarDB for PostgreSQL(Compatible with Oracle) cluster, see Create a database link from PolarDB for PostgreSQL(Compatible with Oracle) to PolarDB for PostgreSQL(Compatible with Oracle).

Prerequisites

  • The PolarDB for PostgreSQL(Compatible with Oracle) cluster and the self-managed PostgreSQL database hosted on the ECS instance belong to the same Alibaba Cloud account.
  • The ECS instance is deployed in a virtual private cloud (VPC).
  • The kernel version of the PolarDB for PostgreSQL(Compatible with Oracle) cluster is the latest kernel version. For information about how to upgrade the kernel version, see Version Management.
  • A database link is created from the PolarDB for PostgreSQL(Compatible with Oracle) cluster to the self-managed PostgreSQL database hosted on the ECS instance.

Precautions

You can create a maximum of 10 database links for each PolarDB for PostgreSQL(Compatible with Oracle) cluster. Each database link consumes one database link quota of both the source cluster and the destination cluster.

Procedure

  1. Log on to the PolarDB console.
  2. In the upper-left corner of the console, select the region in which the cluster that you want to manage is deployed.
  3. Find the cluster and click the cluster ID.
  4. In the left-side navigation pane, choose Settings and Management > Databases.
  5. On the Databases page, click the DBLinks tab in the upper part.
  6. Click Create DBLink and configure the following parameters.
    ParameterDescription
    DBLink NameYou can enter a custom name of the database link. The name must meet the following requirements:
    • The name must contain lowercase letters and can contain digits and underscores (_).
    • The name must start with a lowercase letter and end with a lowercase letter or a digit.
    • The token can be up to 64 characters in length,

    This name is required when you use the database link for cross-database queries.

    Source Instance NameThe name of the current PolarDB for PostgreSQL(Compatible with Oracle) cluster is used as the fixed value. You cannot modify this parameter.
    Source Database NameSelect a database in the current PolarDB for PostgreSQL(Compatible with Oracle) cluster from the drop-down list.
    VPC of Destination InstanceThe VPC where the ECS instance resides.

    You can view the VPC ID of the destination ECS instance in the Network Information section on the Basic Information page in the ECS console.

    dblink-vpcid
    Region ID of Destination InstanceThe region ID of the ECS instance, such as cn-hangzhou.

    You can call the DescribeInstances operation to query the region ID of the destination ECS instance.

    VPC ID of Destination InstanceThe IP address of the ECS instance.

    You can view the primary private IP address of the destination ECS instance in the Network Information section on the Basic Information page in the ECS console.

    dblink-vpc-ip
    VPC Port of Destination InstanceThe port number of the self-managed PostgreSQL database hosted on the ECS instance. Default value: 1521.
    Destination AccountThe account used to log on to the self-managed PostgreSQL database hosted on the ECS instance.
    Destination Account PasswordThe password used to log on to the self-managed PostgreSQL database hosted on the ECS instance.
    Destination Database NameThe name of the self-managed PostgreSQL database hosted on the ECS instance.
  7. Click OK.

Related operations

APIDescription
CreateDBLinkCreates a database link for a PolarDB for PostgreSQL(Compatible with Oracle) cluster.
DescribeDBLinksQueries the database link information of a PolarDB for PostgreSQL(Compatible with Oracle) cluster.