How to Install CockroachDB on Mac OS X
Introduction
CockroachDB is an up and coming database technology that is focused on building SQL databases that can be distributed across multiple machines. NoSQL hit the scene to solve this exact problem but lost a lot of the advantages that come with SQL. CockroachDB allows businesses to scale up quickly, rebalance nodes, and repair data conflicts all built into the database engine. CockroachDB is a brand new tech that is comparable to Google’s Spanner database technology.
Many software companies that are familiar with the traditional SQL databases but whose dataset is growing too quickly for a single machine are looking at NewSQL technologies like CockroachDB to grow their companies. Since it is a new technology you’ll want to experiment with CockroachDB and in this tutorial we will show you how to install CockroachDB on Mac OS X.
We’ll show the commands step-by-step and explain what each command is doing but if you just want to see the commands scroll to the buttom for the Just The Commands section.
Prerequisites
- For this tutorial all you’ll have to know is how to access the Terminal because we’ll be installing CockroachDB via the Command Line.ß
1. Download the Binary Tar File
First we’ll be downloading the binary file so we’ll want to download it into a directory like ~/Downloads
or a directory where you feel comfortable downloading. First we’ll go to our ~/Downloads
folder:
1 | cd ~/Downloads |
The next step is to download the CockroachDB binary archive file and extract it. Run this next command in your terminal:
1 | curl https://binaries.cockroachdb.com/cockroach-v19.1.0.darwin-10.9-amd64.tgz | tar -xJ |
NOTE: This command is actually two commands separated by the |
. The first command uses curl to make a http request to cockroachdb.com
to request the binary file. The second tar -xJ
extracts the compressed file.
We have successfully downloaded the binary tar file.
2. Copy the Binary into your PATH
The next step is to copy the binary from the previous step into your PATH so you can execute cockroach commands easily in the Terminal. We need to copy it into your /usr/local/bin
where OS X looks for binaries to execute. Execute the following command in the Terminal:
1 | cp -i cockroach-v19.1.0.darwin-10.9-amd64/cockroach /usr/local/bin |
If you get any permission denied
errors you’ll need to run the same command prefixed with sudo
and enter your password when prompted. Sudo gives you admin access which is sometimes needed. Here is the command if the previous command gave you permission denied
errors:
1 | sudo cp -i cockroach-v19.1.0.darwin-10.9-amd64/cockroach /usr/local/bin |
These commands use the cp
command, which copies files and directories from one destination to another.
You won’t see any success messages, but if you don’t get any errors then consider it a success.
3. Verify by Starting CockroachDB
Finally we’ll start CockroachDB to confirm everything was installed correctly. We’ll run cockroach on localhost and in insecure
mode because we are running a production environment.ßß
1 | cockroach start --insecure --listen-addr=localhost |
Here is the output we saw and you should see something similar letting you know that your first CockroachDB cluster is up and running on localhost.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * * WARNING: RUNNING IN INSECURE MODE! * * - Your cluster is open for any client that can access localhost. * - Any user, even root, can log in without providing a password. * - Any user, connecting as root, can read or write any data in your cluster. * - There is no network encryption nor authentication, and thus no confidentiality. * * Check out how to secure your cluster: https://www.cockroachlabs.com/docs/v19.1/secure-a-cluster.html * CockroachDB node starting at 2019-05-07 20:01:26.565128 +0000 UTC (took 0.3s) build: CCL v19.1.0 @ 2019/04/29 18:31:15 (go1.11.6) webui: http://localhost:8080 sql: postgresql://root@localhost:26257?sslmode=disable client flags: cockroach <client cmd> --host=localhost:26257 --insecure logs: /Users/alexthompson/Downloads/cockroach-data/logs temp dir: /Users/alexthompson/Downloads/cockroach-data/cockroach-temp674995833 external I/O path: /Users/alexthompson/Downloads/cockroach-data/extern store[0]: path=/Users/alexthompson/Downloads/cockroach-data status: initialized new cluster clusterID: b9421d9c-5322-47fe-b184-d547683ba386 nodeID: |
Conclusion
In this tutorial we showed you how to install CockroachDB on your Mac OS X. We hope you’ll experiment with CockroachDB to determine if it is a good fit for your application.
Just The Commands
1 | cd ~/Downloads |
1 | curl https://binaries.cockroachdb.com/cockroach-v19.1.0.darwin-10.9-amd64.tgz | tar -xJ |
1 | cp -i cockroach-v19.1.0.darwin-10.9-amd64/cockroach /usr/local/bin |
OR
`
js
sudo cp -i cockroach-v19.1.0.darwin-10.9-amd64/cockroach /usr/local/bin
```js
cockroach start --insecure --listen-addr=localhost
Pilot the ObjectRocket Platform Free!
Try Fully-Managed CockroachDB, Elasticsearch, MongoDB, PostgreSQL (Beta) or Redis.
Get Started