From bc8830ac3a5552c12e27eb1a8df3fead71a2926c Mon Sep 17 00:00:00 2001 From: Xuecheng Zhang Date: Thu, 28 Mar 2024 11:51:48 +0800 Subject: [PATCH 1/5] This is an automated cherry-pick of #2535 Signed-off-by: ti-chi-bot --- en/TOC.md | 1 - en/_index.md | 2 -- en/access-tidb.md | 2 +- en/deploy-tidb-operator.md | 5 ++++- en/get-started.md | 1 - en/replace-nodes-for-cloud-disk.md | 2 +- en/tidb-operator-overview.md | 1 - zh/TOC.md | 1 - zh/_index.md | 2 -- zh/access-tidb.md | 2 +- zh/deploy-tidb-operator.md | 5 ++++- zh/get-started.md | 1 - zh/replace-nodes-for-cloud-disk.md | 2 +- zh/tidb-operator-overview.md | 1 - 14 files changed, 12 insertions(+), 16 deletions(-) diff --git a/en/TOC.md b/en/TOC.md index 5308f8949..f13f738e9 100644 --- a/en/TOC.md +++ b/en/TOC.md @@ -18,7 +18,6 @@ - [Amazon EKS](deploy-on-aws-eks.md) - [Google Cloud GKE](deploy-on-gcp-gke.md) - [Azure AKS](deploy-on-azure-aks.md) - - [Alibaba Cloud ACK](deploy-on-alibaba-cloud.md) - [Deploy TiDB on ARM64 Machines](deploy-cluster-on-arm64.md) - [Deploy TiFlash to Explore TiDB HTAP](deploy-tiflash.md) - [Deploy TiProxy Load Balancer](deploy-tiproxy.md) diff --git a/en/_index.md b/en/_index.md index 74e766808..8eb1fa0ce 100644 --- a/en/_index.md +++ b/en/_index.md @@ -27,8 +27,6 @@ hide_commit: true [On Azure AKS](https://docs.pingcap.com/tidb-in-kubernetes/dev/deploy-on-azure-aks) -[On Alibaba ACK](https://docs.pingcap.com/tidb-in-kubernetes/dev/deploy-on-alibaba-cloud) - [On Self-managed Kubernetes](https://docs.pingcap.com/tidb-in-kubernetes/dev/deploy-on-general-kubernetes) diff --git a/en/access-tidb.md b/en/access-tidb.md index 54426b088..7027caa01 100644 --- a/en/access-tidb.md +++ b/en/access-tidb.md @@ -65,6 +65,6 @@ To check you can access TiDB services by using the IP of what nodes, see the fol If the TiDB cluster runs in an environment with LoadBalancer, such as on Google Cloud or AWS, it is recommended to use the LoadBalancer feature of these cloud platforms by setting `tidb.service.type=LoadBalancer`. -To access TiDB Service through LoadBalancer, refer to [EKS](deploy-on-aws-eks.md#install-the-mysql-client-and-connect), [GKE](deploy-on-gcp-gke.md#install-the-mysql-client-and-connect) and [ACK](deploy-on-alibaba-cloud.md#access-the-database). +To access TiDB Service through LoadBalancer, refer to [EKS](deploy-on-aws-eks.md#install-the-mysql-client-and-connect) and [GKE](deploy-on-gcp-gke.md#install-the-mysql-client-and-connect). See [Kubernetes Service Documentation](https://kubernetes.io/docs/concepts/services-networking/service/) to know more about the features of Service and what LoadBalancer in the cloud platform supports. diff --git a/en/deploy-tidb-operator.md b/en/deploy-tidb-operator.md index f68da4359..caf54dd6f 100644 --- a/en/deploy-tidb-operator.md +++ b/en/deploy-tidb-operator.md @@ -1,6 +1,10 @@ --- title: Deploy TiDB Operator on Kubernetes summary: Learn how to deploy TiDB Operator on Kubernetes. +<<<<<<< HEAD +======= +aliases: ['/docs/tidb-in-kubernetes/dev/deploy-tidb-operator/','/tidb-in-kubernetes/dev/deploy-on-alibaba-cloud','/docs/tidb-in-kubernetes/dev/deploy-on-alibaba-cloud/'] +>>>>>>> df689e8d (zh, en: remove docs about deploy on ACK (#2535)) --- # Deploy TiDB Operator on Kubernetes @@ -25,7 +29,6 @@ For some public cloud environments, refer to the following documents: - [Deploy on AWS EKS](deploy-on-aws-eks.md) - [Deploy on Google Cloud GKE](deploy-on-gcp-gke.md) -- [Deploy on Alibaba Cloud ACK](deploy-on-alibaba-cloud.md) TiDB Operator uses [Persistent Volumes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) to persist the data of TiDB cluster (including the database, monitoring data, and backup data), so the Kubernetes cluster must provide at least one kind of persistent volumes. diff --git a/en/get-started.md b/en/get-started.md index d92b4fefc..8fd7bd6ea 100644 --- a/en/get-started.md +++ b/en/get-started.md @@ -746,7 +746,6 @@ On public clouds: - [Deploy TiDB on AWS EKS](deploy-on-aws-eks.md) - [Deploy TiDB on Google Cloud GKE](deploy-on-gcp-gke.md) - [Deploy TiDB on Azure AKS](deploy-on-azure-aks.md) -- [Deploy TiDB on Alibaba Cloud ACK](deploy-on-alibaba-cloud.md) In a self-managed Kubernetes cluster: diff --git a/en/replace-nodes-for-cloud-disk.md b/en/replace-nodes-for-cloud-disk.md index c34d3265e..f60075abb 100644 --- a/en/replace-nodes-for-cloud-disk.md +++ b/en/replace-nodes-for-cloud-disk.md @@ -9,7 +9,7 @@ This document describes a method for replacing and upgrading nodes without downt This document uses Amazon EKS as an example and describes how to create a new node group and migrate a TiDB cluster to the new node group using a rolling restart. You can use this method to replace a node group with more compute resources for TiKV or TiDB and upgrade EKS. -For other cloud platforms, refer to [Google Cloud GKE](deploy-on-gcp-gke.md), [Azure AKS](deploy-on-azure-aks.md), or [Alibaba Cloud ACK](deploy-on-alibaba-cloud.md) and operate on the node group. +For other cloud platforms, refer to [Google Cloud GKE](deploy-on-gcp-gke.md) or [Azure AKS](deploy-on-azure-aks.md) and operate on the node group. ## Prerequisites diff --git a/en/tidb-operator-overview.md b/en/tidb-operator-overview.md index 22f909dbe..47d3fc117 100644 --- a/en/tidb-operator-overview.md +++ b/en/tidb-operator-overview.md @@ -34,7 +34,6 @@ TiDB Operator provides several ways to deploy TiDB clusters on Kubernetes: - [Deploy TiDB on AWS EKS](deploy-on-aws-eks.md) - [Deploy TiDB on Google Cloud GKE](deploy-on-gcp-gke.md) - [Deploy TiDB on Azure AKS](deploy-on-azure-aks.md) - - [Deploy TiDB on Alibaba Cloud ACK](deploy-on-alibaba-cloud.md) - In an existing Kubernetes cluster: diff --git a/zh/TOC.md b/zh/TOC.md index 7a2b9420a..c0237f64f 100644 --- a/zh/TOC.md +++ b/zh/TOC.md @@ -18,7 +18,6 @@ - [Amazon EKS](deploy-on-aws-eks.md) - [Google Cloud GKE](deploy-on-gcp-gke.md) - [Azure AKS](deploy-on-azure-aks.md) - - [阿里云 ACK](deploy-on-alibaba-cloud.md) - [在 ARM64 机器上部署 TiDB 集群](deploy-cluster-on-arm64.md) - [部署 TiDB HTAP 存储引擎 TiFlash](deploy-tiflash.md) - [部署 TiDB 负载均衡 TiProxy](deploy-tiproxy.md) diff --git a/zh/_index.md b/zh/_index.md index efd9fb5b0..8ec31b12f 100644 --- a/zh/_index.md +++ b/zh/_index.md @@ -27,8 +27,6 @@ hide_commit: true [部署到 Azure AKS](https://docs.pingcap.com/zh/tidb-in-kubernetes/dev/deploy-on-azure-aks) -[部署到阿里云 ACK](https://docs.pingcap.com/zh/tidb-in-kubernetes/dev/deploy-on-alibaba-cloud) - [部署到自托管的 Kubernetes](https://docs.pingcap.com/zh/tidb-in-kubernetes/dev/prerequisites) diff --git a/zh/access-tidb.md b/zh/access-tidb.md index ede6f0d61..cd1b79ab0 100644 --- a/zh/access-tidb.md +++ b/zh/access-tidb.md @@ -63,6 +63,6 @@ kubectl -n ${namespace} get svc ${cluster_name}-tidb -ojsonpath="{.spec.ports[?( 若运行在有 LoadBalancer 的环境,比如 Google Cloud、AWS 平台,建议使用云平台的 LoadBalancer 特性。 -参考 [EKS](deploy-on-aws-eks.md#安装-mysql-客户端并连接)、[GKE](deploy-on-gcp-gke.md#安装-mysql-客户端并连接) 和 [ACK](deploy-on-alibaba-cloud.md#连接数据库) 文档,通过 LoadBalancer 访问 TiDB 服务。 +参考 [EKS](deploy-on-aws-eks.md#安装-mysql-客户端并连接) 和 [GKE](deploy-on-gcp-gke.md#安装-mysql-客户端并连接) 文档,通过 LoadBalancer 访问 TiDB 服务。 访问 [Kubernetes Service 文档](https://kubernetes.io/docs/concepts/services-networking/service/),了解更多 Service 特性以及云平台 Load Balancer 支持。 diff --git a/zh/deploy-tidb-operator.md b/zh/deploy-tidb-operator.md index 70d70dac1..b76eec4bc 100644 --- a/zh/deploy-tidb-operator.md +++ b/zh/deploy-tidb-operator.md @@ -1,6 +1,10 @@ --- title: 在 Kubernetes 上部署 TiDB Operator summary: 了解如何在 Kubernetes 上部署 TiDB Operator。 +<<<<<<< HEAD +======= +aliases: ['/docs-cn/tidb-in-kubernetes/dev/deploy-tidb-operator/','/zh/tidb-in-kubernetes/dev/deploy-on-alibaba-cloud','/docs-cn/tidb-in-kubernetes/dev/deploy-on-alibaba-cloud/'] +>>>>>>> df689e8d (zh, en: remove docs about deploy on ACK (#2535)) --- # 在 Kubernetes 上部署 TiDB Operator @@ -25,7 +29,6 @@ TiDB Operator 运行在 Kubernetes 集群,你可以使用 [Getting started 页 - [部署到 AWS EKS](deploy-on-aws-eks.md) - [部署到 Google Cloud GKE](deploy-on-gcp-gke.md) -- [部署到阿里云 ACK](deploy-on-alibaba-cloud.md) TiDB Operator 使用[持久化卷](https://kubernetes.io/docs/concepts/storage/persistent-volumes/)持久化存储 TiDB 集群数据(包括数据库,监控和备份数据),所以 Kubernetes 集群必须提供至少一种持久化卷。 diff --git a/zh/get-started.md b/zh/get-started.md index d0c1902a0..e31e06aab 100644 --- a/zh/get-started.md +++ b/zh/get-started.md @@ -839,7 +839,6 @@ minikube delete - [在 AWS EKS 上部署 TiDB 集群](deploy-on-aws-eks.md) - [在 Google Cloud GKE 上部署 TiDB 集群](deploy-on-gcp-gke.md) - [在 Azure AKS 上部署 TiDB 集群](deploy-on-azure-aks.md) -- [在阿里云 ACK 上部署 TiDB 集群](deploy-on-alibaba-cloud.md) 自托管 Kubernetes 集群: diff --git a/zh/replace-nodes-for-cloud-disk.md b/zh/replace-nodes-for-cloud-disk.md index 8d079dca7..88435dfeb 100644 --- a/zh/replace-nodes-for-cloud-disk.md +++ b/zh/replace-nodes-for-cloud-disk.md @@ -11,7 +11,7 @@ summary: 介绍如何为使用云存储的 TiDB 集群更换节点。 > **注意:** > -> 其它公有云环境请参考 [Google Cloud GKE](deploy-on-gcp-gke.md)、[Azure AKS](deploy-on-azure-aks.md) 或[阿里云 ACK](deploy-on-alibaba-cloud.md) 操作节点组。 +> 其它公有云环境请参考 [Google Cloud GKE](deploy-on-gcp-gke.md) 或 [Azure AKS](deploy-on-azure-aks.md) 操作节点组。 ## 前置条件 diff --git a/zh/tidb-operator-overview.md b/zh/tidb-operator-overview.md index 3d82e03ea..5004ed330 100644 --- a/zh/tidb-operator-overview.md +++ b/zh/tidb-operator-overview.md @@ -37,7 +37,6 @@ TiDB Operator 提供了多种方式来部署 Kubernetes 上的 TiDB 集群: - [在 AWS EKS 上部署 TiDB 集群](deploy-on-aws-eks.md) - [在 Google Cloud GKE 上部署 TiDB 集群](deploy-on-gcp-gke.md) - [在 Azure AKS 上部署 TiDB 集群](deploy-on-azure-aks.md) - - [在阿里云 ACK 上部署 TiDB 集群](deploy-on-alibaba-cloud.md) - 在自托管的 Kubernetes 集群中部署 TiDB 集群: From 715a725188b85dead46ff72bfe4e2e710eebfb95 Mon Sep 17 00:00:00 2001 From: Aolin Date: Mon, 6 May 2024 14:56:24 +0800 Subject: [PATCH 2/5] Apply suggestions from code review --- en/deploy-tidb-operator.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/en/deploy-tidb-operator.md b/en/deploy-tidb-operator.md index caf54dd6f..4d53c6330 100644 --- a/en/deploy-tidb-operator.md +++ b/en/deploy-tidb-operator.md @@ -1,10 +1,7 @@ --- title: Deploy TiDB Operator on Kubernetes summary: Learn how to deploy TiDB Operator on Kubernetes. -<<<<<<< HEAD -======= -aliases: ['/docs/tidb-in-kubernetes/dev/deploy-tidb-operator/','/tidb-in-kubernetes/dev/deploy-on-alibaba-cloud','/docs/tidb-in-kubernetes/dev/deploy-on-alibaba-cloud/'] ->>>>>>> df689e8d (zh, en: remove docs about deploy on ACK (#2535)) +aliases: ['/tidb-in-kubernetes/v1.6/deploy-on-alibaba-cloud','/docs/tidb-in-kubernetes/v1.6/deploy-on-alibaba-cloud/'] --- # Deploy TiDB Operator on Kubernetes From 5201f1df9567697ca08b6e1ff03f304542ac446c Mon Sep 17 00:00:00 2001 From: Aolin Date: Mon, 6 May 2024 14:57:10 +0800 Subject: [PATCH 3/5] Apply suggestions from code review --- zh/deploy-tidb-operator.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/zh/deploy-tidb-operator.md b/zh/deploy-tidb-operator.md index b76eec4bc..efc4b462e 100644 --- a/zh/deploy-tidb-operator.md +++ b/zh/deploy-tidb-operator.md @@ -1,10 +1,7 @@ --- title: 在 Kubernetes 上部署 TiDB Operator summary: 了解如何在 Kubernetes 上部署 TiDB Operator。 -<<<<<<< HEAD -======= -aliases: ['/docs-cn/tidb-in-kubernetes/dev/deploy-tidb-operator/','/zh/tidb-in-kubernetes/dev/deploy-on-alibaba-cloud','/docs-cn/tidb-in-kubernetes/dev/deploy-on-alibaba-cloud/'] ->>>>>>> df689e8d (zh, en: remove docs about deploy on ACK (#2535)) +aliases: ['/zh/tidb-in-kubernetes/v1.6/deploy-on-alibaba-cloud','/docs-cn/tidb-in-kubernetes/v1.6/deploy-on-alibaba-cloud/'] --- # 在 Kubernetes 上部署 TiDB Operator From c34f7ad899ab1404084129549b9832f64f0ea576 Mon Sep 17 00:00:00 2001 From: Aolin Date: Mon, 6 May 2024 14:58:04 +0800 Subject: [PATCH 4/5] remove deploy-on-alibaba-cloud.md Signed-off-by: Aolin --- en/deploy-on-alibaba-cloud.md | 517 ---------------------------------- zh/deploy-on-alibaba-cloud.md | 506 --------------------------------- 2 files changed, 1023 deletions(-) delete mode 100644 en/deploy-on-alibaba-cloud.md delete mode 100644 zh/deploy-on-alibaba-cloud.md diff --git a/en/deploy-on-alibaba-cloud.md b/en/deploy-on-alibaba-cloud.md deleted file mode 100644 index 75f775318..000000000 --- a/en/deploy-on-alibaba-cloud.md +++ /dev/null @@ -1,517 +0,0 @@ ---- -title: Deploy TiDB on Alibaba Cloud Kubernetes -summary: Learn how to deploy a TiDB cluster on Alibaba Cloud Kubernetes. ---- - -# Deploy TiDB on Alibaba Cloud Kubernetes - -This document describes how to deploy a TiDB cluster on Alibaba Cloud Kubernetes with your laptop (Linux or macOS) for development or testing. - -To deploy TiDB Operator and the TiDB cluster in a self-managed Kubernetes environment, refer to [Deploy TiDB Operator](deploy-tidb-operator.md) and [Deploy TiDB on General Kubernetes](deploy-on-general-kubernetes.md). - -## Prerequisites - -- [`aliyun-cli`](https://github.com/aliyun/aliyun-cli) >= 3.0.15 and [configure `aliyun-cli`](https://www.alibabacloud.com/help/doc-detail/90766.htm?spm=a2c63.l28256.a3.4.7b52a893EFVglq) - - > **Note:** - > - > The access key must be granted permissions to control the corresponding resources. - -- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) >= 1.24 -- [Helm 3](https://helm.sh) -- [jq](https://stedolan.github.io/jq/download/) >= 1.6 -- [terraform](https://learn.hashicorp.com/terraform/getting-started/install.html) 0.12.* - -You can use [Cloud Shell](https://shell.aliyun.com) of Alibaba Cloud to perform operations. All the tools have been pre-installed and configured in the Cloud Shell of Alibaba Cloud. - -### Required privileges - -To deploy a TiDB cluster, make sure you have the following privileges: - -- AliyunECSFullAccess -- AliyunESSFullAccess -- AliyunVPCFullAccess -- AliyunSLBFullAccess -- AliyunCSFullAccess -- AliyunEIPFullAccess -- AliyunECIFullAccess -- AliyunVPNGatewayFullAccess -- AliyunNATGatewayFullAccess - -## Overview of things to create - -In the default configuration, you will create: - -- A new VPC -- An ECS instance as the bastion machine -- A managed ACK (Alibaba Cloud Kubernetes) cluster with the following ECS instance worker nodes: - - - An auto-scaling group of 2 * instances (2 cores, 2 GB RAM). The default auto-scaling group of managed Kubernetes must have at least two instances to host the whole system service, like CoreDNS - - An auto-scaling group of 3 * `ecs.g5.large` instances for deploying the PD cluster - - An auto-scaling group of 3 * `ecs.i2.2xlarge` instances for deploying the TiKV cluster - - An auto-scaling group of 2 * `ecs.c5.4xlarge` instances for deploying the TiDB cluster - - An auto-scaling group of 1 * `ecs.c5.xlarge` instance for deploying monitoring components - - A 100 GB cloud disk used to store monitoring data - -All the instances except ACK mandatory workers are deployed across availability zones (AZs) to provide cross-AZ high availability. The auto-scaling group ensures the desired number of healthy instances, so the cluster can auto-recover from node failure or even AZ failure. - -## Deploy - -### Deploy ACK, TiDB Operator and the node pool for TiDB cluster - -1. Configure the target region and Alibaba Cloud key (you can also set these variables in the `terraform` command prompt): - - {{< copyable "shell-regular" >}} - - ```shell - export TF_VAR_ALICLOUD_REGION=${REGION} && \ - export TF_VAR_ALICLOUD_ACCESS_KEY=${ACCESS_KEY} && \ - export TF_VAR_ALICLOUD_SECRET_KEY=${SECRET_KEY} - ``` - - The `variables.tf` file contains default settings of variables used for deploying the cluster. You can change it or use the `-var` option to override a specific variable to fit your need. - -2. Use Terraform to set up the cluster. - - {{< copyable "shell-regular" >}} - - ```shell - git clone --depth=1 https://github.com/pingcap/tidb-operator && \ - cd tidb-operator/deploy/aliyun - ``` - - You can create or modify `terraform.tfvars` to set the values of the variables, and configure the cluster to fit your needs. You can view the configurable variables and their descriptions in `variables.tf`. The following is an example of how to configure the ACK cluster name, the TiDB cluster name, the TiDB Operator version, and the number of PD, TiKV, and TiDB nodes. - - ``` - cluster_name = "testack" - tidb_cluster_name = "testdb" - tikv_count = 3 - tidb_count = 2 - pd_count = 3 - operator_version = "v1.6.0-beta.1" - ``` - - * To deploy TiFlash in the cluster, set `create_tiflash_node_pool = true` in `terraform.tfvars`. You can also configure the node count and instance type of the TiFlash node pool by modifying `tiflash_count` and `tiflash_instance_type`. By default, the value of `tiflash_count` is `2`, and the value of `tiflash_instance_type` is `ecs.i2.2xlarge`. - - * To deploy TiCDC in the cluster, set `create_cdc_node_pool = true` in `terraform.tfvars`. You can also configure the node count and instance type of the TiCDC node pool by modifying `cdc_count` and `cdc_instance_type`. By default, the value of `cdc_count` is `3`, and the value of `cdc_instance_type` is `ecs.c5.2xlarge`. - - > **Note:** - > - > Check the `operator_version` in the `variables.tf` file for the default TiDB Operator version of the current scripts. If the default version is not your desired one, configure `operator_version` in `terraform.tfvars`. - - After the configuration, execute the following commands to initialize and deploy the cluster: - - {{< copyable "shell-regular" >}} - - ```shell - terraform init - ``` - - Input "yes" to confirm execution when you run the following `apply` command: - - {{< copyable "shell-regular" >}} - - ```shell - terraform apply - ``` - - If you get an error while running `terraform apply`, fix the error (for example, lack of permission) according to the error description and run `terraform apply` again. - - It takes 5 to 10 minutes to create the whole stack using `terraform apply`. Once the installation is complete, the basic cluster information is printed: - - ``` - Apply complete! Resources: 3 added, 0 changed, 1 destroyed. - - Outputs: - - bastion_ip = 47.96.174.214 - cluster_id = c2d9b20854a194f158ef2bc8ea946f20e - - kubeconfig_file = /tidb-operator/deploy/aliyun/credentials/kubeconfig - monitor_endpoint = not_created - region = cn-hangzhou - ssh_key_file = /tidb-operator/deploy/aliyun/credentials/my-cluster-keyZ.pem - tidb_endpoint = not_created - tidb_version = v3.0.0 - vpc_id = vpc-bp1v8i5rwsc7yh8dwyep5 - ``` - - > **Note:** - > - > You can use the `terraform output` command to get the output again. - -3. You can then interact with the ACK cluster using `kubectl` or `helm`: - - {{< copyable "shell-regular" >}} - - ```shell - export KUBECONFIG=$PWD/credentials/kubeconfig - ``` - - {{< copyable "shell-regular" >}} - - ```shell - kubectl version - ``` - - {{< copyable "shell-regular" >}} - - ```shell - helm ls - ``` - -### Deploy the TiDB cluster and monitor - -1. Prepare the `TidbCluster`, `TidbDashboard`, and `TidbMonitor` CR files: - - {{< copyable "shell-regular" >}} - - ```shell - cp manifests/db.yaml.example db.yaml && \ - cp manifests/db-monitor.yaml.example db-monitor.yaml && \ - cp manifests/dashboard.yaml.example tidb-dashboard.yaml - ``` - - To complete the CR file configuration, refer to [TiDB Operator API documentation](https://github.com/pingcap/tidb-operator/blob/v1.6.0-beta.1/docs/api-references/docs.md) and [Configure a TiDB Cluster](configure-a-tidb-cluster.md). - - * To deploy TiFlash, configure `spec.tiflash` in `db.yaml` as follows: - - ```yaml - spec - ... - tiflash: - baseImage: pingcap/tiflash - maxFailoverCount: 0 - nodeSelector: - dedicated: TIDB_CLUSTER_NAME-tiflash - replicas: 1 - storageClaims: - - resources: - requests: - storage: 100Gi - storageClassName: local-volume - tolerations: - - effect: NoSchedule - key: dedicated - operator: Equal - value: TIDB_CLUSTER_NAME-tiflash - ``` - - To configure other parameters, refer to [Configure a TiDB Cluster](configure-a-tidb-cluster.md). - - Modify `replicas`, `storageClaims[].resources.requests.storage`, and `storageClassName` according to your needs. - - > **Warning:** - > - > Since TiDB Operator will mount PVs automatically in the **order** of the items in the `storageClaims` list, if you need to add more disks to TiFlash, make sure to append the new item only to the **end** of the original items, and **DO NOT** modify the order of the original items. - - * To deploy TiCDC, configure `spec.ticdc` in `db.yaml` as follows: - - ```yaml - spec - ... - ticdc: - baseImage: pingcap/ticdc - nodeSelector: - dedicated: TIDB_CLUSTER_NAME-cdc - replicas: 3 - tolerations: - - effect: NoSchedule - key: dedicated - operator: Equal - value: TIDB_CLUSTER_NAME-cdc - ``` - - Modify `replicas` according to your needs. - - > **Note:** - > - > * Replace all the `TIDB_CLUSTER_NAME` in the `db.yaml` and `db-monitor.yaml` files with `tidb_cluster_name` configured in the deployment of ACK. - > * Make sure the number of PD, TiKV, TiFlash, TiCDC, or TiDB nodes is >= the `replicas` value of the corresponding component in `db.yaml`. - > * Make sure `spec.initializer.version` in `db-monitor.yaml` is the same as `spec.version` in `db.yaml`. Otherwise, the monitor might not display correctly. - -2. Create `Namespace`: - - {{< copyable "shell-regular" >}} - - ```shell - kubectl --kubeconfig credentials/kubeconfig create namespace ${namespace} - ``` - - > **Note:** - > - > You can give the [`namespace`](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/) a name that is easy to memorize, such as the same name as `tidb_cluster_name`. - -3. Deploy the TiDB cluster: - - {{< copyable "shell-regular" >}} - - ```shell - kubectl --kubeconfig credentials/kubeconfig create -f db.yaml -n ${namespace} && - kubectl --kubeconfig credentials/kubeconfig create -f db-monitor.yaml -n ${namespace} - ``` - -> **Note:** -> -> If you need to deploy a TiDB cluster on ARM64 machines, refer to [Deploy a TiDB Cluster on ARM64 Machines](deploy-cluster-on-arm64.md). - -## Access the database - -You can connect the TiDB cluster via the bastion instance. All necessary information is in the output printed after installation is finished (replace the `${}` parts with values from the output): - -{{< copyable "shell-regular" >}} - -```shell -ssh -i credentials/${cluster_name}-key.pem root@${bastion_ip} -``` - -{{< copyable "shell-regular" >}} - -```shell -mysql --comments -h ${tidb_lb_ip} -P 4000 -u root -``` - -`tidb_lb_ip` is the LoadBalancer IP of the TiDB service. - -> **Note:** -> -> * [The default authentication plugin of MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin) is updated from `mysql_native_password` to `caching_sha2_password`. Therefore, if you use MySQL client from MySQL 8.0 to access the TiDB service (TiDB version < v4.0.7), and if the user account has a password, you need to explicitly specify the `--default-auth=mysql_native_password` parameter. -> * By default, TiDB (versions starting from v4.0.2 and released before February 20, 2023) periodically shares usage details with PingCAP to help understand how to improve the product. For details about what is shared and how to disable the sharing, see [Telemetry](https://docs.pingcap.com/tidb/stable/telemetry). Starting from February 20, 2023, the telemetry feature is disabled by default in newly released TiDB versions. See [TiDB Release Timeline](https://docs.pingcap.com/tidb/stable/release-timeline) for details. - -## Access Grafana - -Visit `:3000` to view the Grafana dashboards. `monitor-lb` is the LoadBalancer IP of the Monitor service. - -The initial login user account and password: - -- User: admin -- Password: admin - -> **Warning:** -> -> If you already have a VPN connecting to your VPC or plan to set up one, it is strongly recommended that you go to the `spec.grafana.service.annotations` section in the `db-monitor.yaml` file and set `service.beta.kubernetes.io/alicloud-loadbalancer-address-type` to `intranet` for security. - -## Access TiDB Dashboard Web UI - -You can view Grafana monitoring metrics by visiting `:12333` in your browser. - -`tidb-dashboard-exposed` is the `LoadBalancer` IP of the TiDB Dashboard service. - -> **Warning:** -> -> If you already have a VPN connecting to your VPC or plan to set up one, it is strongly recommended that you go to the `spec.grafana.service.annotations` section in the `db-monitor.yaml` file and set `service.beta.kubernetes.io/alicloud-loadbalancer-address-type` to `intranet` for security. - -## Upgrade - -To upgrade the TiDB cluster, modify the `spec.version` variable by executing `kubectl --kubeconfig credentials/kubeconfig patch tc ${tidb_cluster_name} -n ${namespace} --type merge -p '{"spec":{"version":"${version}"}}`. - -This may take a while to complete. You can watch the process using the following command: - -{{< copyable "shell-regular" >}} - -```shell -kubectl get pods --namespace ${namespace} -o wide --watch -``` - -## Scale out the TiDB cluster - -To scale out the TiDB cluster, modify `tikv_count`, `tiflash_count`, `cdc_count`, or `tidb_count` in the `terraform.tfvars` file, and then run `terraform apply` to scale out the number of nodes for the corresponding components. - -After the nodes scale out, modify the `replicas` of the corresponding components by running `kubectl --kubeconfig credentials/kubeconfig edit tc ${tidb_cluster_name} -n ${namespace}`. - -> **Note:** -> -> - Because it is impossible to determine which node will be taken offline during the scale-in process, the scale-in of TiDB clusters is currently not supported. -> - The scale-out process takes a few minutes. You can watch the status by running `kubectl --kubeconfig credentials/kubeconfig get po -n ${namespace} --watch`. - -## Configure - -### Configure TiDB Operator - -You can set the variables in `terraform.tfvars` to configure TiDB Operator. Most configuration items can be modified after you understand the semantics based on the comments of the `variable`. Note that the `operator_helm_values` configuration item can provide a customized `values.yaml` configuration file for TiDB Operator. For example: - -- Set `operator_helm_values` in `terraform.tfvars`: - - ```hcl - operator_helm_values = "./my-operator-values.yaml" - ``` - -- Set `operator_helm_values` in `main.tf`: - - ```hcl - operator_helm_values = file("./my-operator-values.yaml") - ``` - -In the default configuration, the Terraform script creates a new VPC. To use the existing VPC, set `vpc_id` in `variable.tf`. In this case, Kubernetes nodes are not deployed in AZs with vSwitch not configured. - -### Configure the TiDB cluster - -See [TiDB Operator API Documentation](https://github.com/pingcap/tidb-operator/blob/v1.6.0-beta.1/docs/api-references/docs.md) and [Configure a TiDB Cluster](configure-a-tidb-cluster.md). - -## Manage multiple TiDB clusters - -To manage multiple TiDB clusters in a single Kubernetes cluster, you need to edit `./main.tf` and add the `tidb-cluster` declaration based on your needs. For example: - -```hcl -module "tidb-cluster-dev" { - source = "../modules/aliyun/tidb-cluster" - providers = { - helm = helm.default - } - - cluster_name = "dev-cluster" - ack = module.tidb-operator - - pd_count = 1 - tikv_count = 1 - tidb_count = 1 -} - -module "tidb-cluster-staging" { - source = "../modules/aliyun/tidb-cluster" - providers = { - helm = helm.default - } - - cluster_name = "staging-cluster" - ack = module.tidb-operator - - pd_count = 3 - tikv_count = 3 - tidb_count = 2 -} -``` - -> **Note:** -> -> You need to set a unique `cluster_name` for each TiDB cluster. - -All the configurable parameters in `tidb-cluster` are as follows: - -| Parameter | Description | Default value | -| :----- | :---- | :----- | -| `ack` | The structure that enwraps the target Kubernetes cluster information (required) | `nil` | -| `cluster_name` | The TiDB cluster name (required and unique) | `nil` | -| `tidb_version` | The TiDB cluster version | `v3.0.1` | -| `tidb_cluster_chart_version` | `tidb-cluster` helm chart version | `v1.0.1` | -| `pd_count` | The number of PD nodes | 3 | -| `pd_instance_type` | The PD instance type | `ecs.g5.large` | -| `tikv_count` | The number of TiKV nodes | 3 | -| `tikv_instance_type` | The TiKV instance type | `ecs.i2.2xlarge` | -| `tiflash_count` | The count of TiFlash nodes | 2 | -| `tiflash_instance_type` | The TiFlash instance type | `ecs.i2.2xlarge` | -| `cdc_count` | The count of TiCDC nodes | 3 | -| `cdc_instance_type` | The TiCDC instance type | `ecs.c5.2xlarge` | -| `tidb_count` | The number of TiDB nodes | 2 | -| `tidb_instance_type` | The TiDB instance type | `ecs.c5.4xlarge` | -| `monitor_instance_type` | The instance type of monitoring components | `ecs.c5.xlarge` | -| `override_values` | The `values.yaml` configuration file of the TiDB cluster. You can read it using the `file()` function | `nil` | -| `local_exec_interpreter` | The interpreter that executes the command line instruction | `["/bin/sh", "-c"]` | -| `create_tidb_cluster_release` | Whether to create the TiDB cluster using Helm | `false` | - -## Manage multiple Kubernetes clusters - -It is recommended to use a separate Terraform module to manage a specific Kubernetes cluster. (A Terraform module is a directory that contains the `.tf` script.) - -`deploy/aliyun` combines multiple reusable Terraform scripts in `deploy/modules`. To manage multiple clusters, perform the following operations in the root directory of the `tidb-operator` project: - -1. Create a directory for each cluster. For example: - - {{< copyable "shell-regular" >}} - - ```shell - mkdir -p deploy/aliyun-staging - ``` - -2. Refer to `main.tf` in `deploy/aliyun` and write your own script. For example: - - ```hcl - provider "alicloud" { - region = ${REGION} - access_key = ${ACCESS_KEY} - secret_key = ${SECRET_KEY} - } - - module "tidb-operator" { - source = "../modules/aliyun/tidb-operator" - - region = ${REGION} - access_key = ${ACCESS_KEY} - secret_key = ${SECRET_KEY} - cluster_name = "example-cluster" - key_file = "ssh-key.pem" - kubeconfig_file = "kubeconfig" - } - - provider "helm" { - alias = "default" - insecure = true - install_tiller = false - kubernetes { - config_path = module.tidb-operator.kubeconfig_filename - } - } - - module "tidb-cluster" { - source = "../modules/aliyun/tidb-cluster" - providers = { - helm = helm.default - } - - cluster_name = "example-cluster" - ack = module.tidb-operator - } - - module "bastion" { - source = "../modules/aliyun/bastion" - - bastion_name = "example-bastion" - key_name = module.tidb-operator.key_name - vpc_id = module.tidb-operator.vpc_id - vswitch_id = module.tidb-operator.vswitch_ids[0] - enable_ssh_to_worker = true - worker_security_group_id = module.tidb-operator.security_group_id - } - ``` - -You can customize this script. For example, you can remove the `module "bastion"` declaration if you do not need the bastion machine. - -> **Note:** -> -> You can copy the `deploy/aliyun` directory. But you cannot copy a directory on which the `terraform apply` operation is currently performed. In this case, it is recommended to clone the repository again and then copy it. - -## Destroy - -1. Refer to [Destroy a TiDB cluster](destroy-a-tidb-cluster.md) to delete the cluster. - -2. Destroy the ACK cluster by running the following command: - - {{< copyable "shell-regular" >}} - - ```shell - terraform destroy - ``` - -If the Kubernetes cluster is not successfully created, the `destroy` operation might return an error and fail. In such cases, manually remove the Kubernetes resources from the local state: - -{{< copyable "shell-regular" >}} - -```shell -terraform state list -``` - -{{< copyable "shell-regular" >}} - -```shell -terraform state rm module.ack.alicloud_cs_managed_kubernetes.k8s -``` - -It may take a long time to finish destroying the cluster. - -> **Note:** -> -> You have to manually delete the cloud disk used by the components in the Alibaba Cloud console. - -## Limitation - -You cannot change `pod cidr`, `service cidr`, and worker instance types once the cluster is created. diff --git a/zh/deploy-on-alibaba-cloud.md b/zh/deploy-on-alibaba-cloud.md deleted file mode 100644 index 049ecbb3c..000000000 --- a/zh/deploy-on-alibaba-cloud.md +++ /dev/null @@ -1,506 +0,0 @@ ---- -title: 在阿里云上部署 TiDB 集群 -summary: 介绍如何在阿里云上部署 TiDB 集群。 ---- - -# 在阿里云上部署 TiDB 集群 - -本文介绍了如何使用个人电脑(Linux 或 macOS 系统)在阿里云上部署 TiDB 集群。 - -如果需要部署 TiDB Operator 及 TiDB 集群到自托管 Kubernetes 环境,请参考[部署 TiDB Operator](deploy-tidb-operator.md)及[部署 TiDB 集群](deploy-on-general-kubernetes.md)等文档。 - -## 环境需求 - -- [aliyun-cli](https://github.com/aliyun/aliyun-cli) >= 3.0.15 并且[配置 aliyun-cli](https://www.alibabacloud.com/help/doc-detail/90766.htm?spm=a2c63.l28256.a3.4.7b52a893EFVglq) - - > **注意:** - > - > Access Key 需要具有操作相应资源的权限。 - -- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl) >= 1.24 -- [Helm 3](https://helm.sh) -- [jq](https://stedolan.github.io/jq/download/) >= 1.6 -- [terraform](https://learn.hashicorp.com/terraform/getting-started/install.html) 0.12.* - -你可以使用阿里云的[云命令行](https://shell.aliyun.com)服务来进行操作,云命令行中已经预装并配置好了所有工具。 - -### 权限 - -完整部署集群需要具备以下权限: - -- AliyunECSFullAccess -- AliyunESSFullAccess -- AliyunVPCFullAccess -- AliyunSLBFullAccess -- AliyunCSFullAccess -- AliyunEIPFullAccess -- AliyunECIFullAccess -- AliyunVPNGatewayFullAccess -- AliyunNATGatewayFullAccess - -## 概览 - -默认配置下,会创建: - -- 一个新的 VPC -- 一台 ECS 实例作为堡垒机 -- 一个托管版 ACK(阿里云 Kubernetes)集群以及一系列 worker 节点: - - 属于一个伸缩组的 2 台 ECS 实例(2 核 2 GB),托管版 Kubernetes 的默认伸缩组中必须至少有两台实例,用于承载整个的系统服务,例如 CoreDNS - - 属于一个伸缩组的 3 台 `ecs.g5.large` 实例,用于部署 PD - - 属于一个伸缩组的 3 台 `ecs.i2.2xlarge` 实例,用于部署 TiKV - - 属于一个伸缩组的 2 台 `ecs.c5.4xlarge` 实例用于部署 TiDB - - 属于一个伸缩组的 1 台 `ecs.c5.xlarge` 实例用于部署监控组件 - -除了默认伸缩组之外的其它所有实例都是跨可用区部署的。而伸缩组 (Auto-scaling Group) 能够保证集群的健康实例数等于期望数值。因此,当发生节点故障甚至可用区故障时,伸缩组能够自动为我们创建新实例来确保服务可用性。 - -## 安装部署 - -### 部署 ACK,TiDB Operator 和 TiDB 集群节点池 - -使用如下步骤部署 ACK,TiDB Operator 和 TiDB 集群节点池。 - -1. 设置目标 region 和阿里云密钥(也可以在运行 `terraform` 命令时根据命令提示输入): - - {{< copyable "shell-regular" >}} - - ```shell - export TF_VAR_ALICLOUD_REGION=${REGION} && \ - export TF_VAR_ALICLOUD_ACCESS_KEY=${ACCESS_KEY} && \ - export TF_VAR_ALICLOUD_SECRET_KEY=${SECRET_KEY} - ``` - - 用于部署集群的各变量的默认值存储在 `variables.tf` 文件中,如需定制可以修改此文件或在安装时通过 `-var` 参数覆盖。 - -2. 使用 Terraform 进行安装: - - {{< copyable "shell-regular" >}} - - ```shell - git clone --depth=1 https://github.com/pingcap/tidb-operator && \ - cd tidb-operator/deploy/aliyun - ``` - - 可以新建或者编辑 `terraform.tfvars`,在其中设置变量的值,按需配置集群,可以通过 `variables.tf` 查看有哪些变量可以设置以及各变量的详细描述。例如,下面示例配置 ACK 集群名称、TiDB 集群名称,TiDB Operator 版本及 PD、TiKV 和 TiDB 节点的数量: - - ``` - cluster_name = "testack" - tidb_cluster_name = "testdb" - tikv_count = 3 - tidb_count = 2 - pd_count = 3 - operator_version = "v1.6.0-beta.1" - ``` - - 如果需要在集群中部署 TiFlash,需要在 `terraform.tfvars` 中设置 `create_tiflash_node_pool = true`,也可以设置 `tiflash_count` 和 `tiflash_instance_type` 来配置 TiFlash 节点池的节点数量和实例类型,`tiflash_count` 默认为 `2`,`tiflash_instance_type` 默认为 `ecs.i2.2xlarge`。 - - 如果需要在集群中部署 TiCDC,需要在 `terraform.tfvars` 中设置 `create_cdc_node_pool = true`,也可以设置 `cdc_count` 和 `cdc_instance_type` 来配置 TiCDC 节点池的节点数量和实例类型,`cdc_count` 默认为 `3`,`cdc_instance_type` 默认为 `ecs.c5.2xlarge`。 - - > **注意:** - > - > 请通过 `variables.tf` 文件中的 `operator_version` 确认当前版本脚本中默认的 TiDB Operator 版本,如果默认版本不是想要使用的版本,请在 `terraform.tfvars` 中配置 `operator_version`。 - - 配置完成后,使用 `terraform` 命令初始化并部署集群: - - {{< copyable "shell-regular" >}} - - ```shell - terraform init - ``` - - `apply` 过程中需要输入 `yes` 来确认执行: - - {{< copyable "shell-regular" >}} - - ```shell - terraform apply - ``` - - 假如在运行 `terraform apply` 时出现报错,可根据报错信息(例如缺少权限)进行修复后再次运行 `terraform apply`。 - - 整个安装过程大约需要 5 至 10 分钟,安装完成后会输出集群的关键信息(想要重新查看这些信息,可以运行 `terraform output`): - - ``` - Apply complete! Resources: 3 added, 0 changed, 1 destroyed. - - Outputs: - - bastion_ip = 47.96.174.214 - cluster_id = c2d9b20854a194f158ef2bc8ea946f20e - kubeconfig_file = /tidb-operator/deploy/aliyun/credentials/kubeconfig - monitor_endpoint = not_created - region = cn-hangzhou - ssh_key_file = /tidb-operator/deploy/aliyun/credentials/my-cluster-keyZ.pem - tidb_endpoint = not_created - tidb_version = v3.0.0 - vpc_id = vpc-bp1v8i5rwsc7yh8dwyep5 - ``` - -3. 用 `kubectl` 或 `helm` 对集群进行操作: - - {{< copyable "shell-regular" >}} - - ```shell - export KUBECONFIG=$PWD/credentials/kubeconfig - ``` - - {{< copyable "shell-regular" >}} - - ```shell - kubectl version - ``` - - {{< copyable "shell-regular" >}} - - ```shell - helm ls - ``` - -### 部署 TiDB 集群和监控 - -1. 准备 TidbCluster、TidbDashboard 和 TidbMonitor CR 文件: - - {{< copyable "shell-regular" >}} - - ```shell - cp manifests/db.yaml.example db.yaml && \ - cp manifests/db-monitor.yaml.example db-monitor.yaml && \ - cp manifests/dashboard.yaml.example tidb-dashboard.yaml - ``` - - 参考 [API 文档](https://github.com/pingcap/tidb-operator/blob/v1.6.0-beta.1/docs/api-references/docs.md)和[集群配置文档](configure-a-tidb-cluster.md)完成 CR 文件配置。 - - 如果要部署 TiFlash,可以在 db.yaml 中配置 `spec.tiflash`,例如: - - ```yaml - spec - ... - tiflash: - baseImage: pingcap/tiflash - maxFailoverCount: 0 - nodeSelector: - dedicated: TIDB_CLUSTER_NAME-tiflash - replicas: 1 - storageClaims: - - resources: - requests: - storage: 100Gi - storageClassName: local-volume - tolerations: - - effect: NoSchedule - key: dedicated - operator: Equal - value: TIDB_CLUSTER_NAME-tiflash - ``` - - 其他参数可以参考[集群配置文档](configure-a-tidb-cluster.md)进行配置。 - - 根据实际情况修改 `replicas`、`storageClaims[].resources.requests.storage`、`storageClassName`。 - - > **警告:** - > - > 由于 TiDB Operator 会按照 `storageClaims` 列表中的配置**按顺序**自动挂载 PV,如果需要为 TiFlash 增加磁盘,请确保只在列表原有配置**最后添加**,并且**不能**修改列表中原有配置的顺序。 - - 如果要部署 TiCDC,可以在 db.yaml 中配置 `spec.ticdc`,例如: - - ```yaml - spec - ... - ticdc: - baseImage: pingcap/ticdc - nodeSelector: - dedicated: TIDB_CLUSTER_NAME-cdc - replicas: 3 - tolerations: - - effect: NoSchedule - key: dedicated - operator: Equal - value: TIDB_CLUSTER_NAME-cdc - ``` - - 根据实际情况修改 `replicas`。 - - > **注意:** - > - > * 请使用 ACK 部署过程中配置的 `tidb_cluster_name` 替换 `db.yaml` 和 `db-monitor.yaml` 文件中所有的 `TIDB_CLUSTER_NAME`。 - > * 请确保 ACK 部署过程中 PD、TiKV、TiFlash、TiCDC 或者 TiDB 节点的数量的值大于等于 `db.yaml` 中对应组件的 `replicas`。 - > * 请确保 `db-monitor.yaml` 中 `spec.initializer.version` 和 `db.yaml` 中 `spec.version` 一致,以保证监控显示正常。 - -2. 创建 `Namespace`: - - {{< copyable "shell-regular" >}} - - ```shell - kubectl --kubeconfig credentials/kubeconfig create namespace ${namespace} - ``` - - > **注意:** - > - > `namespace` 是[命名空间](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/),可以起一个方便记忆的名字,比如和 `tidb_cluster_name` 相同的名称。 - -3. 部署 TiDB 集群: - - {{< copyable "shell-regular" >}} - - ```shell - kubectl --kubeconfig credentials/kubeconfig create -f db.yaml -n ${namespace} && - kubectl --kubeconfig credentials/kubeconfig create -f db-monitor.yaml -n ${namespace} - ``` - -> **注意:** -> -> 如果要将 TiDB 集群部署到 ARM64 机器上,可以参考[在 ARM64 机器上部署 TiDB 集群](deploy-cluster-on-arm64.md)。 - -## 连接数据库 - -通过堡垒机可连接 TiDB 集群进行测试,相关信息在安装完成后的输出中均可找到: - -{{< copyable "shell-regular" >}} - -```shell -ssh -i credentials/${cluster_name}-key.pem root@${bastion_ip} -``` - -{{< copyable "shell-regular" >}} - -```shell -mysql --comments -h ${tidb_lb_ip} -P 4000 -u root -``` - -`tidb_lb_ip` 为 TiDB Service 的 LoadBalancer IP。 - -> **注意:** -> -> * [MySQL 8.0 默认认证插件](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin)从 `mysql_native_password` 更新为 `caching_sha2_password`,因此如果使用 MySQL 8.0 客户端访问 TiDB 服务(TiDB 版本 < v4.0.7),并且用户账户有配置密码,需要显示指定 `--default-auth=mysql_native_password` 参数。 -> * TiDB(v4.0.2 起且发布于 2023 年 2 月 20 日前的版本)默认会定期收集使用情况信息,并将这些信息分享给 PingCAP 用于改善产品。若要了解所收集的信息详情及如何禁用该行为,请参见 [TiDB 遥测功能使用文档](https://docs.pingcap.com/zh/tidb/stable/telemetry)。自 2023 年 2 月 20 日起,新发布的 TiDB 版本默认不再收集使用情况信息分享给 PingCAP,参见 [TiDB 版本发布时间线](https://docs.pingcap.com/zh/tidb/stable/release-timeline)。 - -## 访问 Grafana 监控 - -你可以通过浏览器访问 `:3000` 地址查看 Grafana 监控指标。 - -`monitor-lb` 是集群 Monitor Service 的 LoadBalancer IP。 - -默认帐号密码为: - -- 用户名:admin -- 密码:admin - -> **警告:** -> -> 出于安全考虑,假如你已经或将要配置 VPN 用于访问 VPC,强烈建议将 `db-monitor.yaml` 文件里 `spec.grafana.service.annotations` 中的 `service.beta.kubernetes.io/alicloud-loadbalancer-address-type` 设置为 `intranet` 以禁止监控服务的公网访问。 - -## 访问 TiDB Dashboard Web UI - -你可以通过浏览器访问 `:12333` 地址查看 Grafana 监控指标。 - -`tidb-dashboard-exposed` 是集群 TiDB Dashboard Service 的 `LoadBalancer` IP。 - -> **警告:** -> -> 出于安全考虑,假如你已经或将要配置 VPN 用于访问 VPC,强烈建议将 `db-monitor.yaml` 文件里 `spec.grafana.service.annotations` 中的 `service.beta.kubernetes.io/alicloud-loadbalancer-address-type` 设置为 `intranet` 以禁止监控服务的公网访问。 - -## 升级 TiDB 集群 - -要升级 TiDB 集群,可以通过 `kubectl --kubeconfig credentials/kubeconfig patch tc ${tidb_cluster_name} -n ${namespace} --type merge -p '{"spec":{"version":"${version}"}}'` 修改 `spec.version`。 - -升级操作可能会执行较长时间,可以通过以下命令来持续观察进度: - -{{< copyable "shell-regular" >}} - -``` -kubectl get pods --namespace ${namespace} -o wide --watch -``` - -## TiDB 集群扩容 - -若要扩容 TiDB 集群,可以在文件 `terraform.tfvars` 文件中设置 `tikv_count`、`tiflash_count`、`cdc_count` 或者 `tidb_count` 变量,然后运行 `terraform apply`,扩容对应组件节点数量,节点扩容完成后,通过 `kubectl --kubeconfig credentials/kubeconfig edit tc ${tidb_cluster_name} -n ${namespace}` 修改对应组件的 `replicas`。 - -> **注意:** -> -> - 由于缩容过程中无法确定会缩掉哪个节点,目前还不支持 TiDB 集群的缩容。 -> - 扩容过程会持续几分钟,你可以通过 `kubectl --kubeconfig credentials/kubeconfig get po -n ${namespace} --watch` 命令持续观察进度。 - -## 销毁集群 - -可以参考[销毁 TiDB 集群](destroy-a-tidb-cluster.md#销毁-kubernetes-上的-tidb-集群)删除集群。 - -然后通过如下命令销毁 ACK 集群: - -{{< copyable "shell-regular" >}} - -```shell -terraform destroy -``` - -假如 Kubernetes 集群没有创建成功,那么在 destroy 时会出现报错,无法进行正常清理。此时需要手动将 Kubernetes 资源从本地状态中移除: - -{{< copyable "shell-regular" >}} - -```shell -terraform state list -``` - -{{< copyable "shell-regular" >}} - -```shell -terraform state rm module.ack.alicloud_cs_managed_kubernetes.k8s -``` - -销毁集群操作需要执行较长时间。 - -> **注意:** -> -> 组件挂载的云盘需要在阿里云管理控制台中手动删除。 - -## 配置 - -### 配置 TiDB Operator - -通过在 `terraform.tfvars` 中设置变量的值来配置 TiDB Operator,大多数配置项均能按照 `variable` 的注释理解语义后进行修改。需要注意的是,`operator_helm_values` 配置项允许为 TiDB Operator 提供一个自定义的 `values.yaml` 配置文件,示例如下: - -- 在 `terraform.tfvars` 中设置 `operator_helm_values`: - - ```hcl - operator_helm_values = "./my-operator-values.yaml" - ``` - -- 在 `main.tf` 中设置 `operator_helm_values`: - - ```hcl - operator_helm_values = file("./my-operator-values.yaml") - ``` - -同时,在默认配置下 Terraform 脚本会创建一个新的 VPC,假如要使用现有的 VPC,可以在 `variable.tf` 中设置 `vpc_id`。注意,当使用现有 VPC 时,没有设置 vswitch 的可用区将不会部署 Kubernetes 节点。 - -### 配置 TiDB 集群 - -参考 [API 文档](https://github.com/pingcap/tidb-operator/blob/v1.6.0-beta.1/docs/api-references/docs.md)和[集群配置文档](configure-a-tidb-cluster.md)修改 TiDB 集群配置。 - -## 管理多个 TiDB 集群 - -需要在一个 Kubernetes 集群下管理多个 TiDB 集群时,需要编辑 `./main.tf`,按实际需要新增 `tidb-cluster` 声明,示例如下: - -```hcl -module "tidb-cluster-dev" { - source = "../modules/aliyun/tidb-cluster" - providers = { - helm = helm.default - } - - cluster_name = "dev-cluster" - ack = module.tidb-operator - - pd_count = 1 - tikv_count = 1 - tidb_count = 1 -} - -module "tidb-cluster-staging" { - source = "../modules/aliyun/tidb-cluster" - providers = { - helm = helm.default - } - - cluster_name = "staging-cluster" - ack = module.tidb-operator - - pd_count = 3 - tikv_count = 3 - tidb_count = 2 -} -``` - -注意,多个 TiDB 集群之间 `cluster_name` 必须保持唯一。下面是 `tidb-cluster` 模块的所有可配置参数: - -| 参数名 | 说明 | 默认值 | -| :----- | :---- | :----- | -| `ack` | 封装目标 Kubernetes 集群信息的结构体,必填 | `nil` | -| `cluster_name` | TiDB 集群名,必填且必须唯一 | `nil` | -| `tidb_version` | TiDB 集群版本 | `v3.0.1` | -| `tidb_cluster_chart_version` | `tidb-cluster` helm chart 的版本 | `v1.0.1` | -| `pd_count` | PD 节点数 | 3 | -| `pd_instance_type` | PD 实例类型 | `ecs.g5.large` | -| `tikv_count` | TiKV 节点数 | 3 | -| `tikv_instance_type` | TiKV 实例类型 | `ecs.i2.2xlarge` | -| `tiflash_count` | TiFlash 节点数 | 2 | -| `tiflash_instance_type` | TiFlash 实例类型 | `ecs.i2.2xlarge` | -| `cdc_count` | TiCDC 节点数 | 3 | -| `cdc_instance_type` | TiCDC 实例类型 | `ecs.c5.2xlarge` | -| `tidb_count` | TiDB 节点数 | 2 | -| `tidb_instance_type` | TiDB 实例类型 | `ecs.c5.4xlarge` | -| `monitor_instance_type` | 监控组件的实例类型 | `ecs.c5.xlarge` | -| `override_values` | TiDB 集群的 `values.yaml` 配置文件,通常通过 `file()` 函数从文件中读取 | `nil` | -| `local_exec_interpreter` | 执行命令行指令的解释器 | `["/bin/sh", "-c"]` | -| `create_tidb_cluster_release` | 是否通过 Helm 创建 TiDB 集群 | `false` | - -## 管理多个 Kubernetes 集群 - -推荐针对每个 Kubernetes 集群都使用单独的 Terraform 模块进行管理(一个 Terraform Module 即一个包含 `.tf` 脚本的目录)。 - -`deploy/aliyun` 实际上是将 `deploy/modules` 中的数个可复用的 Terraform 脚本组合在了一起。当管理多个集群时(下面的操作在 `tidb-operator` 项目根目录下进行): - -1. 首先针对每个集群创建一个目录,如: - - {{< copyable "shell-regular" >}} - - ```shell - mkdir -p deploy/aliyun-staging - ``` - -2. 参考 `deploy/aliyun` 的 `main.tf`,编写自己的脚本,下面是一个简单的例子: - - ```hcl - provider "alicloud" { - region = ${REGION} - access_key = ${ACCESS_KEY} - secret_key = ${SECRET_KEY} - } - - module "tidb-operator" { - source = "../modules/aliyun/tidb-operator" - - region = ${REGION} - access_key = ${ACCESS_KEY} - secret_key = ${SECRET_KEY} - cluster_name = "example-cluster" - key_file = "ssh-key.pem" - kubeconfig_file = "kubeconfig" - } - - provider "helm" { - alias = "default" - insecure = true - install_tiller = false - kubernetes { - config_path = module.tidb-operator.kubeconfig_filename - } - } - - module "tidb-cluster" { - source = "../modules/aliyun/tidb-cluster" - providers = { - helm = helm.default - } - - cluster_name = "example-cluster" - ack = module.tidb-operator - } - - module "bastion" { - source = "../modules/aliyun/bastion" - - bastion_name = "example-bastion" - key_name = module.tidb-operator.key_name - vpc_id = module.tidb-operator.vpc_id - vswitch_id = module.tidb-operator.vswitch_ids[0] - enable_ssh_to_worker = true - worker_security_group_id = module.tidb-operator.security_group_id - } - ``` - -上面的脚本可以自由定制,比如,假如不需要堡垒机则可以移除 `module "bastion"` 相关声明。 - -你也可以直接拷贝 `deploy/aliyun` 目录,但要注意不能拷贝已经运行了 `terraform apply` 的目录,建议重新 clone 仓库再进行拷贝。 - -## 使用限制 - -目前,`pod cidr`,`service cidr` 和节点型号等配置在集群创建后均无法修改。 From 35c0a868406c0cd5437d3109c7a8bfb1c17e3fec Mon Sep 17 00:00:00 2001 From: Aolin Date: Mon, 6 May 2024 14:59:04 +0800 Subject: [PATCH 5/5] Apply suggestions from code review --- en/deploy-tidb-operator.md | 2 +- zh/deploy-tidb-operator.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/en/deploy-tidb-operator.md b/en/deploy-tidb-operator.md index 4d53c6330..65d4e9dd0 100644 --- a/en/deploy-tidb-operator.md +++ b/en/deploy-tidb-operator.md @@ -1,7 +1,7 @@ --- title: Deploy TiDB Operator on Kubernetes summary: Learn how to deploy TiDB Operator on Kubernetes. -aliases: ['/tidb-in-kubernetes/v1.6/deploy-on-alibaba-cloud','/docs/tidb-in-kubernetes/v1.6/deploy-on-alibaba-cloud/'] +aliases: ['/tidb-in-kubernetes/v1.6/deploy-on-alibaba-cloud'] --- # Deploy TiDB Operator on Kubernetes diff --git a/zh/deploy-tidb-operator.md b/zh/deploy-tidb-operator.md index efc4b462e..208959207 100644 --- a/zh/deploy-tidb-operator.md +++ b/zh/deploy-tidb-operator.md @@ -1,7 +1,7 @@ --- title: 在 Kubernetes 上部署 TiDB Operator summary: 了解如何在 Kubernetes 上部署 TiDB Operator。 -aliases: ['/zh/tidb-in-kubernetes/v1.6/deploy-on-alibaba-cloud','/docs-cn/tidb-in-kubernetes/v1.6/deploy-on-alibaba-cloud/'] +aliases: ['/zh/tidb-in-kubernetes/v1.6/deploy-on-alibaba-cloud'] --- # 在 Kubernetes 上部署 TiDB Operator