CockroachDB replicates and distributes data for you behind-the-scenes and uses a Gossip protocol to enable each node to locate data across the cluster.
To test this, use the built-in SQL client locally as follows:
-
On your local machine, launch the built-in SQL client, with the
--host
flag set to the address of any node:{% include copy-clipboard.html %}
$ cockroach sql --insecure --host=<address of any node>
-
Create an
insecurenodetest
database:{% include copy-clipboard.html %}
> CREATE DATABASE insecurenodetest;
-
Use
\q
orctrl-d
to exit the SQL shell. -
Launch the built-in SQL client, with the
--host
flag set to the address of a different node:{% include copy-clipboard.html %}
$ cockroach sql --insecure --host=<address of different node>
-
View the cluster's databases, which will include
insecurenodetest
:{% include copy-clipboard.html %}
> SHOW DATABASES;
+--------------------+ | Database | +--------------------+ | crdb_internal | | information_schema | | insecurenodetest | | pg_catalog | | system | +--------------------+ (5 rows)
-
Use
\q
to exit the SQL shell.