Doc Menu

Deploy TiCDC in Kubernetes

TiCDC is a tool for replicating the incremental data of TiDB. This document describes how to deploy TiCDC in Kubernetes using TiDB Operator.

You can deploy TiCDC when deploying a new TiDB cluster, or add the TiCDC component to an existing TiDB cluster.

Prerequisites

TiDB Operator is deployed.

Fresh TiCDC deployment

To deploy TiCDC when deploying the TiDB cluster, refer to Deploy TiDB in General Kubernetes.

Add TiCDC to an existing TiDB cluster

  1. Edit TidbCluster Custom Resource:

    kubectl edit tc ${cluster_name} -n ${namespace}
  2. Add the TiCDC configuration as follows:

    spec:
      ticdc:
        baseImage: pingcap/ticdc
        replicas: 3

    To deploy Enterprise Edition of TiCDC, edit the db.yaml file to set spec.ticdc.baseImage to the enterprise image (pingcap/ticdc-enterprise).

    For example:

    spec:
     ticdc:
       baseImage: pingcap/ticdc-enterprise
  3. After the deployment, enter a TiCDC Pod by running kubectl exec:

    kubectl exec -it ${pod_name} -n ${namespace} sh
  4. Manage the cluster and data replication tasks by using cdc cli.

    /cdc cli capture list --pd=http://${cluster_name}-pd:2379
    [
            {
                    "id": "6d92386a-73fc-43f3-89de-4e337a42b766",
                    "is-owner": true
            },
            {
                    "id": "b293999a-4168-4988-a4f4-35d9589b226b",
                    "is-owner": false
            }
    ]

    Starting from v4.0.3, TiCDC supports TLS. TiDB Operator supports enabling TLS for TiCDC since v1.1.3.

    If TLS is enabled when you create the TiDB cluster, add TLS certificate-related parameters when you use cdc cli.

    /cdc cli capture list --pd=https://${cluster_name}-pd:2379 --ca=/var/lib/cluster-client-tls/ca.crt --cert=/var/lib/cluster-client-tls/tls.crt --key=/var/lib/cluster-client-tls/tls.key

    If the server does not have an external network, refer to deploy TiDB cluster to download the required Docker image on the machine with an external network and upload it to the server.