TiDB

維基百科,自由的百科全書
跳至導覽 跳至搜尋
TiDB
開發者北京平凱星辰科技發展有限公司(PingCAP)
首次發佈2017年10月15日,​8年前​(2017-10-15[1]
目前版本
    Module:EditAtWikidata第29行Lua錯誤:attempt to index field 'wikibase' (a nil value)
    原始碼庫
    • {{URL|example.com|可选的显示文本}}
    Module:EditAtWikidata第29行Lua錯誤:attempt to index field 'wikibase' (a nil value)
    程式語言Go (TiDB), Rust (TiKV)
    引擎
      Module:EditAtWikidata第29行Lua錯誤:attempt to index field 'wikibase' (a nil value)
      語言英文、中文
      類型NewSQL
      許可協定Apache 2.0

      TiDB是一個開源的NewSQL資料庫,支援混合事務和分析處理(HTAP)工作負載[2]。它與MySQL相容,並且可以提供水平可延伸性、強一致性和高可用性。它主要由PingCAP公司開發和支援,並在Apache 2.0下授權。TiDB從Google的Spanner[3]和F1[4]論文中汲取了最初的設計靈感。[5]

      TiDB被InfoWorld 2018 Bossie Award評選為最佳數據儲存和分析開源軟件之一。[6]

      歷史[編輯]

      PingCAP Inc.是一家軟件公司,成立於2015年4月,成立後便開始開發TiDB。該公司是TiDB及其關聯的開源社群的主要開發人員,維護人員和驅動者。[7]

      主要特性[編輯]

      水平可延伸性[編輯]

      TiDB可以通過添加新節點來擴充SQL處理和儲存容量。這使得基礎設施容量的擴充更加容易和靈活,而傳統的關聯式資料庫只能垂直擴充。

      MySQL相容性[編輯]

      對於應用程式來說,TiDB的行為就如同一個MySQL 5.7伺服器。用戶可以繼續使用所有現有的MySQL客戶端庫。因為TiDB的SQL處理層是從頭開始構建的,而不是一個MySQL分支,所以它的相容性不是100%,[8]而且MySQL和TiDB之間存在已知的行為差異。[9]

      具有強一致性的分散式事務[編輯]

      TiDB在內部基於範圍將表分片為的小塊,這些塊稱為「區域」。[10]每個區域的預設大小約為100 MB,TiDB在內部使用二階段提交來確保區域以事務上一致的方式進行維護。

      雲原生[編輯]

      為了使部署、組態、操作和維護更加靈活,TiDB被設計成可在雲中工作。TiDB的儲存層稱為TiKV,於2018年8月成為雲原生計算基金會的沙盒級別專案。[11]TiDB平台的體系結構還允許分別獨立擴充SQL處理和儲存。

      更精簡的ETL流程[編輯]

      TiDB可以支援連線事務處理(OLTP)和連線分析處理(OLAP)工作負載。這意味着,雖然用戶可能傳統上在MySQL上進行交易,然後將數據抽取、轉換和載入(ETL)到一個列儲存中進行分析處理,但這一步驟不再需要。

      高可用性[編輯]

      TiDB使用Raft一致性演算法[12]確保數據在整個Raft組的儲存程序中高度可用和安全複製。在發生故障時,Raft組將自動為失敗的成員選擇一個新的領導者,並自我修復TiDB叢集,而不需要任何必要的人工干預。失敗和自愈操作對應用程式是透明的。

      部署方法[編輯]

      Kubernetes Operator[編輯]

      可以使用TiDB Operator將TiDB部署到支援Kubernetes的雲環境中。[13]Operator是打包、部署和管理Kubernetes應用程式的方法。它是為執行有狀態工作負載而設計的,最早由CoreOS在2016年引入。[14]TiDB Operator[15]最初由PingCAP開發,並於2018年8月開源。[16]TiDB Operator可以用於在手提電腦[17]、Google Cloud Platform的Google Kubernetes引擎[18]和Amazon Web Services的Kubernetes彈性容器服務上部署TiDB。[19]

      Ansible[編輯]

      通過使用TiDB-Ansible playbook,可以使用Ansible (軟件)部署TiDB。[20]

      Docker[編輯]

      可以使用Docker在多個節點和多桌機器上的容器化環境中部署TiDB,而Docker Compose可以使用單個命令部署TiDB以進行測試。[21]

      工具[編輯]

      TiDB提供了一系列開源工具來幫助現有MySQLMariaDB用戶進行數據複製和遷移。

      Syncer與Data Migration[編輯]

      Syncer是一個工具,它支援從MySQL或MariaDB實例到TiDB叢集的完整數據遷移或增量數據複製。[22]Data Migration(DM)是 Syncer的第二代迭代,它適合將已分片的MySQL或MariaDB表中的數據複製到TiDB。[23]Syncer/DM的一個常見用例是將MySQL或MariaDB表連接到TiDB,幾乎將TiDB視為從屬,然後在該TiDB叢集上直接即時執行分析工作負載。

      Lightning[編輯]

      Lightning是一個可將大型MySQL轉儲高速完全匯入到新的TiDB群集中的工具,它提供了比執行每個SQL陳述式更快的匯入體驗。該工具用於把大量數據快速填充到一個最初為空的TiDB叢集,以便加快測試或生產遷移。之所以能提升匯入速度,是因為TiDB通過將SQL陳述式解析為鍵值對,然後直接生成有序字串表(SSTable)檔案到RocksDB[24]

      TiDB-Binlog[編輯]

      TiDB-Binlog是一個用於收集對TiDB叢集所做邏輯更改的工具。它用於在兩個TiDB叢集之間或從一個TiDB叢集到另一個下游平台之間提供增量備份和複製。

      它的功能類似於MySQL主從複製。主要的區別在於,由於TiDB是一個分散式資料庫檔案管理器,因此每個TiDB實例生成的binlog需要在被下游使用之前,根據事務提交的時間進行合併和排序。[25]

      用戶案例[編輯]

      目前,已有近3000家公司在使用 TiDB,其中包括Mastercard、AirBNB、Square、Paypay、中國銀行、建設銀行、美團、Bilibili、Shopee[26]、BookMyShow[27]、小米[28]、知乎[29]、美團點評[30]、愛奇藝[31], 轉轉[32]、摩拜[33]、易果[34],以及猿輔導[35]


      參考文獻[編輯]

      1. ^ 1.0 GA release notes. 
      2. ^ How TiDB combines OLTP and OLAP in a distributed database. [2019-12-07]. (原始內容存檔於2019-05-02). 
      3. ^ Spanner: Google's Globally-Distributed Database. [2019-12-07]. (原始內容存檔於2018-12-30). 
      4. ^ F1: A Distributed SQL Database That Scales. [2019-12-07]. (原始內容存檔於2019-12-02). 
      5. ^ TiDB Brings Distributed Scalability to SQL. [2019-12-07]. (原始內容存檔於2019-05-02). 
      6. ^ The best open source software for data storage and analytics. [2019-12-07]. (原始內容存檔於2019-09-02). 
      7. ^ TiDB developer PingCAP wants to expand in North America after raising $50M Series C. [2019-12-07]. (原始內容存檔於2019-05-02). 
      8. ^ Compatibility with MySQL. [2019-12-07]. (原始內容存檔於2019-05-02). 
      9. ^ Meet TiDB: An open source NewSQL database. [2019-12-07]. (原始內容存檔於2019-07-31). 
      10. ^ TiKV Architecture. [2019-12-07]. (原始內容存檔於2019-05-02). 
      11. ^ CNCF to Host TiKV in the Sandbox. [2019-12-07]. (原始內容存檔於2019-09-03). 
      12. ^ The Raft Consensus Algorithm. [2019-12-07]. (原始內容存檔於2018-01-20). 
      13. ^ Database Operators Bring Stateful Workloads to Kubernetes. [2019-12-07]. (原始內容存檔於2019-12-29). 
      14. ^ Introducing Operators: Putting Operational Knowledge into Software. [2019-12-07]. (原始內容存檔於2019-11-25). 
      15. ^ TiDB Operator GitHub repo. [2019-12-07]. (原始內容存檔於2019-07-16). 
      16. ^ Introducing the Kubernetes Operator for TiDB. [2019-12-07]. (原始內容存檔於2019-05-02). 
      17. ^ Deploy TiDB to Kubernetes on Your Laptop. [2019-12-07]. (原始內容存檔於2018-08-17). 
      18. ^ Deploy TiDB, a distributed MySQL compatible database, to Kubernetes on Google Cloud. 
      19. ^ Deploy TiDB, a distributed MySQL compatible database, on Kubernetes via AWS EKS. 
      20. ^ Ansible Playbook for TiDB. [2019-12-07]. (原始內容存檔於2020-08-25). 
      21. ^ How to Spin Up an HTAP Database in 5 Minutes With TiDB + TiSpark. [2019-12-07]. (原始內容存檔於2019-05-02). 
      22. ^ Syncer User Guide. [2019-12-07]. (原始內容存檔於2019-11-21). 
      23. ^ DM GitHub Repo. [2019-12-07]. (原始內容存檔於2020-08-25). 
      24. ^ Introducing TiDB Lightning. [2019-12-07]. (原始內容存檔於2019-05-08). 
      25. ^ TiDB-Binlog Architecture Evolution and Implementation Principles. [2019-12-07]. (原始內容存檔於2019-06-16). 
      26. ^ Shopping on Shopee, the TiDB Way - TiDB. pingcap.com. [2019-12-07]. (原始內容存檔於2019-11-06). 
      27. ^ BookMyShow.com: More Uptime, 30% Less Operational Cost with TiDB - TiDB. pingcap.com. [2019-12-07]. (原始內容存檔於2019-11-06). 
      28. ^ Powering the Xiaomi Mobile Lifestyle with TiDB - TiDB. pingcap.com. [2019-12-07]. (原始內容存檔於2019-11-06). 
      29. ^ Lesson Learned from Queries over 1.3 Trillion Rows of Data Within Milliseconds of Response Time at Zhihu.com - TiDB. pingcap.com. [2019-12-07]. (原始內容存檔於2019-11-06). 
      30. ^ TiDB, the Key to a Better Life for Meituan-Dianping’s 290 Million Monthly Users - TiDB. pingcap.com. [2019-12-07]. (原始內容存檔於2019-11-21). 
      31. ^ Always Fun, Always On: How TiDB Helps iQiyi Deliver Streaming Videos - TiDB. pingcap.com. [2019-12-07]. (原始內容存檔於2019-11-06). 
      32. ^ Managing the Surging Data Volume of a Fast-Growing Marketplace with TiDB - TiDB. pingcap.com. [2019-12-07]. (原始內容存檔於2019-11-06). 
      33. ^ Blitzscaling the Largest Dockless Bikesharing Platform with TiDB’s Help - TiDB. pingcap.com. [2019-12-07]. (原始內容存檔於2019-05-02). 
      34. ^ States, Austin TX United. The Hybrid Database Capturing Perishable Insights at Yiguo. Datanami. 2018-02-22 [2019-12-07]. (原始內容存檔於2019-11-06). 
      35. ^ How TiDB tackles fast data growth and complex queries for yuanfudao.com - TiDB. pingcap.com. [2019-12-07]. (原始內容存檔於2019-11-06).