> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Install CockroachDB on Linux

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

<Tip>
  To try CockroachDB Cloud instead of running CockroachDB yourself, refer to the <InternalLink version="cockroachcloud" path="quickstart">Cloud Quickstart</InternalLink>.
  See <InternalLink version="releases" path="v23.2">Release Notes</InternalLink> for what's new in the latest release, . To upgrade to this release from an older version, see <InternalLink path="upgrade-cockroach-version">Cluster Upgrade</InternalLink>.
  Use one of the options below to install CockroachDB.

  * To install a FIPS-compliant CockroachDB binary, refer to <InternalLink path="fips">Install a FIPS-compliant build of CockroachDB</InternalLink> instead of this page.
  * For limitations of CockroachDB on ARM, refer to [ARM limitations](#arm).
  * For limitations of CockroachDB on a NUMA architecture, refer to [NUMA limitations](#numa).
</Tip>

## 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 <InternalLink version="releases" path="index">Releases</InternalLink> 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 <InternalLink path="spatial-data-overview">spatial features</InternalLink>. Extract the archive and optionally copy the `cockroach` binary into your `PATH` so you can execute <InternalLink path="cockroach-commands">cockroach commands</InternalLink> from any shell. If you get a permission error, use `sudo`.

If you plan to use CockroachDB's <InternalLink path="spatial-data-overview">spatial features</InternalLink>, you must complete the following steps. Otherwise, your installation is now complete.

2. CockroachDB uses custom-built versions of the <InternalLink path="architecture/glossary#geos">GEOS</InternalLink> 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 <InternalLink path="cockroach-start">`--spatial-libs` flag to `cockroach start`</InternalLink>. The instructions below assume the `/usr/local/lib/cockroach` location.

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

      ```
      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.

      ```
      cp -i cockroach-VERSION.linux-ARCHITECTURE/lib/libgeos.so /usr/local/lib/cockroach/
      ```

      ```
      cp -i cockroach-VERSION.linux-ARCHITECTURE/lib/libgeos_c.so /usr/local/lib/cockroach/
      ```

      If you get a permissions error, prefix the command with `sudo`.
3. 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:

      ```
      which cockroach
      ```

      ```
      /usr/local/bin/cockroach
      ```
   2. Start a temporary, in-memory cluster using <InternalLink path="cockroach-demo">`cockroach demo`</InternalLink>:

      ```
      cockroach demo
      ```

      * In the demo cluster's interactive SQL shell, run the following command to test that the spatial libraries have loaded properly:

        ```
        > SELECT ST_IsValid(ST_MakePoint(1,2">Releases</InternalLink>);
        ```

        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"
        ```

* Keep up-to-date with CockroachDB releases and best practices:

## Use Kubernetes

To orchestrate CockroachDB using [Kubernetes](https://kubernetes.io/), either with configuration files or the [Helm](https://helm.sh/) package manager, use the following tutorials:

* <InternalLink path="orchestrate-a-local-cluster-with-kubernetes">Orchestrate CockroachDB Locally with Minikube</InternalLink>
* <InternalLink path="deploy-cockroachdb-with-kubernetes">Orchestrate CockroachDB in a Single Kubernetes Cluster</InternalLink>
* <InternalLink path="orchestrate-cockroachdb-with-kubernetes-multi-cluster">Orchestrate CockroachDB Across Multiple Kubernetes Clusters</InternalLink>

## Use Docker

For CockroachDB v22.2.beta-5 and above, Docker images are [multi-platform images](https://docs.docker.com/build/building/multi-platform/) 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 **<InternalLink path="cockroachdb-feature-availability#feature-availability-phases">Limited Access</InternalLink>** 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](https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/). Please carefully check that you meet all prerequisites.
2. Confirm that the Docker daemon is running in the background:

   ```
   $ docker version
   ```

   If you do not see the server listed, start the **Docker** daemon.
3. Pull the image for the release of CockroachDB from [Docker Hub](https://hub.docker.com/r//):

   ```
   $ sudo docker pull :
   ```
4. Keep up-to-date with CockroachDB releases and best practices:

## Build from Source

See the [public wiki](https://wiki.crdb.io/wiki/spaces/CRDB/pages/181338446/Getting+and+building+CockroachDB+from+source) for guidance. When building on the ARM architecture, refer to [Limitations](#limitations).

<a id="best-practices" />

## Limitations

### ARM

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

* Floating point operations may yield different results on ARM than on Intel, particularly [Fused Multiply Add (FMA) intrinsics](https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation#Fused_multiply.E2.80.93add).
  Validate workloads that rely on floating point operations or FMA instrincs before migrating those workloads to ARM in production.
  When [building from source](#install-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](https://github.com/golang/go/issues/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](https://en.wikipedia.org/wiki/Non-uniform_memory_access), 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 64 cores to the node for each instance. Refer to the documentation for [`numactl --membind`](https://man7.org/linux/man-pages/man8/numactl.8.html).
* 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 <InternalLink path="architecture/replication-layer#intra-locality">`--locality`</InternalLink> 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?

* If you're just getting started with CockroachDB:
  * [Create a CockroachDB Cloud account](https://cockroachlabs.cloud/signup?experience=enterprise) where you can <InternalLink path="licensing-faqs">generate and manage licenses</InternalLink> for CockroachDB installations
  * <InternalLink path="start-a-local-cluster">Start a cluster locally</InternalLink> and talk to it via the built-in SQL client
  * <InternalLink path="learn-cockroachdb-sql">Learn more about CockroachDB SQL</InternalLink>
  * <InternalLink path="example-apps">Build a simple application</InternalLink> with CockroachDB using PostgreSQL-compatible client drivers and ORMs
  * <InternalLink path="demo-replication-and-rebalancing">Explore CockroachDB features</InternalLink> like automatic replication, rebalancing, and fault tolerance
* If you're ready to run CockroachDB in production:
  * Review the <InternalLink path="recommended-production-settings">Production Checklist</InternalLink>
  * <InternalLink path="manual-deployment">Deploy CockroachDB manually</InternalLink> or <InternalLink path="kubernetes-overview">use an orchestration system like Kubernetes</InternalLink>
