Setting Up Replication

This example will guide you through setting up replication of a database. These instructions assume that you have two SingleStore clusters running; the primary cluster contains the source data that is replicated to the secondary cluster.

Note

To replicate a database, the secondary cluster user must have CREATE DATABASE privileges and the primary cluster user (the one specified in REPLICATE DATABASE) must have the ALL PRIVILEGES permission on the primary cluster’s master aggregator.

The following host:port combinations represent the master aggregators of the primary and secondary clusters:

  • primary-MA:3306

  • secondary-MA:3306

Note that the primary and secondary clusters need not have identical topologies. SingleStore will automatically manage sharding of replica data on the secondary cluster. It is not necessary to use the root user for this command, instead use another user with sufficient permissions as listed above.

To begin replicating the database db_name from primary-MA, run the following command on secondary-MA:

REPLICATE DATABASE db_name FROM master_user:'master_user_password'@primary-MA:3306;

You always initiate replication from the secondary cluster. You can start replication to a secondary cluster without pausing the primary cluster.

Multiple secondary clusters can replicate from a single primary cluster. To do this, run REPLICATE DATABASE on the master aggregator of each of the replica clusters.

Note

Data is always replicated across clusters asynchronously. Databases are replicated at the leaf level, which implies that a leaf in the secondary cluster replicates data directly from a leaf in the primary cluster; therefore, when connecting a secondary cluster to the primary cluster, the leaves in the primary and secondary cluster must be able to communicate with each other. They should not be blocked by firewall or network rules.

Last modified: April 3, 2023

Was this article helpful?

Verification instructions

Note: You must install cosign to verify the authenticity of the SingleStore file.

Use the following steps to verify the authenticity of singlestoredb-server, singlestoredb-toolbox, singlestoredb-studio, and singlestore-client SingleStore files that have been downloaded.

You may perform the following steps on any computer that can run cosign, such as the main deployment host of the cluster.

  1. (Optional) Run the following command to view the associated signature files.

    curl undefined
  2. Download the signature file from the SingleStore release server.

    • Option 1: Click the Download Signature button next to the SingleStore file.

    • Option 2: Copy and paste the following URL into the address bar of your browser and save the signature file.

    • Option 3: Run the following command to download the signature file.

      curl -O undefined
  3. After the signature file has been downloaded, run the following command to verify the authenticity of the SingleStore file.

    echo -n undefined |
    cosign verify-blob --certificate-oidc-issuer https://oidc.eks.us-east-1.amazonaws.com/id/CCDCDBA1379A5596AB5B2E46DCA385BC \
    --certificate-identity https://kubernetes.io/namespaces/freya-production/serviceaccounts/job-worker \
    --bundle undefined \
    --new-bundle-format -
    Verified OK