6.4. Databases in a Causal Cluster

This section describes how to manage multiple active databases in a Causal Cluster.

Multiple databases in a Causal Cluster are managed the same way as a single instance. Administrators can use the same Cypher commands described in Section 6.2.1, “Administrative commands” to manage databases. This is based on two main principles:

6.4.1. Running Cypher administrative commands from Cypher Shell on a Causal Cluster.

For the following examples, consider a Causal Cluster environment formed by 5 members, 3 Core servers, and 2 Read Replicas:

Example 6.10. View the members of a Causal Cluster
neo4j@neo4j> CALL dbms.cluster.overview();
+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id        | addresses                                                                    | databases                   | groups |
+------------------------------------------------------------------------------------------------------------------------------------------------------------+
| "8c...3d" | ["bolt://localhost:7683", "http://localhost:7473", "https://localhost:7483"] | {neo4j: "FOLLOWER", system: "FOLLOWER"}         | []     |
| "8f...28" | ["bolt://localhost:7681", "http://localhost:7471", "https://localhost:7481"] | {neo4j: "LEADER", system: "LEADER"}                   | []     |
| "e0...4d" | ["bolt://localhost:7684", "http://localhost:7474", "https://localhost:7484"] | {neo4j: "READ_REPLICA", system: "READ_REPLICA"}     | []     |
| "1a...64" | ["bolt://localhost:7682", "http://localhost:7472", "https://localhost:7482"] | {neo4j: "FOLLOWER", system: "FOLLOWER"}         | []     |
| "59...87" | ["bolt://localhost:7685", "http://localhost:7475", "https://localhost:7485"] | {neo4j: "READ_REPLICA", system: "READ_REPLICA"}     | []     |
+------------------------------------------------------------------------------------------------------------------------------------------------------------+

5 rows available after 5 ms, consumed after another 0 ms

The leader is currently the instance exposing port 7681 for the bolt protocol, and 7471/7481 for the http/https protocol.

Administrators can connect and execute Cypher commands in the following ways:

Example 6.11. Using the bolt:// scheme to connect to the Leader:
$ bin/cypher-shell -a bolt://localhost:7681 -d system -u neo4j -p neo4j1
Connected to Neo4j 4.0.0 at bolt://localhost:7681 as user neo4j.
Type :help for a list of available commands or :exit to exit the shell.
Note that Cypher queries must end with a semicolon.
neo4j@system> SHOW DATABASES;
+-------------------------------+
| name     | status   | default |
+-------------------------------+
| "neo4j"  | "online" | TRUE    |
| "system" | "online" | FALSE   |
+-------------------------------+

2 rows available after 34 ms, consumed after another 0 ms
neo4j@system> CREATE DATABASE data001;
0 rows available after 378 ms, consumed after another 12 ms
Added 1 nodes, Set 4 properties, Added 1 labels
neo4j@system> SHOW DATABASES;
+--------------------------------+
| name      | status   | default |
+--------------------------------+
| "neo4j"   | "online" | TRUE    |
| "system"  | "online" | FALSE   |
| "data001" | "online" | FALSE   |
+--------------------------------+

3 rows available after 2 ms, consumed after another 1 ms
Example 6.12. Using the neo4j:// scheme to connect to any Core member:
$ bin/cypher-shell -a neo4j://localhost:7683 -d system -u neo4j -p neo4j1
Connected to Neo4j 4.0.0 at neo4j://localhost:7683 as user neo4j.
Type :help for a list of available commands or :exit to exit the shell.
Note that Cypher queries must end with a semicolon.
neo4j@system> SHOW DATABASES;
+--------------------------------+
| name      | status   | default |
+--------------------------------+
| "neo4j"   | "online" | TRUE    |
| "system"  | "online" | FALSE   |
| "data001" | "online" | FALSE   |
+--------------------------------+

3 rows available after 0 ms, consumed after another 0 ms
neo4j@system> CREATE DATABASE data002;
0 rows available after 8 ms, consumed after another 1 ms
Added 1 nodes, Set 4 properties, Added 1 labels
neo4j@system> SHOW DATABASES;
+--------------------------------+
| name      | status   | default |
+--------------------------------+
| "neo4j"   | "online" | TRUE    |
| "system"  | "online" | FALSE   |
| "data001" | "online" | FALSE   |
| "data002" | "online" | FALSE   |
+--------------------------------+

4 rows available after 33 ms, consumed after another 0 ms

The neo4j:// scheme is the equivalent to the bolt+routing: scheme available in earlier versions of Neo4j, but it can be used seamlessly with a standalone and clustered DBMS.