Sign In Try Free

Deploy a Heterogeneous Cluster for an Existing TiDB Cluster

This document describes how to deploy a heterogeneous cluster for an existing TiDB cluster. A heterogeneous cluster consists of nodes with different configurations from the existing TiDB cluster.

Usage scenarios

This document is applicable to scenarios in which you need to create differentiated instances for an existing TiDB cluster, such as the following:

  • Create TiKV clusters with different configurations and different labels for hotspot scheduling.
  • Create TiDB clusters with different configurations for OLTP and OLAP queries.

Prerequisites

You already have a TiDB cluster. If not,deploy a TiDB cluster on Kubernetesfirst.

Deploy a heterogeneous cluster

Depending on whether you need to enable Transport Layer Security (TLS) for a heterogeneous cluster, choose one of the following methods:

  • Deploy a heterogeneous cluster
  • Deploy a TLS-enabled heterogeneous cluster
  • non-TLS
  • TLS

To deploy a heterogeneous cluster, do the following:

  1. Create a cluster configuration file for the heterogeneous cluster.

    Run the following command to create a cluster configuration file for the heterogeneous cluster. Replace${origin_cluster_name}with the name of the existing cluster, and replace${heterogeneous_cluster_name}with the name of the heterogeneous cluster. To view the monitoring data of both the existing cluster and the heterogeneous cluster in the same Grafana of TidbMonitor, you need to name the heterogeneous cluster with the prefix of the existing cluster name.

    
                     
    origin_cluster_name=basic heterogeneous_cluster_name=basic-heterogcat> cluster.yaml <<EOF apiVersion: m.rzhenli.com/v1alpha1 kind: TidbCluster metadata: name: ${heterogeneous_cluster_name} spec: configUpdateStrategy: RollingUpdate version: v7.1.0 timezone: UTC pvReclaimPolicy: Delete discovery: {} cluster: name: ${origin_cluster_name} tikv: baseImage: pingcap/tikv maxFailoverCount: 0 replicas: 1 # If storageClassName is not set, the default Storage Class of the Kubernetes cluster is used. # storageClassName: local-storage requests: storage: "100Gi" config: {} tidb: baseImage: pingcap/tidb maxFailoverCount: 0 replicas: 1 service: type: ClusterIP config: {} tiflash: baseImage: pingcap/tiflash maxFailoverCount: 0 replicas: 1 storageClaims: - resources: requests: storage: 100Gi EOF

    For more configurations and field meanings of TiDB cluster, see theTiDB cluster configuration document.

  2. In the configuration file of your heterogeneous cluster, modify the configurations of each node according to your need.

    For example, you can modify the number ofreplicasfor each component in thecluster.yamlfile, or remove components that are not needed.

  3. Create the heterogeneous cluster by running the following command. You need to replacecluster.yamlwith the configuration filename of your heterogeneous cluster.

    
                     
    kubectl create -f cluster.yaml -n${namespace}

    If the output showstidbcluster.m.rzhenli.com/${heterogeneous_cluster_name} created, the execution is successful. Then, TiDB Operator will create the TiDB cluster with the configurations according to the cluster configuration file.

To enable TLS for a heterogeneous cluster, you need to explicitly declare the TLS configuration, issue the certificates using the same certification authority (CA) as the target cluster and create new secrets with the certificates.

If you want to issue the certificate usingcert-manager, choose the sameIssueras that of the target cluster to create yourCertificate.

For detailed procedures to create certificates for the heterogeneous cluster, refer to the following two documents:

After creating certificates, take the following steps to deploy a TLS-enabled heterogeneous cluster.

  1. Create a cluster configuration file for the heterogeneous cluster.

    例如,将以下配置保存为thecluster.yamlfile. Replace${heterogeneous_cluster_name}with the desired name of your heterogeneous cluster, and replace${origin_cluster_name}with the name of the existing cluster.

    
                     
    apiVersion: m.rzhenli.com/v1alpha1 kind: TidbCluster metadata: name: ${heterogeneous_cluster_name} spec: tlsCluster: enabled: true configUpdateStrategy: RollingUpdate version: v7.1.0 timezone: UTC pvReclaimPolicy: 删除 discovery:{}cluster: name: ${origin_cluster_name} tikv: baseImage: pingcap/tikv maxFailoverCount: 0 replicas: 1 # If storageClassName is not set, the default Storage Class of the Kubernetes cluster is used. # storageClassName: local-storage requests: storage: "100Gi" config:{}tidb: baseImage: pingcap/tidb maxFailoverCount: 0 replicas: 1 service: type: ClusterIP config:{}tlsClient: enabled: true tiflash: baseImage: pingcap/tiflash maxFailoverCount: 0 replicas: 1 storageClaims: - resources: requests: storage: 100Gi

    In the configuration file,spec.tlsCluster.enabledcontrols whether to enable TLS between the components andspec.tidb.tlsClient.enabledcontrols whether to enable TLS for the MySQL client.

  2. In the configuration file of your heterogeneous cluster, modify the configurations of each node according to your need.

    For example, you can modify the number ofreplicasfor each component in thecluster.yamlfile, or remove components that are not needed.

  3. 创建TLS-enabled heterogeneous cluster by running the following command. You need to replacecluster.yamlwith the configuration filename of the heterogeneous cluster.

    
                     
    kubectl create -f cluster.yaml -n${namespace}

    If the output showstidbcluster.m.rzhenli.com/${heterogeneous_cluster_name} created, the execution is successful. Then, TiDB Operator will create the TiDB cluster with the configurations according to your cluster configuration file.

Deploy a cluster monitoring component

If you need to deploy a monitoring component for a heterogeneous cluster, take the following steps to add the heterogeneous cluster name to the TidbMonitor CR file of an existing TiDB cluster.

  1. Edit the TidbMonitor Custom Resource (CR) of the existing TiDB cluster:

    
                    
    kubectl edit tm${cluster_name}-n${namespace}
  2. Replace${heterogeneous_cluster_name}with the desired name of your heterogeneous cluster, and replace${origin_cluster_name}with the name of the existing cluster. For example:

    
                    
    apiVersion: m.rzhenli.com/v1alpha1 kind: TidbMonitor metadata: name: heterogeneous spec: clusters: - name: ${origin_cluster_name} - name: ${heterogeneous_cluster_name} prometheus: baseImage: prom/prometheus version: v2.27.1 grafana: baseImage: grafana/grafana version: 7.5 .11 initializer: baseImage: pingcap/tidb-monitor-initializer version: v7.1.0 reloader: baseImage: pingcap/tidb-monitor-reloader version: v1.0.1 prometheusReloader: baseImage: quay.io/prometheus-operator/prometheus-config-reloader version: v0.49.0 imagePullPolicy: IfNotPresent
Download PDF Request docs changes Ask questions on Discord
Playground
New
One-stop & interactive experience of TiDB's capabilities WITHOUT registration.
Was this page helpful?
Products
TiDB
TiDB Dedicated
TiDB Serverless
Pricing
Get Demo
Get Started
©2023PingCAP. All Rights Reserved.