Software:TiDB

From HandWiki
Short description: NewSQL relational distributed database
TiDB
Developer(s)PingCAP Inc.
Initial releaseOctober 15, 2017; 6 years ago (2017-10-15)[1]
Written inGo (TiDB), Rust (TiKV)
Available inEnglish, Chinese
TypeNewSQL
LicenseApache 2.0

TiDB (/’taɪdiːbi:/, "Ti" stands for Titanium) is an open-source NewSQL database that supports Hybrid Transactional and Analytical Processing (HTAP) workloads.[2] Designed to be MySQL compatible, it is developed and supported primarily by PingCAP and licensed under Apache 2.0. It is also available as a paid product. TiDB drew its initial design inspiration from Google's Spanner and F1 papers.[3][4][5]

Release history

See all TiDB release notes.

Main features

Horizontal scalability

TiDB can expand both SQL processing and storage capacity by adding new nodes.

MySQL compatibility

TiDB acts like it is a MySQL 5.7 server to applications. A user can continue to use all of the existing MySQL client libraries.[6] Because TiDB's SQL processing layer is built from scratch, not a MySQL fork.[7]

Distributed transactions with strong consistency

TiDB internally shards a table into small range-based chunks that are referred to as "Regions".[8] Each Region defaults to approximately 100 MB in size, and TiDB uses a two-phase commit internally to ensure that regions are maintained in a transactionally consistent way.

Cloud native

TiDB is designed to work in the cloud. The storage layer of TiDB, called TiKV, became a Cloud Native Computing Foundation (CNCF) member project in August 2018, as a Sandbox level project,[9] and became an incubation-level hosted project in May 2019.[10] TiKV graduated from CNCF in September 2020.[11]

Real-time HTAP

TiDB can support both online transaction processing (OLTP) and online analytical processing (OLAP) workloads. TiDB has two storage engines: TiKV, a rowstore, and TiFlash, a columnstore.

High availability

TiDB uses the Raft consensus algorithm[12] to ensure that data is available and replicated throughout storage in Raft groups. In the event of failure, a Raft group will automatically elect a new leader for the failed member, and self-heal the TiDB cluster.

Deployment methods

Kubernetes with Operator

TiDB can be deployed in a Kubernetes-enabled cloud environment by using TiDB Operator.[13] An Operator is a method of packaging, deploying, and managing a Kubernetes application. It is designed for running stateful workloads and was first introduced by CoreOS in 2016.[14] TiDB Operator[15] was originally developed by PingCAP and open-sourced in August, 2018.[16] TiDB Operator can be used to deploy TiDB on a laptop,[17] Google Cloud Platform’s Google Kubernetes Engine,[18] and Amazon Web Services’ Elastic Container Service for Kubernetes.[19]

TiUP

TiDB 4.0 introduces TiUP, a cluster operation and maintenance tool. It helps users quickly install and configure a TiDB cluster with a few commands.[20]

TiDB Ansible

TiDB can be deployed using Ansible by using a TiDB Ansible playbook (not recommended).[21]

Docker

Docker can be used to deploy TiDB in a containerized environment on multiple nodes and multiple machines, and Docker Compose can be used to deploy TiDB with a single command for testing purposes.[22]

Tools

TiDB has a series of open-source tools built around it to help with data replication and migration for existing MySQL and MariaDB users.

TiDB Data Migration (DM)

TiDB Data Migration (DM) is suited for replicating data from already sharded MySQL or MariaDB tables to TiDB.[23] A common use case of DM is to connect MySQL or MariaDB tables to TiDB, treating TiDB almost as a slave, then directly run analytical workloads on this TiDB cluster in near real-time.

Backup & Restore

Backup & Restore (BR) is a distributed backup and restore tool for TiDB cluster data.[24]

Dumpling

Dumpling is a data export tool that exports data stored in TiDB or MySQL. It lets users make logical full backups or full dumps from TiDB or MySQL.[25]

TiDB Lightning

TiDB Lightning is a tool that supports high speed full-import of a large MySQL dump into a new TiDB cluster. This tool is used to populate an initially empty TiDB cluster with much data, in order to speed up testing or production migration. The import speed improvement is achieved by parsing SQL statements into key-value pairs, then directly generate Sorted String Table (SST) files to RocksDB.[26][27]

TiDB Binlog

TiDB Binlog is a tool used to collect the logical changes made to a TiDB cluster. It is used to provide incremental backup and replication, either between two TiDB clusters, or from a TiDB cluster to another downstream platform.[28][29]

See also

References

  1. "1.0 GA release notes". https://github.com/pingcap/tidb/releases/tag/v1.0.0. 
  2. Xu, Kevin (October 17, 2018). "How TiDB combines OLTP and OLAP in a distributed database". https://www.infoworld.com/article/3313327/how-tidb-combines-oltp-and-olap-in-a-distributed-database.html. 
  3. "F1: A Distributed SQL Database That Scales". 2013. https://ai.google/research/pubs/pub41344. 
  4. "Spanner: Google's Globally-Distributed Database". 2012. https://ai.google/research/pubs/pub39966. 
  5. Hall, Susan (April 17, 2017). "TiDB Brings Distributed Scalability to SQL". https://thenewstack.io/tidb-brings-distributed-scalability-sql/. 
  6. Tocker, Morgan (November 14, 2018). "Meet TiDB: An open source NewSQL database". https://opensource.com/article/18/11/key-differences-between-mysql-and-tidb. 
  7. "Compatibility with MySQL". https://docs.pingcap.com/tidb/stable/mysql-compatibility. 
  8. "TiKV Architecture". https://tikv.org/docs/4.0/concepts/architecture/#region. 
  9. Evans, Kristen (August 28, 2018). "CNCF to Host TiKV in the Sandbox". https://www.cncf.io/blog/2018/08/28/cncf-to-host-tikv-in-the-sandbox/. 
  10. CNCF (May 21, 2019). "TOC Votes to Move TiKV into CNCF Incubator". https://www.cncf.io/blog/2019/05/21/toc-votes-to-move-tikv-into-cncf-incubator/. 
  11. TiKV Authors (September 2, 2020). "Celebrating TiKV's CNCF Graduation". https://tikv.org/blog/graduation-announcement/. 
  12. "The Raft Consensus Algorithm". https://raft.github.io/. 
  13. Jackson, Joab (January 22, 2019). "Database Operators Bring Stateful Workloads to Kubernetes". https://thenewstack.io/databases-operators-bring-stateful-workloads-to-kubernetes/. 
  14. Philips, Brandon (November 3, 2016). "Introducing Operators: Putting Operational Knowledge into Software". https://coreos.com/blog/introducing-operators.html. 
  15. "TiDB Operator GitHub repo". https://github.com/pingcap/tidb-operator. 
  16. "Introducing the Kubernetes Operator for TiDB". August 16, 2018. https://www.infoworld.com/article/3297700/introducing-the-kubernetes-operator-for-tidb.html. 
  17. "Deploy TiDB to Kubernetes on Your Laptop". https://docs.pingcap.com/tidb-in-kubernetes/stable/get-started. 
  18. "Deploy TiDB, a distributed MySQL compatible database, to Kubernetes on Google Cloud". https://docs.pingcap.com/tidb-in-kubernetes/stable/deploy-on-gcp-gke. 
  19. "Deploy TiDB, a distributed MySQL compatible database, on Kubernetes via AWS EKS". https://github.com/pingcap/tidb-operator/blob/master/docs/aws-eks-tutorial.md. 
  20. Long, Heng (April 19, 2020). "Get a TiDB Cluster Up in Only One Minute". https://pingcap.com/blog/get-tidb-cluster-up-in-only-one-minute. 
  21. "Ansible Playbook for TiDB". https://github.com/pingcap/tidb-ansible. 
  22. "How to Spin Up an HTAP Database in 5 Minutes With TiDB + TiSpark". https://dzone.com/articles/how-to-spin-up-an-htap-database-in-5-minutes-with. 
  23. "DM GitHub Repo". https://github.com/pingcap/dm. 
  24. Shen, Taining (April 13, 2020). "How to Back Up and Restore a 10-TB Cluster at 1+ GB/s". https://pingcap.com/blog/back-up-and-restore-a-10-tb-cluster-at-1-gb-per-second. 
  25. "Dumpling Overview". https://docs.pingcap.com/tidb/stable/dumpling-overview. 
  26. Chan, Kenny (January 30, 2019). "Introducing TiDB Lightning". https://www.pingcap.com/blog/introducing-tidb-lightning/. 
  27. "TiDB Lightning Overview". https://docs.pingcap.com/tidb/stable/tidb-lightning-overview. 
  28. "TiDB Binlog Cluster Overview". https://docs.pingcap.com/tidb/stable/tidb-binlog-overview. 
  29. Wang, Xiang (January 29, 2019). "TiDB-Binlog Architecture Evolution and Implementation Principles". https://www.pingcap.com/blog/tidb-binlog-architecture-evolution-and-implementation-principles/.