tikv README

The project's README from github.com/tikv/tikv. As one markdown file: README.md.

tikv_logo

Website | Documentation | Community Chat

Build Status Coverage Status CII Best Practices

TiKV is an open-source, distributed, and transactional key-value database. Unlike other traditional NoSQL systems, TiKV not only provides classical key-value APIs, but also transactional APIs with ACID compliance. Built in Rust and powered by Raft, TiKV was originally created by PingCAP to complement TiDB, a distributed HTAP database compatible with the MySQL protocol.

The design of TiKV ('Ti' stands for titanium) is inspired by some great distributed systems from Google, such as BigTable, Spanner, and Percolator, and some of the latest achievements in academia in recent years, such as the Raft consensus algorithm.

If you're interested in contributing to TiKV, or want to build it from source, see CONTRIBUTING.md. For maintainership-oriented code reading and review context, see doc/maintenance-guides/README.md.

cncf_logo cncf_logo

TiKV is a graduated project of the Cloud Native Computing Foundation (CNCF). If you are an organization that wants to help shape the evolution of technologies that are container-packaged, dynamically-scheduled and microservices-oriented, consider joining the CNCF. For details about who's involved and how TiKV plays a role, read the CNCF announcement.


With the implementation of the Raft consensus algorithm in Rust and consensus state stored in RocksDB, TiKV guarantees data consistency. Placement Driver (PD), which is introduced to implement auto-sharding, enables automatic data migration. The transaction model is similar to Google's Percolator with some performance improvements. TiKV also provides snapshot isolation (SI), snapshot isolation with lock (SQL: SELECT ... FOR UPDATE), and externally consistent reads and writes in distributed transactions.

TiKV has the following key features:

Governance

See Governance.

Documentation

For instructions on deployment, configuration, and maintenance of TiKV,see TiKV documentation on our website. For more details on concepts and designs behind TiKV, see Deep Dive TiKV.

Note:

We have migrated our documentation from the TiKV's wiki page to the official website. The original Wiki page is discontinued. If you have any suggestions or issues regarding documentation, offer your feedback here.

TiKV adopters

You can view the list of TiKV Adopters.

TiKV software stack

The TiKV software stack

When a node starts, the metadata of the Node, Store and Region are recorded into PD. The status of each Region and Store is reported to PD regularly.

Quick start

Deploy a playground with TiUP

The most quickest to try out TiKV with TiDB is using TiUP, a component manager for TiDB.

You can see this page for a step by step tutorial.

Deploy a playground with binary

TiKV is able to run separately with PD, which is the minimal deployment required.

  1. Download and extract binaries.
$ export TIKV_VERSION=v7.5.0
$ export GOOS=darwin  # only {darwin, linux} are supported
$ export GOARCH=amd64 # only {amd64, arm64} are supported
$ curl -O  https://tiup-mirrors.pingcap.com/tikv-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
$ curl -O  https://tiup-mirrors.pingcap.com/pd-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
$ tar -xzf tikv-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
$ tar -xzf pd-$TIKV_VERSION-$GOOS-$GOARCH.tar.gz
  1. Start PD instance.
$ ./pd-server --name=pd --data-dir=/tmp/pd/data --client-urls="http://127.0.0.1:2379" --peer-urls="http://127.0.0.1:2380" --initial-cluster="pd=http://127.0.0.1:2380" --log-file=/tmp/pd/log/pd.log
  1. Start TiKV instance.
$ ./tikv-server --pd-endpoints="127.0.0.1:2379" --addr="127.0.0.1:20160" --data-dir=/tmp/tikv/data --log-file=/tmp/tikv/log/tikv.log
  1. Install TiKV Client(Python) and verify the deployment, required Python 3.5+.
$ pip3 install -i https://test.pypi.org/simple/ tikv-client
from tikv_client import RawClient

client = RawClient.connect(["127.0.0.1:2379"])

client.put(b'foo', b'bar')
print(client.get(b'foo')) # b'bar'

client.put(b'foo', b'baz')
print(client.get(b'foo')) # b'baz'

Deploy a cluster with Docker Compose

The easiest way to run a complete TiKV cluster (3 PD + 3 TiKV nodes) for development and testing is using Docker Compose. The setup uses pre-built TiKV and PD nightly images from Docker Hub, so no building is required.

Note: On macOS, use docker compose (space) instead of docker-compose (hyphen) in all commands.

  1. Start the cluster:
$ docker-compose up -d
# On macOS, use: docker compose up -d
  1. Check cluster status:
$ docker-compose ps
# On macOS, use: docker compose ps
  1. Access the cluster:

For more details, see docker-compose.README.md.

Deploy a cluster with TiUP

You can see this manual of production-like cluster deployment presented by @c4pt0r.

Build from source

See CONTRIBUTING.md.

Client drivers

If you want to try the Go client, see Go Client.

Security

Security audit

A third-party security auditing was performed by Cure53. See the full report here.

Reporting Security Vulnerabilities

To report a security vulnerability, please send an email to TiKV-security group.

See Security for the process and policy followed by the TiKV project.

Communication

Communication within the TiKV community abides by TiKV Code of Conduct. Here is an excerpt:

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

Social Media

Slack

Join the TiKV community on Slack - Sign up and join channels on TiKV topics that interest you.

License

TiKV is under the Apache 2.0 license. See the LICENSE file for details.

Acknowledgments

tikv (tikv/tikv)

Searching Database…

16.9K ·GitHub
这是什么?一个开源的分布式事务型键值数据库。和传统的 NoSQL 系统不同,它不仅提供经典的键值 API,还提供符合 ACID 的事务 API。
它是嵌入到我应用里的库,还是需要我部署的一组服务器集群?是需要部署的集群,不是嵌入式的库。最小的部署方式是 TiKV 搭配 PD(Placement Driver)一起运行,由 PD 负责管理整个集群。
我怎么把集群跑起来试一试?最快的方式是用 TiUP 启动一个带 TiDB 的 playground。如果要搭开发集群,可以用 Docker Compose 从预构建的 nightly 镜像启动 3 个 PD 节点和 3 个 TiKV 节点,不需要自己编译;在 macOS 上注意命令要写成带空格的 'docker compose'。
我的应用怎么连接到它?通过客户端驱动连接:Go 的驱动最稳定、使用最广泛,另外还有 Java、Rust 和 C 的客户端。快速入门里用一个 Python 客户端来验证部署,该客户端要求 Python 3.5+。
在 TiKV 集群里,PD、Store 和 Region 分别是什么意思?PD 是集群的管理者,会定期检查副本约束,并自动均衡负载和数据。每个 Store 内嵌一个 RocksDB 实例,把数据写到本地磁盘;Region 是键值数据迁移的基本单位,会被复制到多个节点上,这些副本组成一个 Raft 组。
它的设计灵感来自哪里?来自 Google 的几套系统:BigTable、Spanner 和 Percolator,再加上近年学术界的 Raft 一致性算法。名字里的 'Ti' 代表钛(titanium)。
这个代码库做过安全审计吗?做过——第三方安全审计由 Cure53 完成,完整报告的链接在 README 里。
What are similar projects?nebula, tidb, etcd, rook, thanos, talent-plan, yugabyte-db, distribution
Creator
tikv
Size
137.1 MB
Stars
16.9K
Age
10y
Commits · 90 Days