Install CockroachDB on Linux

On this page Carat arrow pointing down
Tip:

To try CockroachDB Cloud instead of running CockroachDB yourself, refer to the Cloud Quickstart.

CockroachDB v24.2 is the latest supported production release. It is an Innovation release that is optional for CockroachDB Dedicated and CockroachDB self-hosted but required for CockroachDB Serverless. To learn more, refer to CockroachDB v24.2 Release Notes.

Use one of the options below to install CockroachDB. To upgrade an existing cluster, refer to Upgrade to v24.2.

Download the binary

The CockroachDB binary for Linux requires glibc, libncurses, and tzdata, which are found by default on nearly all Linux distributions, with Alpine as the notable exception.

  1. Visit Releases to download the CockroachDB archive for the architecture of your Linux host. The archive contains the cockroach binary and the supporting libraries that are used to provide spatial features. Extract the archive and optionally copy the cockroach binary into your PATH so you can execute cockroach commands from any shell. If you get a permission error, use sudo.

  2. Note:

    If you plan to use CockroachDB's spatial features, you must complete the following steps. Otherwise, your installation is now complete.

  3. CockroachDB uses custom-built versions of the GEOS libraries. Copy these libraries to one of the locations where CockroachDB expects to find them.

    By default, CockroachDB looks for external libraries in /usr/local/lib/cockroach or a lib subdirectory of the CockroachDB binary's current directory. If you place these libraries in another location, you must pass the location in the --spatial-libs flag to cockroach start. The instructions below assume the /usr/local/lib/cockroach location.

    1. Create the directory where the external libraries will be stored:

      icon/buttons/copy
      mkdir -p /usr/local/lib/cockroach
    2. Copy the library files to the directory. In the following commands, replace {ARCHITECTURE} with linux-amd64 for Intel, or with linux-arm64 for ARM.

      icon/buttons/copy
      cp -i cockroach-v24.2.6.linux-{ARCHITECTURE}/lib/libgeos.so /usr/local/lib/cockroach/
      icon/buttons/copy
      cp -i cockroach-v24.2.6.linux-{ARCHITECTURE}/lib/libgeos_c.so /usr/local/lib/cockroach/

      If you get a permissions error, prefix the command with sudo.

  4. Verify that CockroachDB can execute spatial queries.

    1. Make sure the cockroach binary you just installed is the one that runs when you type cockroach in your shell:

      icon/buttons/copy
      which cockroach
      /usr/local/bin/cockroach
    2. Start a temporary, in-memory cluster using cockroach demo:

      icon/buttons/copy
      cockroach demo
    3. In the demo cluster's interactive SQL shell, run the following command to test that the spatial libraries have loaded properly:

      icon/buttons/copy
      > SELECT ST_IsValid(ST_MakePoint(1,2));

      You should see the following output:

        st_isvalid
      --------------
      true
      (1 row)

      If your cockroach binary is not properly accessing the dynamically linked C libraries in /usr/local/lib/cockroach, it will output an error message like the one below.

      ERROR: st_isvalid(): geos: error during GEOS init: geos: cannot load GEOS from dir "/usr/local/lib/cockroach": failed to execute dlopen
                Failed running "sql"
  5. Keep up-to-date with CockroachDB releases and best practices:

Use Kubernetes

To orchestrate CockroachDB using Kubernetes, either with configuration files or the Helm package manager, use the following tutorials:

Use Docker

Warning:

Running a stateful application like CockroachDB in Docker is more complex and error-prone than most uses of Docker. Unless you are very experienced with Docker, we recommend starting with a different installation and deployment method.

CockroachDB's Docker images are multi-platform images that contain binaries for both Intel and ARM. Multi-platform images do not take up additional space on your Docker host.

Experimental images are not qualified for production use and not eligible for support or uptime SLA commitments.

  1. Install a container runtime, such as Docker Desktop.
  2. Verify that the runtime service is installed correctly and running in the background. Refer to the runtime's documentation. For Docker, start a terminal and run docker version. If you get an error, verify your installation and try again.
  3. Visit Docker Hub and decide which image tag to pull. Releases are rolled out gradually. Docker images for a new release are published when other binary artifacts are published. The following tag formats are commonly used, although other tags are available.

    Tag Example Description
    An exact patch v24.2.6 Pins a cluster to an exact patch. The cluster is upgraded to a newer patch or major version only when you pull a newer tag.
    Latest patch within a major version latest-v24.2 Automatically updates a cluster to the latest patch of the version you specify. This tag is recommended in production, because it keeps your cluster updated within a major version but does not automatically upgrade your cluster to a new major version.
    latest The latest patch within the latest major version. This is the default if you do not specify a tag. It updates your cluster automatically to each new patch and major version, and is not recommended in production.

    Copy the tag you want to pull.

  4. Pull the image. Replace {TAG} with the tag from the previous step.

    icon/buttons/copy
    docker pull cockroachdb/cockroach:{TAG}
    
  5. Start a cluster by starting the container on each node using docker start. The default command is cockroach start. Pass your desired flags as the final argument. For details, refer to Deploy a local container in Docker.

For CockroachDB v22.2.beta-5 and above, Docker images are multi-platform images that contain binaries for both Intel and ARM. Multi-platform images do not take up additional space on your Docker host.

Docker images for previous releases contain Intel binaries only. Intel binaries can run on ARM systems, but with a significant reduction in performance.

CockroachDB on ARM is in Limited Access in v22.2.13, and is experimental in all other versions. Experimental images are not qualified for production use and not eligible for support or uptime SLA commitments.

  1. Install Docker for Linux. Please carefully check that you meet all prerequisites.

  2. Confirm that the Docker daemon is running in the background:

    icon/buttons/copy
    $ docker version

    If you do not see the server listed, start the Docker daemon.

    Note:
    On Linux, Docker needs sudo privileges.
  3. Pull the image for the v24.2.6 release of CockroachDB from Docker Hub:

    icon/buttons/copy
    $ sudo docker pull cockroachdb/cockroach:v24.2.6
  4. Keep up-to-date with CockroachDB releases and best practices:

Build from Source

See the public wiki for guidance. When building on the ARM architecture, refer to Limitations.

Limitations

ARM

CockroachDB runtimes built for the ARM architecture have the following limitations:

Validate workloads that rely on floating point operations or FMA instrincs before migrating those workloads to ARM in production.

When building from source on ARM, it is not currently possible to disable FMA intrinsics in Go. To track the status of this feature request, refer to GoLang issue #36971.

  • In production, Cockroach Labs recommends that all cluster nodes have identical CockroachDB versions, CPU architecture, hardware, and software.
  • A mix of Intel and ARM nodes is supported as a temporary transitional state during the migration only. Cockroach Labs recommends that you test and validate your workload ahead of the migration to ensure that the workload and your application work as expected in a cluster with both Intel and ARM nodes, especially with respect to floating-point arithmetic.

NUMA

In a NUMA (non-uniform memory access) architecture, the system’s memory is physically distributed across multiple memory banks or "nodes", and each node is assigned to a processor. A processor can access its local memory much faster than non-local memory. This non-uniform memory access can lead to performance differences depending on data location.

CockroachDB is written in Go, which has no process-level support for NUMA scheduling or pinning. Instead, you must manage NUMA at the operating system level. To run multiple CockroachDB clusters on a NUMA architecture:

  • Assign no more than 32 cores to the node for each instance. Refer to the documentation for numactl --membind.
  • Ensure that your orchestration framework, process manager, or startup scripts start each CockroachDB in a separate NUMA node.
  • If multiple CockroachDB nodes for the same CockroachDB cluster run on the same physical host, ensure that they are in the same --locality to ensure that data is distributed across different physical hosts.
  • Ensure that each CockroachDB node writes to a unique set of storage volumes (block devices).

What's next?

Note:
By default, each node of a CockroachDB cluster periodically shares anonymous usage details with Cockroach Labs. For an explanation of the details that get shared and how to opt-out of reporting, see Diagnostics Reporting.

Yes No
On this page

Yes No