pdbcli configuration guide

更新时间:
复制 MD 格式

The pdbcli configuration file is a key part of installing, deploying, and maintaining a PolarDB for PostgreSQL (PolarFlex) database cluster. It defines key details such as the cluster topology, host information, port configurations, and database parameters. Correctly understanding and using these configuration files is vital for stable cluster operation. This topic describes the configuration files in the polarflex-${version}/ directory and explains their parameters.

Configuration files

Configuration file name

Primary purpose

Scenarios

Notes

config.yaml

The default configuration file used for daily maintenance of the database cluster.

Daily maintenance, cluster management, and operations and maintenance (O&M).

• Do not delete this file.

• Validate the configuration syntax after making changes.

• Back up the file before modifying it in a production environment.

config_template.yaml

A configuration file template for a cluster with one primary and two secondary nodes.

One-click deployment of a three-node cluster.

• Requires three servers for installation and deployment.

• This file is not used after installation.

config_master_slave.yaml

A configuration template for a cluster with one primary and one secondary node.

One-click deployment of a two-node cluster.

• Requires two servers for installation and deployment.

• This file is not used after installation.

config_single_node.yaml

A configuration template for a single-node cluster.

One-click deployment of a single-node cluster.

• Requires only one server for installation and deployment.

• This file is not used after installation.

Deployment and O&M

Use the polarflex-deploy.sh one-click deployment script to create a cluster for the first time. Select and modify the template file that corresponds to your desired cluster architecture.

  • How it works: The polarflex-deploy.sh script reads your selected template file. It combines the template with parameters that you pass, such as IP addresses, to automatically generate and overwrite the config.yaml file. The script then uses this new config.yaml file to perform the deployment.

    image

  • Procedure:

    1. Select a template file: config_single_node.yaml, config_master_slave.yaml, or config_template.yaml.

    2. Modify the parameters in the template file as needed.

    3. Run polarflex-deploy.sh to perform a one-click deployment.

    4. The script automatically generates the config.yaml file.

    5. After the deployment is complete, verify that the contents of config.yaml are correct.

    6. After the cluster is deployed, all daily management and maintenance operations are performed by directly modifying the config.yaml file.

Parameter reference

This section uses config_template.yaml as an example to explain the file structure and key parameters. This file is used to deploy a three-node PolarDB cluster with cluster management (CM), database (DB), and proxy components on three hosts.

Note

You can install and deploy a cluster without modifying the default configuration file. For a quick installation, you can skip the configuration file modification steps and proceed directly to installing and creating the cluster.

all:
  children:
    cm:
      hosts:
        host01: null
        host02: null
        host03: null
      var: null
    db:
      hosts:
        host01:
          polardb_polar_hostid: 1
        host02:
          polardb_polar_hostid: 2
          polardb_node_type: standby
        host03:
          polardb_polar_hostid: 3
          polardb_node_type: standby
      vars:
        polardb_custom_params:
        - max_standby_streaming_delay = 900000
        - max_connections = 3300
        - polar_max_super_conns = 1500
        - max_slot_wal_keep_size = 64000
        - log_statement = 'ddl'
        polardb_service_restart_sec: 5
        hugepage_enabled: off
    proxy:
      hosts:
        host01: null
        host02: null
        host03: null
      var: null
  hosts:
    host01:
      ansible_host: {{host1}} # HOST01_IP
    host02:
      ansible_host: {{host2}} # HOST02_IP
    host03:
      ansible_host: {{host3}} # HOST03_IP
  vars:
    ansible_group_priority: 99
    ansible_python_interpreter: /usr/bin/{{python}}
    cluster_id: polardb1
    cm_consensus_port: 7001
    cm_service_port: 5001
    cm_tls_service_port: 6001
    cm_db_sync_mode: SYNC
    polardb_data_root_dir: /var/lib/thirdDB
    license_dir: license
    polardb_enable_direct_io: false
    polardb_multi_instance_per_host: true
    polardb_polar_enable_pfs_mode: false
    polardb_port: 1523
    polardb_proxy_port: 12369
    polardb_proxy_port_rwlb: 12370
    polardb_proxy_admin_port: 12371
    polardb_storage_mode: local_filesystem_mode
    polardb_user: polar1
    polardb_init_username: {{polardb_init_username}}
    polardb_base_init_password: {{polardb_base_init_password}}
    polardb_init_database_name: {{polardb_init_database_name}}
    primary_db_host: host01
    ue_node_driver_service_port: 12355
    password_encrypt: true
    cpu_cores: {{cpu_cores}}
    memory_limit: {{memory_limit}}
    lc_ctype: en_US.UTF8
    global_type: {{global_type}}
    global_master_hosts_ip: {{global_master_hosts_ip}}
    maintenance_user: {{maintenance_user}}
    global_stream_mode: {{global_stream_mode}}
    compatibility_mode: pg
    # Each parameter can be passed in through an environment variable. Here is an example.
    # alternative_parameters: {{alternative_parameters}} 

1. Overall structure and editing principles

  • File structure:

    • all.children: Groups hosts by function (cm, db, proxy) and defines group-level variables.

    • all.hosts: Defines the aliases and corresponding IP addresses for all hosts in the cluster.

    • all.vars: Defines global variables that apply to the entire cluster.

  • Editing principles:

    • Do not manually modify the all.hosts section. The polarflex-deploy.sh script automatically replaces the placeholders with the machine IP addresses that you pass as parameters.

    • Do not manually modify the all.children.*.hosts section. By default, the complete cm, db, and proxy components are deployed on all nodes.

    • Adjust parameters in the global all.vars and group-specific all.children.*.vars sections as needed.

    • After modification, ensure that the YAML file maintains correct indentation and key names. Use true/false for Boolean values. Port values must be integers. Strings that do not contain spaces do not require quotation marks.

2. Group definitions (all.children)

  1. cm:

    • children.cm.hosts: A list of hosts where the cluster management (CM) service is deployed. Typically, one or three hosts are used to achieve high availability (HA).

      Note

      Adding or removing CM nodes usually requires rerunning the deployment or performing a cluster-level CM operation.

  2. db:

    • children.db.hosts.*.polardb_polar_hostid: The unique numeric ID of the database node within the cluster.

    • children.db.hosts.*.polardb_node_type: The node type. This can be omitted for the primary node. For a secondary node, it must be explicitly specified as standby.

    • children.db.vars.polardb_custom_params: Custom database parameters that are passed through to the PostgreSQL kernel.

      Parameter

      Example value

      Description

      Suggestion

      max_standby_streaming_delay

      900000

      The maximum time (in milliseconds) that a secondary database waits when applying streaming Write-Ahead Logging (WAL) from the primary database if a conflicting query is encountered. If this time is exceeded, the conflicting query is canceled to ensure WAL replay continues. 900000 ms = 15 minutes.

      Keep the default value.

      max_connections

      3300

      The maximum number of concurrent connections allowed for the instance.

      Set this value based on your business needs and connection management strategy. Avoid setting it too high to prevent memory exhaustion. Restart the instance after modification. You can usually keep the default value.

      polar_max_super_conns

      1500

      The maximum number of concurrent connections allowed for a superuser in PolarDB.

      Keep the default value.

      max_slot_wal_keep_size

      64000

      The maximum amount of WAL (in MB) that each replication slot can retain. When this limit is reached, the oldest WAL files are reclaimed, and streaming replication between the primary and secondary databases is interrupted. This prevents the disk from filling up. The default value is approximately 62.5 GB.

      Set this based on disk capacity, downstream lag, and send latency. It is critical to monitor replication slot lag. A low limit can cause WAL files generated by the primary database to be reclaimed during high-write scenarios. This leads to replication interruption, making the secondary database unavailable and requiring a manual rebuild. If streaming replication is in synchronous mode, an interruption prevents the primary node from accepting writes.

      log_statement

      ddl

      Controls the granularity of SQL statements recorded in the log: `none`, `ddl`, `mod`, or `all`. By default, only DDL statements are logged.

      Set as needed. Avoid enabling `all` for long periods to prevent rapid log growth and performance impact.

    • children.db.vars.polardb_service_restart_sec: The number of seconds to wait between nodes during a rolling restart of the service. Keep the default value.

    • children.db.vars.hugepage_enabled: Specifies whether to enable enormous pages in the operating system (on/off). If enabled, you must also configure enormous pages at the operating system level.

  3. proxy:

    children.proxy.hosts: A list of hosts where the proxy service is deployed. Typically, it is deployed on multiple hosts to ensure availability.

3. Global variables (all.vars)

This section describes the global variables in all.vars. Some parameters in the configuration file contain {{}}. These parameters are automatically replaced during one-click deployment and do not require manual modification. For parameters not listed here, keep the default values. The installer automatically manages and configures them. Parameters in the following list, such as the data directory and ports, cannot be modified after installation. To change them, you must uninstall and delete the cluster, and then redeploy it.

Parameter

Description

Example/Default

Suggestion

polardb_data_root_dir

The directory for storing data files.

/var/lib/thirdDB

Change this to the path of a data disk with large capacity to ensure performance and space.

compatibility_mode

The database compatibility type.

pg

Modify as needed. Options are pg or ora. To be compatible with Oracle syntax, set this to ora.

ansible_group_priority

Controls the order in which Ansible variables are overwritten.

99

Keep the default value.

ansible_python_interpreter

The Python path for Ansible on the target machine.

/usr/bin/{{python}}

Keep the default value.

cluster_id

The cluster identifier.

polardb1

Keep the default value, or change it to a meaningful name.

cm_consensus_port

The internal consensus communication port for CM.

7001

Keep the default value to avoid port conflicts.

cm_service_port

The external service port for CM.

5001

Modify as needed to avoid port conflicts and configure the firewall to allow traffic.

cm_db_sync_mode

The primary-secondary replication mode: synchronous or asynchronous.

SYNC/ASYNC

Keep the default value. The default is `ASYNC` for a one-primary, one-secondary cluster, and `SYNC` for a one-primary, two-secondary cluster.

polardb_storage_mode

The storage mode.

local_filesystem_mode

Keep the default value.

polardb_port

The database port.

1523

Modify as needed to avoid port conflicts and configure the firewall to allow traffic. Clients must connect to this port.

polardb_proxy_port

The proxy service port for strong consistency reads and writes.

12369

Modify as needed to avoid port conflicts and configure the firewall to allow traffic.

polardb_proxy_port_rwlb

The proxy service port for read/write splitting.

12370

Modify as needed to avoid port conflicts and configure the firewall to allow traffic.

polardb_proxy_admin_port

The proxy administration port.

12371

Modify as needed to avoid port conflicts.

polardb_user

The operating system user that runs the database service.

polar1

Keep the default value.

primary_db_host

The alias of the host where the primary database is logically located.

host01

Keep the default value.

ue_node_driver_service_port

The node driver service port.

12355

Modify as needed to avoid port conflicts.

polardb_init_username

The administrative or business superuser created during initialization.

admin

Keep the default value.

polardb_base_init_password

The logon security token for the initial superuser.

cG9zdGdyZXM=

Keep the default value. The default value is Base64-encoded.

polardb_init_database_name

The name of the business system database automatically created after installation.

admin_db

Keep the default value. Use a semantic name to avoid conflicts with system databases.

password_encrypt

Specifies whether to enable Base64 encoding for passwords in the configuration file.

true

Keep the default value.

lc_ctype

The character set locale.

en_US.UTF8

Keep the default value. Ensure this locale is installed on the operating system (run locale -a). If not, install it or change it to an existing locale, such as zh_CN.UTF-8.

Note

Parameters such as the data directory and ports cannot be modified after the cluster is installed. To make changes, you must uninstall and then redeploy the cluster.

Notes

  • Port conflicts: Check for port conflicts with other services.

  • Path permissions: Ensure that the polardb_user specified in the configuration file has read and write permissions for the data directory. If this user does not exist on the current operating system, it is automatically created during the installation process.

  • Network requirements: Ensure that all nodes can communicate with each other and that the firewall rules are configured correctly.

  • Configuration file: Ensure that the YAML syntax is correct.