Skip to content

Commit 425a273

Browse files
NataliaIvakinagfx54bAnnaSjerling
authored andcommitted
Add docs on the recreate procedure (#1819)
Co-authored-by: Balazs Lendvai <[email protected]> Co-authored-by: Anna Sjerling <[email protected]>
1 parent 2dbaa7f commit 425a273

File tree

2 files changed

+124
-1
lines changed

2 files changed

+124
-1
lines changed

modules/ROOT/pages/clustering/databases.adoc

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,129 @@ neo4j@neo4j> DRYRUN REALLOCATE DATABASES;
225225
+----------------------------------------------------------------------------------------------------------------------------------------+
226226
----
227227

228+
[role=label--new-5.24]
229+
[[recreate-databases]]
230+
== Recreate a database
231+
232+
Neo4j 5.24 introduces the xref:reference/procedures.adoc#procedure_dbms_cluster_recreateDatabase[`dbms.cluster.recreateDatabase()`] procedure, which allows you:
233+
234+
* To change the database store to a specified backup, while keeping all the associated privileges for the database.
235+
236+
* To make your database write-available again after it has been lost (for example, due to a disaster).
237+
// See xref:clustering/disaster-recovery.adoc[] for more information.
238+
239+
[CAUTION]
240+
====
241+
The recreate procedure works only for real user databases and not for composite databases, or the `system` database.
242+
243+
Remember that the recreate procedure results in downtime while the stores get updated.
244+
The time is unbounded and may depend on different factors -- for example, the size of the store, network speed, etc.
245+
====
246+
247+
The database in question can be in an `online` or `offline` state when it is recreated, but a successful operation starts the database regardless of its previous state.
248+
249+
If your database has Change Data Capture (CDC) enabled, the CDC chain will stop when the database is recreated, even though CDC remains enabled in the recreated database.
250+
To restore CDC functionality, follow the guide on how link:https://neo4j.com/docs/cdc/current/existing-databases/[to initialize CDC applications from an existing database].
251+
252+
Before recreating a database, any eventual quarantined states need to be addressed.
253+
For more information, see xref:database-administration/standard-databases/errors.adoc#quarantine[Standard databases -> Error handling].
254+
255+
You need xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-database-management[the `CREATE DATABASE` and `DROP DATABASE` privileges] to run the recreate procedure.
256+
257+
To check if the recreation is successful, use the `SHOW DATABASES` command and verify that all allocations have been started.
258+
259+
Additionally, you have the option to modify <<alter-topology-recreate, the topology>> during the recreation process.
260+
However, note that the store format, access, and enrichment cannot be altered during recreation.
261+
262+
[[recreate-seeding-options]]
263+
=== Seeding options
264+
265+
The store to be used during the recreation of a database can be defined in different ways.
266+
One method uses a backup, while others use available allocations in the cluster.
267+
268+
You can use either <<uri-seed, `seedURI`>> or <<seed-servers, `seedingServers`>> to specify the source from which the database should be recreated.
269+
270+
* If you define neither, an error is thrown.
271+
272+
* If you define both of them, then `seedingServers` must be an empty list.
273+
See <<undefined-servers-backup, Undefined servers with fallback backup>> for more details.
274+
275+
* If `seedingServers` is not empty and `seedURI` is also defined, an error will occur.
276+
277+
[[uri-seed]]
278+
==== Use backup as a seed
279+
280+
If you provide a URI to a backup or a dump, the stores on all allocations will be replaced by the backup or the dump at the given URI.
281+
The new allocations can be put on any `ENABLED` server in the cluster.
282+
See <<cluster-seed-uri, Seed from URI>> for more details.
283+
284+
285+
[source, shell]
286+
----
287+
CALL dbms.cluster.recreateDatabase("neo4j", {seedURI: "s3:/myBucket/myBackup.backup"});
288+
----
289+
290+
[[seed-servers]]
291+
==== Use available servers as a seed
292+
293+
After the recreation is complete, the database will have the latest data store from the seeding servers.
294+
295+
[CAUTION]
296+
====
297+
Recreation is based on remaining stores or a store defined by the user.
298+
This means that stores which were lost or not defined are not used for the recreation.
299+
If not used stores were more up to date than the used ones, this results in data loss.
300+
====
301+
302+
[[specified-servers]]
303+
===== Specified servers
304+
305+
You can specify a set of available servers.
306+
The stores on all allocations will be synchronized to the most up-to-date store from the defined servers.
307+
The number of defined servers cannot exceed the number of total allocations in the desired topology.
308+
309+
[source, shell]
310+
----
311+
CALL dbms.cluster.recreateDatabase("neo4j", {seedingServers: ["serverId1", "serverId2", "serverId3"]});
312+
----
313+
314+
[[undefined-servers]]
315+
===== Undefined servers
316+
317+
If you provide an empty list of seeding servers and do not specify a `seedURI`, Neo4j automatically selects all available allocations of the database as seeders.
318+
The store will be replaced by the most up-to-date seeder available in the cluster.
319+
320+
[source, shell]
321+
----
322+
CALL dbms.cluster.recreateDatabase("neo4j", {seedingServers: []});
323+
----
324+
325+
[[undefined-servers-backup]]
326+
===== Undefined servers with fallback backup
327+
328+
If both an empty list of seeding servers and a `seedURI` are provided, Neo4j finds all available allocations of the database and use those as seeders.
329+
However, if no available servers can be found, the database is recreated based on the backup or the dump defined by the URI.
330+
This means the store is replaced by the most up-to-date seeder if available; otherwise, the backup is used.
331+
332+
[source, shell]
333+
----
334+
CALL dbms.cluster.recreateDatabase("neo4j", {seedingServers: [], seedURI: "s3:/myBucket/myBackup.backup"});
335+
----
336+
337+
[[alter-topology-recreate]]
338+
=== Change the topology
339+
340+
There is an option to define a new topology when recreating a database.
341+
This can be beneficial during a disaster, if enough servers are not available to recreate the database with the original topology.
342+
When altering the total number of allocations down during a recreation, it is important to remember that the number of seeding servers cannot exceed the number of total allocations of the database.
343+
This also holds true when using recreate with an empty list of seeders.
344+
If there are more available servers in the cluster hosting the database than the number of new allocations, the recreation will fail.
345+
346+
[source, shell]
347+
----
348+
CALL dbms.cluster.recreateDatabase("neo4j", {seedingServers: [], primaries: 3, secondaries: 0});
349+
----
350+
228351
[[cluster-seed]]
229352
== Seed a cluster
230353

modules/ROOT/pages/clustering/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This chapter describes the following:
99
* Setting up a cluster -- The basics of configuring and deploying a new cluster.
1010
** xref:clustering/setup/deploy.adoc[Deploy a basic cluster] -- How to set up a basic cluster.
1111
** xref:clustering/setup/analytics-cluster.adoc[Deploy an analytics cluster] -- How to deploy a special case Neo4j cluster for analytic queries.
12-
** xref:clustering/setup/single-to-cluster.adoc[Move from single server to cluster] -- This section describes how to move from a single Neo4j server to Neo4j cluster.
12+
** xref:clustering/setup/single-to-cluster.adoc[Move from a standalone deployment to a cluster] -- This section describes how to move from a single Neo4j server to Neo4j cluster.
1313
** xref:clustering/setup/discovery.adoc[Cluster server discovery] -- How servers in a cluster discover each other and form a cluster.
1414
** xref:clustering/setup/routing.adoc[Leadership, routing and load balancing] -- Election of leaders, routing and load balancing.
1515
** xref:clustering/setup/encryption.adoc[Intra-cluster encryption] -- How to secure the cluster communication.

0 commit comments

Comments
 (0)