Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Deploy TiDB on AWS EKS

Deploy TiDB on AWS EKS

原创
作者头像
杨漆
修改于 2021-03-09 06:25:16
修改于 2021-03-09 06:25:16
1.2K0
举报
文章被收录于专栏:TidbTidb

**导读**

> 作者:杨漆

> 16年关系型数据库管理,从oracle 9i 、10g、11g、12c到Mysql5.5、5.6、5.7、8.0 到TiDB获得3个OCP、2个OCM;运维路上不平坦,跌过不少坑、熬过许多夜。把工作笔记整理出来分享给大伙儿,希望帮到大家少走弯路、少熬夜。

how to deploy a TiDB cluster on AWS Elastic Kubernetes Service (EKS) ?

PrerequisitesBefore deploying a TiDB cluster on AWS EKS, make sure the following requirements are satisfied:

Install Helm: used for deploying TiDB Operator.

Complete all operations in Getting started with eksctl.

This guide includes the following contents:

Install and configure awscli.

Install and configure eksctl that is used for creating Kubernetes clusters.

Install kubectl.

Note:

The operations described in this document requires at least the minumum privileges needed by eksctl and the services privileges needed to create a Linux bastion host.

DeployThis section describes how to deploy EKS, TiDB operator, the TiDB cluster, and the monitoring component.

Create EKS and the node pool

apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: <clusterName> region: us-west-2 nodeGroups: - name: admin desiredCapacity: 1 labels: dedicated: admin - name: tidb desiredCapacity: 2 labels: dedicated: tidb taints: dedicated: tidb:NoSchedule - name: pd desiredCapacity: 3 labels: dedicated: pd taints: dedicated: pd:NoSchedule - name: tikv desiredCapacity: 3 labels: dedicated: tikv taints: dedicated: tikv:NoSchedule

Save the configuration above as cluster.yaml, and replace <clusterName> with your desired cluster name. Execute the following command to create the cluster:

eksctl create cluster -f cluster.yaml

Note:

After executing the command above, you need to wait until the EKS cluster is successfully created and the node group is created and added in the EKS cluster. This process might take 5 to 10 minutes.

For more cluster configuration, refer to eksctl documentation.

Deploy TiDB OperatorTo deploy TiDB Operator in the Kubernetes cluster, refer to the Deploy TiDB Operator sectionin Getting Started.

1.Deploy TiDB cluster and

monitorPrepare the TidbCluster and TidbMonitor CR files:

curl -LO https://raw.githubusercontent.com/pingcap/tidb-operator/master/examples/aws/tidb-cluster.yaml && curl -LO https://raw.githubusercontent.com/pingcap/tidb-operator/master/examples/aws/tidb-monitor.yaml

2.Create Namespace:

kubectl create namespace tidb-cluster

Note:

A namespace is a virtual cluster backed by the same physical cluster. This document takes tidb-cluster as an example. If you want to use other namespace, modify the corresponding arguments of -n or --namespace.

3.Deploy the TiDB cluster:

kubectl create -f tidb-cluster.yaml -n tidb-cluster && kubectl create -f tidb-monitor.yaml -n tidb-cluster

4.View the startup status of the TiDB cluster:

kubectl get pods -n tidb-cluster

When all the Pods are in the Running or Ready state, the TiDB cluster is successfully started. For example:

NAME READY STATUS RESTARTS AGE tidb-discovery-5cb8474d89-n8cxk 1/1 Running 0 47h tidb-monitor-6fbcc68669-dsjlc 3/3 Running 0 47h tidb-pd-0 1/1 Running 0 47h tidb-pd-1 1/1 Running 0 46h tidb-pd-2 1/1 Running 0 46h tidb-tidb-0 2/2 Running 0 47h tidb-tidb-1 2/2 Running 0 46h tidb-tikv-0 1/1 Running 0 47h tidb-tikv-1 1/1 Running 0 47h tidb-tikv-2 1/1 Running 0 47h

Access the databaseAfter you deploy a TiDB cluster, you can access the TiDB database via MySQL client.

Prepare a host that can access the clusterThe LoadBalancer created for your TiDB cluster is an intranet LoadBalancer. You can create a bastion host in the cluster VPC to access the database. To create a bastion host on AWS console, refer to AWS documentation.

Select the cluster's VPC and Subnet, and verify whether the cluster name is correct in the dropdown box. You can view the cluster's VPC and Subnet by running the following command:

eksctl get cluster -n <clusterName>

Allow the bastion host to access the Internet. Select the correct key pair so that you can log in to the host via SSH.

Note:

In addition to the bastion host, you can also connect the existing machine to the cluster VPC by VPC Peering.

If the EKS cluster is created in an existing VPC, you can use the host inside the VPC.

Install the MySQL client and connectAfter the bastion host is created, you can connect to the bastion host via SSH and access the TiDB cluster via the MySQL client.

1.Connect to the bastion host via SSH:

ssh [-i /path/to/your/private-key.pem] ec2-user@<bastion-public-dns-name>

2.Install the MySQL client:

sudo yum install mysql -y

3.Connect the client to the TiDB cluster:

mysql -h <tidb-nlb-dnsname> -P 4000 -u root

For example:

$ mysql -h abfc623004ccb4cc3b363f3f37475af1-9774d22c27310bc1.elb.us-west-2.amazonaws.com -P 4000 -u root Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 1189 Server version: 5.7.25-TiDB-v4.0.2 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> show status; +--------------------+--------------------------------------+ | Variable_name | Value | +--------------------+--------------------------------------+ | Ssl_cipher | | | Ssl_cipher_list | | | Ssl_verify_mode | 0 | | Ssl_version | | | ddl_schema_version | 22 | | server_id | ed4ba88b-436a-424d-9087-977e897cf5ec | +--------------------+--------------------------------------+ 6 rows in set (0.00 sec)

<tidb-nlb-dnsname> is the LoadBalancer domain name of the TiDB service. You can view the domain name in the EXTERNAL-IPfield by executing kubectl get svc basic-tidb -n tidb-cluster.

Note:

By default, TiDB (starting from v4.0.2) 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.

MonitorObtain the LoadBalancer domain name of Grafana:

kubectl -n tidb-cluster get svc basic-grafana

In the output above, the EXTERNAL-IP column is the LoadBalancer domain name.

You can access the <grafana-lb>:3000 address using your web browser to view monitoring metrics. Replace <grafana-lb> with the LoadBalancer domain name.

The initial Grafana login credentials are:

User: admin

Password: admin

UpgradeTo upgrade the TiDB cluster, edit the spec.version by executing kubectl edit tc basic -n tidb-cluster.

The upgrade process does not finish immediately. You can watch the upgrade progress by executing kubectl get pods -n tidb-cluster --watch.

Scale outBefore scaling out the cluster, you need to scale out the corresponding node group so that the new instances have enough resources for operation.

The following example shows how to scale out the tikv group of the <clusterName> cluster to 4 nodes:

eksctl scale nodegroup --cluster <clusterName> --name tikv --nodes 4 --nodes-min 4 --nodes-max 4

After that, execute kubectl edit tc basic -n tidb-cluster, and modify each component's replicas to the desired number of replicas. The scaling-out process is then completed.

For more information on managing node groups, refer to eksctl documentation.

Deploy TiFlash/TiCDCAdd node groupsIn the configuration file of eksctl (cluster.yaml), add the following two items to add a node group for TiFlash/TiCDC respectively. desiredCapacityis the number of nodes you desire.

- name: tiflash desiredCapacity: 3 labels: role: tiflash taints: dedicated: tiflash:NoSchedule - name: ticdc desiredCapacity: 1 labels: role: ticdc taints: dedicated: ticdc:NoSchedule

If the cluster is not created, execute eksctl create cluster -f cluster.yaml to create the cluster and node groups.

If the cluster is already created, execute eksctl create nodegroup -f cluster.yamlto create the node groups. The existing node groups are ignored and will not be created again.

Configure and deployIf you want to deploy TiFlash, configure spec.tiflash in tidb-cluster.yaml:

spec: ... tiflash: baseImage: pingcap/tiflash replicas: 1 storageClaims: - resources: requests: storage: 100Gi tolerations: - effect: NoSchedule key: dedicated operator: Equal value: tiflash

If you want to deploy TiCDC, configure spec.ticdc in tidb-cluster.yaml:

spec: ... ticdc: baseImage: pingcap/ticdc replicas: 1 tolerations: - effect: NoSchedule key: dedicated operator: Equal value: ticdc

Modify replicas according to your needs.

Finally, execute kubectl -n tidb-cluster apply -f tidb-cluster.yaml to update the TiDB cluster configuration.

For detailed CR configuration, refer to API references and Configure a TiDB Cluster.

Deploy TiDB Enterprise EditionIf you need to deploy TiDB/PD/TiKV/TiFlash/TiCDC Enterprise Edition, configure spec.<tidb/pd/tikv/tiflash/ticdc>.baseImage in tidb-cluster.yaml as the enterprise image. The image format is pingcap/<tidb/pd/tikv/tiflash/ticdc>-enterprise.

For example:

spec: ... pd: baseImage: pingcap/pd-enterprise ... tikv: baseImage: pingcap/tikv-enterprise

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
1.深入TiDB:初见TiDB
本篇文章应该是我研究的 TiDB 的第一篇文章,主要是介绍整个 TiDB 架构以及它能支持哪些功能为主。至于其中的细节,我也是很好奇,所以不妨关注一下,由我慢慢讲述。
luozhiyun
2021/09/14
8840
在 EKS 上管理 NodeGroup
最初使用的 NodeGroup 的 InstantType 规格太低,不太好用,所以需要增加一个新的 NodeGroup 。
云云众生s
2024/03/27
1620
【DB宝57】使用Docker-Compose快速部署TiDB集群环境
参考连接:https://docs.pingcap.com/zh/tidb/v3.0/deploy-test-cluster-using-docker-compose
AiDBA宝典
2021/12/17
2.2K0
【DB宝57】使用Docker-Compose快速部署TiDB集群环境
国产数据库|TiDB 5.4 单机快速安装初体验
在墨天轮中国数据库流行度排行榜上(PS:前段时间还是叫国产数据库流行度排行榜,看来现在已按照上月国产数据库掌门人论坛做了调整),TiDB 数据库一直以来霸榜第一,在线事务与在线分析处理 (Hybrid Transactional and Analytical Processing, HTAP) 功能是它主要的特点。去年七月份使用 tiup playground 模拟出了一个集群环境,体验了一些功能,考取了 PCTA 认证,现在 TiDB 发展到啥样了呢?我们来看看吧,体验一下!
JiekeXu之路
2022/03/31
1K0
国产数据库|TiDB 5.4 单机快速安装初体验
TiDB安装简介
TiDB 是 PingCAP 公司设计的开源分布式 HTAP (Hybrid Transactional and Analytical Processing) 数据库,结合了传统的 RDBMS 和 NoSQL 的最佳特性。TiDB 兼容 MySQL,支持无限的水平扩展,具备强一致性和高可用性。TiDB 的目标是为 OLTP (Online Transactional Processing) 和 OLAP (Online Analytical Processing) 场景提供一站式的解决方案。
ha_lydms
2023/08/10
6320
TiDB安装简介
Deploy TiDB on GCP GKE (Google Cloud)
how to deploy a TiDB cluster on GCP GKE with your laptop (Linux or macOS) for development or testing
杨漆
2021/01/31
9180
Deploy TiDB on GCP GKE (Google Cloud)
建设 TiDB 自动化平台:转转 DBA 团队实践
转转研发中心及业界小伙伴们的技术学习交流平台,定期分享一线的实战经验及业界前沿的技术话题。 各种干货实践,欢迎交流分享,如有问题可随时联系 waterystone ~
PingCAP
2023/02/20
4610
TiDB单机伪集群配置文档
准备环境 准备一台部署主机,确保其软件满足需求: 关闭防火墙: systemctl stop firewalld systemctl disable firewalld 关闭selinux vi /etc/selinux/config SELINUX=disabled setenforce 0
zhangdd
2021/02/26
7270
国产数据库|TiDB 8.0 新特性尝鲜
TiDB 是平凯星辰 PingCAP 公司自主设计、研发的开源分布式关系型数据库,是一款同时支持在线事务处理与在线分析处理 (Hybrid Transactional and Analytical Processing, HTAP) 的融合型分布式数据库产品,具备水平扩容或者缩容、金融级高可用、实时 HTAP、云原生的分布式数据库、兼容 MySQL 协议和 MySQL 生态等重要特性。
JiekeXu之路
2024/04/15
4100
国产数据库|TiDB 8.0 新特性尝鲜
tidb4.0.6离线安装
https://download.pingcap.org/tidb-community-server-v4.0.6-linux-amd64.tar.gz
全栈程序员站长
2021/05/19
3360
生产环境TiDB 5.0集群部署
最近是沉迷于TiDB,无法自拔,从TiDB集群部署到集群压测、高可用测试、再到参数调优,最后到线上业务从MySQL迁移到TiDB,整个过程下来,感觉整个学习成本还是比较高,不管是TiDB还是分布式数据库,要学习的内容还是非常的多;本文主要分享生产环境部署TiDB v5.0.3版本集群过程,供大家参考学习;
SEian.G
2021/08/25
1.4K0
TiDB 组件 GC 原理及常见问题
本文详细介绍了 TiDB 的 Garbage Collection(GC)机制及其在 TiDB 组件中的实现原理和常见问题排查方法。 TiDB 底层使用单机存储引擎 RocksDB,并通过 MVCC 机制,基于 RocksDB 实现了分布式存储引擎 TiKV,以支持高可用分布式事务。 GC 过程旨在清理旧数据,减少其对性能的影响,主要包括四个步骤: 计算 GC safepoint、解析锁(Resolve locks)、连续范围数据删除(Delete ranges)和同步 GC safepoint 至集群其他组件。 文章还讲述了如何定位 GC leader、监控 GC 状态、以及处理 GC 过程中遇到的常见问题。
PingCAP
2024/04/07
1850
TiDB 4.0 新特性也太爽了吧
TiDB4.0版本在4月份发布了RC版本,新增一些好用的功能:TiUP、BR、Dashboard、TiFlash、大事务的支持等等一些新功能,让我们快来体验一下吧。
田帅萌
2020/05/20
9120
国产数据库|TiDB 之 TiCDC6.0 数据同步体验
简介:TiCDC 是一款 TiDB 增量数据同步工具,通过拉取上游 TiKV 的数据变更日志,具有将数据还原到与上游任意时刻一致的能力,同时提供开放数据协议(TiCDC Open Protocol),支持其他系统订阅数据变更,TiCDC 可以将数据解析为有序的行级变更数据输出到下游。
JiekeXu之路
2022/12/07
7000
国产数据库|TiDB 之 TiCDC6.0 数据同步体验
TIDB 初级课程体验 5 ( 搭建一个TIDB)
TIDB 的安装通过文档,有两种模式 1 安装一个 TIDB TIKV PD, 或者
AustinDatabases
2021/09/02
3040
TiDB Operator 源码阅读 (四) 组件的控制循环
上篇文章中,我们介绍了 TiDB Operator 的组件生命周期管理的编排,以 TiDBCluster Controller 为例介绍 Controller Manager 的实现。TiDBCluster Controller 负责了 TiDB 主要组件的生命周期管理,TiDB 各个组件的 Member Manager 封装了对应具体的生命周期管理逻辑。在上篇文章中,我们描述了一个抽象的组件生命周期管理的实现,本文中,我们将以 PD 为例详细介绍组件生命周期管理的实现过程和相关代码,并且以 PD 的介绍为基础,介绍其他组件的部分差异。
PingCAP
2021/06/30
7630
配置 Windows 节点组
创建 cluster 时我们没有指定 --install-vpc-controllers 参数,所以我们需要首先安装 vpc controller :
云云众生s
2024/03/27
1530
基于 TiDB 资源管控 + TiCDC 实现多业务融合容灾测试
随着金融行业的不断发展,多个业务系统的整合成为了趋势,分布式数据库的应用也愈发广泛。为了应对多业务融合带来的复杂性,金融机构需要在保障各业务系统高效运行的同时,确保 IT 系统的高可用性和稳定性。本文将介绍 TiDB 如何通过多租户资源管控与容灾技术,助力金融机构在分布式环境中实现高效的业务整合与容灾能力,并探讨 TiCDC 工具在跨区域数据同步中的应用。
PingCAP
2024/09/05
1490
手把手教你搭建Tidb最新版4.0集群
TiUP 是 TiDB 4.0 版本引入的集群运维工具,TiUP cluster 是 TiUP 提供的使用 Golang 编写的集群管理组件,通过 TiUP cluster 组件就可以进行日常的运维工作,包括部署、启动、关闭、销毁、弹性扩缩容、升级 TiDB 集群、管理 TiDB 集群参数。
杨漆
2021/03/18
1K0
手把手教你搭建Tidb最新版4.0集群
TiDB Operator 源码阅读 (三) 编排组件控制循环
上篇文章中,我们介绍了 TiDB Operator 的 Controller Manager 的设计和实现,了解了各个 Controller 如何接受和处理变更。在这篇文章中,我们将讨论组件的 Controller 的实现。TiDBCluster Controller 负责了 TiDB 主要组件的生命周期管理,我们将以此为例, 介绍组件控制循环的编排设计。我们将会了解到完成 TiDB 集群的生命周期管理过程中,各种控制循环事件经过了怎样的编排,这些事件中又完成了哪些资源管理操作。在阅读时,大家了解这些工作的大致过程和定义即可,我们将在下一篇文章中具体介绍各个组件如何套用下面的范式。
PingCAP
2021/04/21
5280
相关推荐
1.深入TiDB:初见TiDB
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档