CockroachDB - the open source, cloud-native SQL database.
Switch branches/tags
v2.2.0-alpha.00000000 v2.1.0-beta.20181015 v2.1.0-beta.20181008 v2.1.0-beta.20181001 v2.1.0-beta.20180924 v2.1.0-beta.20180917 v2.1.0-beta.20180910 v2.1.0-beta.20180904 v2.1.0-beta.20180827 v2.1.0-alpha.20180730 v2.1.0-alpha.20180702 v2.1.0-alpha.20180604 v2.1.0-alpha.20180507 v2.1.0-alpha.20180416 v2.1.0-alpha.00000000 v2.0.6 v2.0.6-rc.1 v2.0.5 v2.0.4 v2.0.3 v2.0.2 v2.0.1 v2.0.0 v2.0-rc.1 v2.0-beta.20180326 v2.0-beta.20180319 v2.0-beta.20180312 v2.0-beta.20180305 v2.0-alpha.20180212 v2.0-alpha.20180129 v2.0-alpha.20180122 v2.0-alpha.20180116 v2.0-alpha.20171218 v2.0-alpha.20171218-plus-left-join-fix v1.2-alpha.20171211 v1.2-alpha.20171204 v1.2-alpha.20171113 v1.2-alpha.20171026 v1.2-alpha.20170901 v1.1.9 v1.1.9-rc.1 v1.1.8 v1.1.7 v1.1.6 v1.1.5 v1.1.4 v1.1.3 v1.1.2 v1.1.1 v1.1.0 v1.1.0-rc.1 v1.1-beta.20170928 v1.1-beta.20170921 v1.1-beta.20170907 v1.1-alpha.20170817 v1.1-alpha.20170810 v1.1-alpha.20170803 v1.1-alpha.20170720 v1.1-alpha.20170713 v1.1-alpha.20170629 v1.1-alpha.20170622 v1.1-alpha.20170608 v1.1-alpha.20170601 v1.0.7 v1.0.6 v1.0.5 v1.0.4 v1.0.3 v1.0.2 v1.0.1 v1.0 v1.0-rc.3 v1.0-rc.2 v1.0-rc.1 v0.1-alpha beta-20170420 beta-20170413 beta-20170406 beta-20170330 beta-20170323 beta-20170309 beta-20170223 beta-20170216 beta-20170209 beta-20170126 beta-20170112 beta-20170105 beta-20161215 beta-20161208 beta-20161201 beta-20161110 beta-20161103 beta-20161027 beta-20161013 beta-20161006 beta-20160929 beta-20160915 beta-20160908 beta-20160829 beta-20160728
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github Fix typo in issue template Apr 23, 2016
acceptance acceptance+cloud: fix for Terraform 0.7.4 Sep 29, 2016
base server/base: comment updates Sep 28, 2016
build build: add Event* functions to go vet print funcs Sep 27, 2016
cli cli: Add http-host flag as first step of replacing http-addr Sep 28, 2016
cloud acceptance+cloud: fix for Terraform 0.7.4 Sep 29, 2016
cmd all: move to lib/pq Sep 26, 2016
config *: remove use of `import weak` Aug 31, 2016
docs RFC: Time Series Culling Sep 26, 2016
githooks Remove githooks/pre-push. Sep 28, 2015
gossip gossip: Don't use %s to format an array of resolvers. Sep 23, 2016
internal/client all: remove Trace/Tracef/VTracef Sep 15, 2016
keys storage: compact printing of key ranges Sep 18, 2016
kv server: enable testserver to take different store configurations Sep 28, 2016
resource Remove old PDF logos Jun 8, 2016
roachpb kv: resolve intents from a DelRange using a minimal span Sep 27, 2016
rpc storage: stream snapshots via a new GRPC endpoint. Sep 21, 2016
scripts scripts: 24 cores for gceworker Sep 21, 2016
security security: remove LoadInsecureClientTLSConfig Sep 6, 2016
server server/base: comment updates Sep 28, 2016
sql Merge pull request #9599 from RaduBerinde/update-tracing Sep 28, 2016
storage storage: reinstate snapshot status reporting Sep 28, 2016
testutils Merge pull request #9581 from andreimatei/fix-testclustershim Sep 28, 2016
ts ts: plumb contexts Sep 12, 2016
ui storage: monitor the GCInfo counters. Sep 27, 2016
util tracing: use the updated opentracing infrastructure Sep 28, 2016
.dockerignore gomvpkg -from github.com/cockroachdb/cockroach/client -to github.com/… Jun 30, 2016
.editorconfig Add `.editorconfig` and update style notes. Nov 25, 2015
.gitattributes ui: ignore diffs for more generated files Aug 31, 2016
.gitignore Clean up .gitignore Jul 21, 2016
.go-version build: update to go1.7.1 Sep 12, 2016
.mailmap Populate a .mailmap to enhance the output of git blame/shortlog/etc. May 5, 2016
CONTRIBUTING.md Makefile: Decrease required Git version back down to 1.8+ Sep 13, 2016
GLOCKFILE Merge pull request #9599 from RaduBerinde/update-tracing Sep 28, 2016
LICENSE Added copyright attribution and AUTHORS file. Feb 13, 2014
Makefile Makefile: increase RACETIMEOUT to 10m Sep 22, 2016
README.md remove google groups and add forum Jul 28, 2016
STYLE.md *: format maybe-nil errors as %v Aug 18, 2016
circle.yml acceptance: replace docker/engine-api with docker/docker Sep 8, 2016
main.go Remove explicit "init" step to start a cluster Feb 3, 2016

README.md

logo

Circle CI GoDoc Project Status Gitter

A Scalable, Survivable, Strongly-Consistent SQL Database

What is CockroachDB?

CockroachDB is a distributed SQL database built on a transactional and strongly-consistent key-value store. It scales horizontally; survives disk, machine, rack, and even datacenter failures with minimal latency disruption and no manual intervention; supports strongly-consistent ACID transactions; and provides a familiar SQL API for structuring, manipulating, and querying data.

For more details, see our FAQ and original design document.

Status

CockroachDB is currently in beta. See our Roadmap and Issues for a list of features planned or in development.

Docs

For guidance on installation, development, deployment, and administration, see our User Documentation.

Quickstart

  1. Install Cockroach DB.

  2. Start a local cluster with three nodes listening on different ports:

    $ ./cockroach start --background
    $ ./cockroach start --store=cockroach-data2 --port=26258 --http-port=8081 --join=localhost:26257 --background
    $ ./cockroach start --store=cockroach-data3 --port=26259 --http-port=8082 --join=localhost:26257 --background
  3. Start the built-in SQL client as an interactive shell:

    $ ./cockroach sql
    # Welcome to the cockroach SQL interface.
    # All statements must be terminated by a semicolon.
    # To exit: CTRL + D.
  4. Run some CockroachDB SQL statements:

    root@:26257> CREATE DATABASE bank;
    CREATE DATABASE
    
    root@:26257> SET DATABASE = bank;
    SET
    
    root@:26257> CREATE TABLE accounts (id INT PRIMARY KEY, balance DECIMAL);
    CREATE TABLE
    
    root@26257> INSERT INTO accounts VALUES (1234, 10000.50);
    INSERT 1
    
    root@26257> SELECT * FROM accounts;
    +------+----------+
    |  id  | balance  |
    +------+----------+
    | 1234 | 10000.50 |
    +------+----------+
  5. Checkout the admin UI by pointing your browser to http://<localhost>:8080.

  6. CockroachDB makes it easy to secure a cluster.

Client Drivers

CockroachDB supports the PostgreSQL wire protocol, so you can use any available PostgreSQL client drivers to connect from various languages. For recommended drivers that we've tested, see Install Client Drivers.

Deployment

  • Manual - Steps to deploy a CockroachDB cluster manually on multiple machines.

  • Cloud - Configuration files and instructions for deploying an insecure development or test cluster on GCE or AWS using Terraform.

Get In Touch

Report a Bug

For filing bugs, suggesting improvements, or requesting new features, help us out by opening an issue.

Need Help?

Contributing

We're an open source project and welcome contributions.

  1. See CONTRIBUTING.md to get your local environment set up.

  2. Take a look at our open issues, in particular those with the helpwanted label.

  3. Review our style guide and follow our code reviews to learn about our style and conventions.

  4. Make your changes according to our code review workflow.

Tech Talks

For recordings and slides from talks given by CockroachDB founders and engineers, see Tech Talks.

Design

This is an overview. For an in-depth discussion of the design and architecture, see the full design doc. For another quick design overview, see the CockroachDB tech talk slides.

Overview

CockroachDB is a distributed SQL database built on top of a transactional and consistent key:value store. The primary design goals are support for ACID transactions, horizontal scalability and survivability, hence the name. CockroachDB implements a Raft consensus algorithm for consistency. It aims to tolerate disk, machine, rack, and even datacenter failures with minimal latency disruption and no manual intervention. CockroachDB nodes (RoachNodes) are symmetric; a design goal is homogeneous deployment (one binary) with minimal configuration.

CockroachDB implements a single, monolithic sorted map from key to value where both keys and values are byte strings (not unicode). CockroachDB scales linearly (theoretically up to 4 exabytes (4E) of logical data). The map is composed of one or more ranges and each range is backed by data stored in RocksDB (a variant of LevelDB), and is replicated to a total of three or more CockroachDB servers. Ranges are defined by start and end keys. Ranges are merged and split to maintain total byte size within a globally configurable min/max size interval. Range sizes default to target 64M in order to facilitate quick splits and merges and to distribute load at hotspots within a key range. Range replicas are intended to be located in disparate datacenters for survivability (e.g. { US-East, US-West, Japan }, { Ireland, US-East, US-West} , { Ireland, US-East, US-West, Japan, Australia }).

Single mutations to ranges are mediated via an instance of a distributed consensus algorithm to ensure consistency. We’ve chosen to use the Raft consensus algorithm. All consensus state is stored in RocksDB.

A single logical mutation may affect multiple key/value pairs. Logical mutations have ACID transactional semantics. If all keys affected by a logical mutation fall within the same range, atomicity and consistency are guaranteed by Raft; this is the fast commit path. Otherwise, a non-locking distributed commit protocol is employed between affected ranges.

CockroachDB provides snapshot isolation (SI) and serializable snapshot isolation (SSI) semantics, allowing externally consistent, lock-free reads and writes--both from an historical snapshot timestamp and from the current wall clock time. SI provides lock-free reads and writes but still allows write skew. SSI eliminates write skew, but introduces a performance hit in the case of a contentious system. SSI is the default isolation; clients must consciously decide to trade correctness for performance. CockroachDB implements a limited form of linearalizability, providing ordering for any observer or chain of observers.

Similar to Spanner directories, CockroachDB allows configuration of arbitrary zones of data. This allows replication factor, storage device type, and/or datacenter location to be chosen to optimize performance and/or availability. Unlike Spanner, zones are monolithic and don’t allow movement of fine grained data on the level of entity groups.

SQL - NoSQL - NewSQL Capabilities

SQL - NoSQL - NewSQL Capabilities