See Release Notes for what's new in the latest release, v20.2.19. To upgrade to this release from an older version, see Cluster Upgrade.
To try CockroachDB Cloud instead of running CockroachDB yourself, refer to the Cloud Quickstart.
Install options
Use one of the options below to install CockroachDB.
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.
-
Download the CockroachDB archive for Linux and the supporting libraries that are used to provide spatial features, and extract the binary:
$ curl https://binaries.cockroachdb.com/cockroach-v20.2.19.linux-amd64.tgz | tar -xz -
Copy the binary into your
PATHso you can execute cockroach commands from any shell:cp -i cockroach-v20.2.19.linux-amd64/cockroach /usr/local/bin/If you get a permissions error, prefix the command with
sudo. -
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/cockroachor alibsubdirectory of the CockroachDB binary's current directory. If you place these libraries in another location, you must pass the location in the--spatial-libsflag tocockroach start. The instructions below assume the/usr/local/lib/cockroachlocation.- Create the directory where the external libraries will be stored:
mkdir -p /usr/local/lib/cockroach - Copy the library files to the directory:
cp -i cockroach-v20.2.19.linux-amd64/lib/libgeos.so /usr/local/lib/cockroach/cp -i cockroach-v20.2.19.linux-amd64/lib/libgeos_c.so /usr/local/lib/cockroach/If you get a permissions error, prefix the command with
sudo.
- Create the directory where the external libraries will be stored:
Verify that CockroachDB can execute spatial queries.
Make sure the
cockroachbinary you just installed is the one that runs when you typecockroachin your shell:which cockroach/usr/local/bin/cockroachStart a temporary, in-memory cluster using
cockroach demo:cockroach demoIn 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));You should see the following output:
st_isvalidtrue (1 row)
If you plan to use CockroachDB's spatial features, you must complete the following steps. Otherwise, your installation is now complete.
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: