CockroachDB is an Open Source NewSQL DBMS. If you are new to the NewSQL world – CockroachDB can run on Raspberry Pi to large cluster of servers. Distributed Online Transaction Processing (OLTP) is one of the widely known use case of CockroachDB. CockroachDB is an interesting DBMS. It uses PostgreSQL protocol and you’ll feel to find some MySQL syntax. It has good things of both RDBMS and NoSQL. It is inspired by Google Spanner and developed by three ex-Google employees of Google. CockroackDB allows use to use the PostgreSQL drivers. So, we can practically reuse all the frameworks that have emerged in the “old era”. This is how we use the CLI :
1 2 3 | CREATE DATABASE IF NOT EXISTS test; USE test; ... |
Their official site has a guide to migrate from MySQL, PostgreSQL etc.
Steps to Install CockroachDB
You can install CockroachDB in the way of traditional installation or from Docker Hub. We are showing the steps of traditional SSH installation as one server, insecure installation with 512MB RAM. You need the IP address of the server, port 8080 and port 26257.
---
One server installation/running is just easy. wget
the binary. I am using /var/www/html
just for an example location :
1 2 3 4 5 6 | # mkdir -p /var/www/html/cockroachdb cd /var/www/html/cockroachdb wget https://binaries.cockroachdb.com/cockroach-latest.linux-amd64.tgz # |
Extract the downloaded file and delete the tarball :
1 2 3 4 5 6 7 8 | # tar -xvzf cockroach-latest.linux-amd64.tgz ls -al rm cockroach-latest.linux-amd64.tgz ls -al # |
We will copy the file to /usr/local/bin/
so that running a command from terminal finds it :
1 2 3 4 5 | # cp cockroach-latest.linux-amd64/cockroach /usr/local/bin/ # |
Now, if you run :
1 2 3 4 5 | # cockroach version # |
You’ll get response. It is the “installation”. You have to start it in this way :
1 2 3 | # cockroach start --insecure --background --advertise-host=23.24.25.26 # |
23.24.25.26
is an example IP address of the server. You will get a warning message like this :
1 2 3 4 5 6 7 8 9 10 11 | * * WARNING: RUNNING IN INSECURE MODE! * * - Your cluster is open for any client that can access <all your IP addresses>. * - 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/v2.0/secure-a-cluster.html * CockroachDB node starting at... |
You can access its web dashboard by visiting the URL http://23.24.25.26:8080
on your web browser. You can start the SQL client on SSH in this way :
1 2 3 4 5 | # cockroach sql --insecure # |
This ends this small guide to get started.
Tagged With cockroachdb raspberry pi 4 , instalition cockroch , install cockroach db in ubuntu