Skip to content

Dynamic XDR configuration

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

This page describes how to configure XDR dynamically using asadm or asinfo, and how to persist that configuration across node restarts.

XDR is Aerospike’s inter-cluster replication mechanism, a standard feature in Aerospike Database Enterprise Edition.

Terminology

  • Shipping refers to sending data from one datacenter to another.
  • A cluster from which records are shipped is a source cluster.
  • A cluster to which records are shipped is a destination cluster.

Version changes

A source cluster running Database 8.1.1 and later requires every Aerospike destination cluster to run Database 5.0.0.3 and later. See XDR version compatibility. The following Database versions change which parameters you can set dynamically. For all XDR changes by version, see Version changes.

  • Starting with Database 8.1.1, recovery-threads configures the number of threads per datacenter (1-32) for use in parallel recovery. This improves recovery performance for large backlogs.
  • Starting with Database 7.2.0:
    • ship-versions-policy controls how XDR ships versions of modified records when facing lag between the source cluster and a destination.
    • ship-versions-interval specifies a time window in seconds within which XDR is allowed to skip versions.
  • Starting with Database 5.7.0, the XDR subsystem always accepts dynamic configuration commands because it is always initialized even if XDR is not configured statically.
  • Prior to Database 5.7.0, the XDR subsystem must be configured statically with at least one datacenter before it accepts dynamic configuration commands. See Static XDR configuration.

Dynamic configuration

Configure XDR on a running cluster without restarting database nodes using asadm or asinfo.

  • asadm manage config applies changes across all nodes in the cluster. Aerospike recommends this for most XDR configuration tasks.
  • asinfo set-config applies changes only to the node you connect to. The same command-string format is used when configuring XDR programmatically through the SDK.

For additional command syntax, see XDR syntax in the runtime configuration guide.

Configure a new datacenter

  1. Create the datacenter and add destination nodes.

    Terminal window
    asadm -e "enable; manage config xdr create dc DC1"
    asadm -e "enable; manage config xdr dc DC1 add node 10.0.0.2:3000"

    When using TLS, first set the datacenter’s tls-name as shown in Configure a new datacenter with TLS, because the server rejects a TLS node address on a datacenter without one. Then append the destination cluster’s TLS name after the port using the format host:tls_port:tls_name:

    Terminal window
    asadm -e "enable; manage config xdr dc DC1 add node 10.0.0.2:4333:destination_tls_name"

    To remove a TLS node, specify only the host and port (omit the TLS name):

    Terminal window
    asadm -e "enable; manage config xdr dc DC1 remove node 10.0.0.2:4333"
  2. Add the namespace to the defined dc. This starts shipping new writes from this point forward. XDR does not ship existing records unless you add the namespace with rewind. See Rewind a shipment.

    Terminal window
    asadm -e "enable; manage config xdr dc DC1 add namespace NAMESPACE_NAME"
  3. Verify the datacenter configuration.

    Terminal window
    asadm -e "show config xdr dc for DC1"

    Check that node-address-port lists the destination node and that namespaces lists the namespace you added.

  4. To retain this configuration on restart, add it to your configuration file. See Persist dynamic XDR configuration.

Configure a new datacenter with TLS

When the destination cluster requires TLS and authentication, set the TLS and authentication parameters before adding node addresses and namespaces. For background on TLS name concepts and static configuration, see XDR security.

  1. Create the datacenter.

    Terminal window
    asadm -e "enable; manage config xdr create dc DC1"
  2. Set the local cluster’s TLS name for this datacenter.

    Terminal window
    asadm -e "enable; manage config xdr dc DC1 param tls-name to source_tls_name"
  3. Set the authentication mode.

    Use external for LDAP authentication over TLS, internal for Aerospike access control, or pki for PKI authentication. With pki, do not set auth-user or auth-password-file. See XDR security for authentication mode details and credential setup.

    Terminal window
    asadm -e "enable; manage config xdr dc DC1 param auth-mode to external"
  4. If using access control or LDAP, set the password file and user.

    Terminal window
    asadm -e "enable; manage config xdr dc DC1 param auth-password-file to /path/to/credentials.txt"
    asadm -e "enable; manage config xdr dc DC1 param auth-user to xdr_user"
  5. Add the destination node addresses. Use the format host:tls_port:tls_name to append the destination cluster’s TLS name after the port.

    Terminal window
    asadm -e "enable; manage config xdr dc DC1 add node 10.0.0.2:4333:destination_tls_name"

    To remove a node, specify only the host and port (omit the TLS name):

    Terminal window
    asadm -e "enable; manage config xdr dc DC1 remove node 10.0.0.2:4333"
  6. Add the namespace to start shipping new writes from this point forward. To ship older records, see Rewind a shipment.

    Terminal window
    asadm -e "enable; manage config xdr dc DC1 add namespace NAMESPACE_NAME"
  7. To retain this configuration on restart, add it to your configuration file. See Persist dynamic XDR configuration.

Persist dynamic XDR configuration

To retain dynamic XDR settings across node restarts, add the equivalent xdr section to your Aerospike configuration file after you finish dynamic configuration. See Rewind a shipment for how to control backfill when associating a namespace.

Rewind a shipment

Use rewind when you associate a namespace with a datacenter to ship records last updated within a specified time window. A rewind ships every matching record in that window, whether or not XDR previously shipped it to the destination. You can use rewind when first associating a namespace or when re-associating a namespace that is already configured for the datacenter.

Use these rules when planning a rewind:

  • For a new namespace association, add the namespace with rewind in the same command.
  • For an existing namespace association, remove the namespace from the datacenter, then add it back with rewind. Removing the namespace discards the existing XDR queue, so records can be missed if the rewind period is shorter than the current XDR lag. If the add fails right after the remove and the log shows {NAMESPACE_NAME} DC DC_NAME previous processing pending, in-flight shipments from the removed association have not settled yet. Wait a moment and retry the add.
  • To ship records updated within a specific time window, set rewind to the number of seconds before the current time. With asinfo, you can also append a time unit of s, m, h, or d, for example rewind=10m. asadm accepts only a number of seconds or all.
  • To rewind only specific sets, configure ship-only-specified-sets and ship-set after removing the namespace and before adding it back. See Ship specific sets to a new namespace for the full sequence.
  • For large namespaces, using asbackup and asrestore, or a touch UDF that triggers normal XDR shipping, may be more efficient than a set-specific rewind. See How to rewind XDR for a namespace for details.
  • When a namespace is added with or without rewind, XDR sets a fresh Last Ship Time (LST) for that namespace and DC pair. The LST is communicated across nodes and persisted to SMD. XDR does not ship records older than the LST.

Rewind and restart examples

  1. In the following example, the rewind 600 clause rewinds shipment to 10 minutes before the current time for datacenter DC1 and namespace namespace1:

    Terminal window
    asadm -e "enable; manage config xdr dc DC1 remove namespace namespace1"
    asadm -e "enable; manage config xdr dc DC1 add namespace namespace1 rewind 600"
    • For small datasets, you can restart the shipment entirely from the beginning with rewind all.

    • For large datasets, starting a complete rewind can increase server loads.

  2. The following example completely restarts shipment for datacenter DC2 and namespace namespace2:

    Terminal window
    asadm -e "enable; manage config xdr dc DC2 remove namespace namespace2"
    asadm -e "enable; manage config xdr dc DC2 add namespace namespace2 rewind all"

Ship specific sets to a new namespace

In some cases, when associating a namespace to a datacenter, you can restrict shipping to only specific sets.

  1. Disassociate the namespace from the datacenter.

    Terminal window
    asadm -e "enable; manage config xdr dc DC_NAME remove namespace NAMESPACE_NAME"
  2. Dynamically configure ship-only-specified-sets for that namespace. Set these parameters while the namespace is disassociated so that the rewind in the last step ships only the specified sets. Both parameters are dynamic, so you can also change them after the namespace is added.

    Terminal window
    asadm -e "enable; manage config xdr dc DC_NAME namespace NAMESPACE_NAME param ship-only-specified-sets to true"
  3. Specify which sets to ship.

    Terminal window
    asadm -e "enable; manage config xdr dc DC_NAME namespace NAMESPACE_NAME param ship-set to SETNAME"
  4. Verify the settings before you rewind. Use asinfo for this check, because asadm show config xdr namespace lists only namespaces that are associated with the datacenter, and the namespace is still removed at this point.

    Terminal window
    asinfo -v "get-config:context=xdr;dc=DC_NAME;namespace=NAMESPACE_NAME" -l

    Check that ship-only-specified-sets is true and that shipped-sets lists SETNAME. If it doesn’t, the rewind in the next step can ship every set in the namespace.

  5. Rewind when associating the namespace to the datacenter.

    Terminal window
    asadm -e "enable; manage config xdr dc DC_NAME add namespace NAMESPACE_NAME rewind all"

Recovery modes

When you rewind a namespace, XDR scans the index and ships matching records for that namespace, partition by partition. This is XDR recovery mode. For when recovery mode activates and how it fits the shipment lifecycle, see XDR recovery mode. XDR supports the following recovery modes.

Single-threaded interleaved recovery

Single-threaded interleaved recovery is the default when recovery-threads is 1.

In this mode, one recovery thread processes multiple partitions in an interleaved fashion. The mode is active whenever recovery-threads is 1, for any value of max-recoveries-interleaved, including the default of 0.

Use max-recoveries-interleaved to control how many partitions recover concurrently. Set it greater than 0 to limit concurrent recovery.

When a partition’s recovery round ends before the partition is fully recovered, XDR puts the partition back in the recovery queue. With the default of 0, the partition goes to the end of the queue, so the thread rotates through every pending partition. With a value of N greater than 0, the partition goes back in at position N-1, so the thread rotates among at most N partitions and each one finishes sooner. A value of 1 recovers one partition at a time.

If high incoming throughput pushes partitions back into recovery before they finish, set max-recoveries-interleaved to a small nonzero value to reduce how many partitions recover at once.

Parallel partition-dedicated recovery

Parallel partition-dedicated recovery is active when recovery-threads is greater than 1 and max-recoveries-interleaved is 0 (Database 8.1.1 and later).

When the entire partition is finished, the thread picks up the next partition from the queue. Multiple threads work simultaneously on different partitions, with each thread fully dedicated to one partition at a time.

Dynamic configuration constraints

  • When switching from parallel to interleaved mode: Set recovery-threads to 1, which enables interleaving. Then, optionally, set max-recoveries-interleaved to a value greater than 0 to limit how many recoveries are interleaved.
  • When switching from interleaved to parallel mode: To change recovery-threads when max-recoveries-interleaved is greater than 0, first set max-recoveries-interleaved to 0, then change recovery-threads to the value you want.