See Release Notes for what's new in the latest release, v21.1.21. To upgrade to this release from an older version, see Cluster Upgrade.
To deploy a free CockroachDB Cloud cluster instead of running CockroachDB yourself, see the Quickstart.
Install options
Use one of the options below to install CockroachDB.
Download the binary
-
Download the CockroachDB archive for OS X and the supporting libraries that are used to provide spatial features, and copy the binary into your
PATH
so you can execute cockroach commands from any shell:$ curl https://binaries.cockroachdb.com/cockroach-v21.1.21.darwin-10.9-amd64.tgz | tar -xJ && cp -i cockroach-v21.1.21.darwin-10.9-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/cockroach
or alib
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 tocockroach start
. The instructions below assume the/usr/local/lib/cockroach
location.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-v21.1.21.darwin-10.9-amd64/lib/libgeos.dylib /usr/local/lib/cockroach/
cp -i cockroach-v21.1.21.darwin-10.9-amd64/lib/libgeos_c.dylib /usr/local/lib/cockroach/
If you get a permissions error, prefix the command with
sudo
.
Verify that CockroachDB can execute spatial queries.
Make sure the
cockroach
binary you just installed is the one that runs when you typecockroach
in your shell:which cockroach
/usr/local/bin/cockroach
Start a temporary, in-memory cluster using
cockroach demo
: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));
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:
If you plan to use CockroachDB's spatial features, you must complete the following steps. Otherwise, your installation is now complete.
Use Kubernetes
To orchestrate CockroachDB locally using Kubernetes, either with configuration files or the Helm package manager, see Orchestrate CockroachDB Locally with Minikube.
Use Docker
-
Install Docker for Mac. Please carefully check that you meet all prerequisites.
-
Confirm that the Docker daemon is running in the background:
$ docker version
If you do not see the server listed, start the Docker daemon.
-
Pull the image for the v21.1.21 release of CockroachDB from Docker Hub:
$ docker pull cockroachdb/cockroach:v21.1.21
-
Keep up-to-date with CockroachDB releases and best practices:
Build from source
-
Install the following prerequisites, as necessary:
C++ compiler Must support C++ 11. GCC prior to 6.0 does not work due to this issue. On macOS, Xcode should suffice. Go Version 1.15.11+ is required. Older versions might work via make build IGNORE_GOVERS=1
.Bash Versions 4+ are preferred, but later releases from the 3.x series are also known to work. CMake Versions 3.17.0+ are known to work. Autoconf Version 2.68+ is required. A 64-bit system is strongly recommended. Building or running CockroachDB on 32-bit systems has not been tested. You'll also need at least 2GB of RAM. If you plan to run our test suite, you'll need closer to 4GB of RAM.
-
Download the CockroachDB v21.1.21 source archive, and extract the sources:
$ curl https://binaries.cockroachdb.com/cockroach-v21.1.21.src.tgz | tar -xz
In the extracted directory, run
make build
:cd cockroach-v21.1.21
make build
The build process can take 10+ minutes, so please be patient.
-
Install the
cockroach
binary into/usr/local/bin/
so it's easy to executecockroach
commands from any directory:make install
If you get a permissions error, prefix the command with
sudo
.You can also execute the
cockroach
binary directly from its built location,./src/github.com/cockroachdb/cockroach/cockroach
, but the rest of the documentation assumes you have the binary on yourPATH
. -
Keep up-to-date with CockroachDB releases and best practices:
What's next?
- If you're just getting started with CockroachDB:
- Start a cluster locally and talk to it via the built-in SQL client
- Learn more about CockroachDB SQL
- Build a simple application with CockroachDB using Postgres-compatible client drivers and ORMs
- Explore core CockroachDB features like automatic replication, rebalancing, and fault tolerance
- If you're ready to run CockroachDB in production: