Manage read-only nodes

更新时间:
复制 MD 格式

After you deploy a PolarDB for PostgreSQL (Lightweight Edition) cluster, you can add or delete read-only nodes as needed.

Precautions

Deleting a read-only node causes a transient connection interruption on that node. Other nodes are not affected. Delete nodes during off-peak hours and ensure your application has an automatic reconnection mechanism.

Add a read-only node

To scale out your cluster by adding read-only nodes, you must update the cluster configuration file with the new node's configuration.

  1. Prepare the environment for the new node. This includes the following:

  2. Modify the configuration file by adding the read-only node configuration to the db.hosts and hosts sections. For an example of the configuration file, see Configuration file example.

  3. Install cluster dependencies on the new read-only node.

    pdbcli install node --target <IP address of the target read-only node>
  4. Add the read-only node. This process pulls data from the primary node to initialize the new node and then adds the node to the high availability (HA) component and the Proxy component.

    pdbcli rebuild db --target <IP address of the target read-only node>

    After the installation is complete, run pdbcli status to confirm the node status.

Delete a read-only node

pdbcli delete db --target <IP address of the target read-only node>

After deleting the read-only node, update the cluster configuration file by removing the configuration for the deleted node from the db.hosts and hosts sections. For an example of the configuration file, see Configuration file example.

Rebuild a read-only node

pdbcli rebuild db --target <IP address of the target read-only node>

You cannot rebuild the primary node of the cluster. When you rebuild a read-only node, the system pulls data from the primary node and adds the rebuilt node back to the HA component and the Proxy component.