Creating Readonly Instances

Starting from PolarDB-X Operator version 1.3.0, you have the capability to create readonly instances and designate their affiliation with a PolarDB-X primary instance.

Readonly instances' storage nodes ensure isolation of physical resources by introducing Learner replicas. This setup not only provides read-write separation features but also guarantees strong consistency for readonly queries based on a global clock.

There are two approaches to create a readonly instance:

1. Adding a Readonly Instance to an Existing Primary Instance

Compose a standalone PolarDBXCluster YAML configuration file, set spec.readonly to true, and specify spec.primaryCluster as the name of its associated primary instance. Here is an example:

  # readonly.yaml
  apiVersion: polardbx.aliyun.com/v1
  kind: PolarDBXCluster
  metadata:
    name: pxc-readonly
  spec:
    readonly: true
    primaryCluster: pxc-master # Name of the primary instance
    topology:
      nodes:
        cn:
          replicas: 1
          template:
            resources:
              limits:
                cpu: 2
                memory: 4Gi
            image: polardbx/polardbx-sql:v2.4.0_5.4.19
            imagePullPolicy: Always
        dn:
          # DN replicas will automatically synchronize with the primary instance's DN replicas; no need to explicitly specify
          template:
            resources:
              limits:
                cpu: 2
                memory: 4Gi
            image: polardbx/polardbx-engine:v2.4.0_8.4.19
            imagePullPolicy: IfNotPresent
    config:
      cn:
        static:
          AttendHtap: true # Indicating support for HTAP

2. Simultaneously Creating a Primary Instance and Readonly Instance

When creating the primary instance, add information about the associated readonly instance in the spec.initReadonly field of the primary instance's PolarDBXCluster YAML configuration file. The specifications and parameters of the created readonly instance match those of the primary instance. Here is an example:

  # pxc-with-readonly.yaml
  apiVersion: polardbx.aliyun.com/v1
  kind: PolarDBXCluster
  metadata:
    name: pxc
  spec:
    initReadonly:
      - cnReplicas: 1 # Number of readonly instance CNs
        name: readonly # Suffix for the readonly instance; in this example, a readonly instance named "pxc-readonly" will be generated; if not filled, a random suffix will be generated
        extraParams:
          AttendHtap: "true" # Indicating support for HTAP
    topology:
      nodes:
        cn:
          replicas: 1
          template:
            resources:
              limits:
                cpu: 2
                memory: 4Gi
            image: polardbx/polardbx-sql:v2.4.0_5.4.19
            imagePullPolicy: Always
        dn:
          replicas: 1
          template:
            resources:
              limits:
                cpu: 2
                memory: 4Gi
            image: polardbx/polardbx-engine:v2.4.0_8.4.19
            imagePullPolicy: IfNotPresent

3. Connecting to Readonly Instances

To connect to readonly instances, use the same method as connecting to primary instances. Refer to Connecting to PolarDB-X Database, and insert the readonly instance name as the corresponding cluster instance name.

results matching ""

    No results matching ""