Skip to content

Commit

Permalink
Restructure the Managing standard databases page (neo4j#1532)
Browse files Browse the repository at this point in the history
Co-authored-by: Reneta Popova <[email protected]>
  • Loading branch information
NataliaIvakina and renetapopova authored Apr 18, 2024
1 parent 5f54fc6 commit 99281a8
Show file tree
Hide file tree
Showing 16 changed files with 894 additions and 896 deletions.
6 changes: 5 additions & 1 deletion modules/ROOT/content-nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@
* xref:database-administration/index.adoc[]
** Standard databases
*** xref:database-administration/standard-databases/naming-databases.adoc[]
*** xref:database-administration/standard-databases/manage-databases.adoc[]
*** xref:database-administration/standard-databases/create-databases.adoc[]
*** xref:database-administration/standard-databases/listing-databases.adoc[]
*** xref:database-administration/standard-databases/alter-databases.adoc[]
*** xref:database-administration/standard-databases/delete-databases.adoc[]
*** xref:database-administration/standard-databases/wait-options.adoc[]
*** xref:database-administration/standard-databases/configuration-parameters.adoc[]
*** xref:database-administration/standard-databases/errors.adoc[]
** Database aliases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ These include the rights to perform the following classes of tasks:
** Allow the creation of labels, relationship types, or property names.
** Manage transactions.
* Manage xref:authentication-authorization/dbms-administration.adoc[DBMS privileges] to control the rights to perform actions on the entire system:
** Manage xref:database-administration/standard-databases/manage-databases.adoc[multiple databases].
** Manage xref:database-administration/index.adoc[multiple databases].
** Manage xref:authentication-authorization/manage-users.adoc[users] and xref:authentication-authorization/manage-roles.adoc[roles].
** Change configuration parameters.
** Manage sub-graph privileges.
Expand Down
2 changes: 1 addition & 1 deletion modules/ROOT/pages/backup-restore/restore-backup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Restoring a database backup to a previous Neo4j version is not supported.

You must create the database (using `CREATE DATABASE` against the `system` database) after the restore operation finishes, unless you are replacing an existing database.
`neo4j-admin database restore` must be invoked as the `neo4j` user to ensure the appropriate file permissions.
For more information, see xref:database-administration/standard-databases/manage-databases.adoc[Manage databases].
For more information, see xref:database-administration/standard-databases/create-databases.adoc[Create databases].

[NOTE]
====
Expand Down
4 changes: 2 additions & 2 deletions modules/ROOT/pages/clustering/databases.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ If a database is no longer needed, the command `DROP DATABASE` deletes the datab

== `CREATE DATABASE`

The command to create a database in a cluster is not significantly different from the command to create a database in a non-clustered environment (see xref:database-administration/standard-databases/manage-databases.adoc[Database management] for more information on database management on single servers).
The command to create a database in a cluster is not significantly different from the command to create a database in a non-clustered environment (see xref:database-administration/standard-databases/create-databases.adoc[Create, start, and stop databases] for more information on database management on single servers).
The difference in a clustered environment is that the topology can be specified, i.e. how many primaries and secondaries are desired for the database.
To create a database `foo` with 3 servers hosting the database in primary mode and 2 servers in secondary mode, the command looks like this:

Expand Down Expand Up @@ -63,7 +63,7 @@ It is not possible to automatically transition to a topology with a single prima

However, it is possible to _manually_ do this transition.
The first step is to back up the database, see xref:backup-restore/index.adoc[Backup and restore] for more information.
Once the database is backed up, the next step is to drop the database, see xref:database-administration/standard-databases/manage-databases.adoc[Manage databases] for more information.
Once the database is backed up, the next step is to drop the database, see xref:database-administration/standard-databases/delete-databases.adoc[Delete databases] for more information.
The last step is to either seed a cluster from the backup with the new topology, or to restore the backup on a single server.
See xref:clustering/databases.adoc#cluster-seed[Seed a cluster] further on for information on seeding.

Expand Down
2 changes: 1 addition & 1 deletion modules/ROOT/pages/clustering/disaster-recovery.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Once the `system` database is verified available, and all servers are online, th
The steps here aim to make the unavailable databases available.

. If you have previously dropped databases as part of this guide, re-create each one from backup.
See the xref:database-administration/standard-databases/manage-databases.adoc[Manage databases] section for more information on how to create a database.
See the xref:database-administration/standard-databases/create-databases.adoc[Create databases] section for more information on how to create a database.
. Run `SHOW DATABASES`.
If all databases are in desired states on all servers (`requestedStatus`=`currentStatus`), disaster recovery is complete.
// . For each database that remains unavailable, refer to <<unavailable-databases, Managing unavailable databases in a cluster>>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ For example:

The possible values for `currentStatus` are `online`, `offline`, `starting`, `stopping`, `store copying`, `initial`, `deallocating`, `dirty`, `quarantined`, and `unknown`.
The `requestedStatus` can only be `online` or `offline`.
See xref::database-administration/standard-databases/manage-databases.adoc#database-states[Database states] for more information.
See xref::database-administration/standard-databases/listing-databases.adoc#database-states[Database states] for more information.

Additionally, note that databases hosted on servers that are offline are also returned by the `SHOW DATABASES` command.
For such databases the `address` column displays `NULL`, the `currentStatus` column displays `unknown`, and the `statusMessage` displays `Server is unavailable`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Composite databases are managed using Cypher(R) administrative commands.
Note that it is not possible to modify access options or database topologies for composite databases as these are inherited from the constituent databases.
For information about modifying access options, see xref:database-administration/standard-databases/manage-databases.adoc#manage-databases-alter[Alter database access mode].
For information about modifying access options, see xref:database-administration/standard-databases/alter-databases.adoc#manage-databases-alter[Alter database access mode].
For information about about topologies for databases, see xref:clustering/setup/deploy.adoc#cluster-example-create-databases-on-cluster[Create databases in a cluster].
// The above two links will have to be changed when server management and access control sections are migrated from Cypher Manual.

Expand Down Expand Up @@ -43,7 +43,7 @@ SHOW DATABASES
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
----

For a description of all the returned column of this command, ways in which the `SHOW DATABASE` command can be filtered, and details about the privileges required for the command, see xref:database-administration/standard-databases/manage-databases.adoc#manage-databases-list[listing standard databases].
For a description of all the returned column of this command, ways in which the `SHOW DATABASE` command can be filtered, and details about the privileges required for the command, see xref:database-administration/standard-databases/listing-databases.adoc#manage-databases-list[listing standard databases].

For composite databases, the `constituents` column is particularly interesting as it lists the aliases that make up the composite database.

Expand Down Expand Up @@ -106,7 +106,7 @@ SHOW DATABASES
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
----

For a full description of the columns returned by this command, and how to sort the results by specific columns, see xref:database-administration/standard-databases/manage-databases.adoc#manage-databases-listing-databases[Managing databases].
For a full description of the columns returned by this command, and how to sort the results by specific columns, see xref:database-administration/standard-databases/listing-databases.adoc#manage-databases-listing-databases[Managing databases].

To create database aliases in the composite database, give the composite database as a namespace for the alias.
For information about creating aliases in composite databases, see xref:database-administration/aliases/manage-aliases-composite-databases.adoc#create-composite-database-alias[Managing aliases in composite databases].
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
:description: how to modify standard databases in Neo4j using the Cypher command `ALTER DATABASE`.
[role=enterprise-edition not-on-aura]
[[administration-databases-alter-database]]
= Alter databases
Standard databases can be modified using the command `ALTER DATABASE`.

[[manage-databases-alter]]
== Alter database access mode

By default, a database has read-write access mode on creation.
The database can be limited to read-only mode on creation using the configuration parameters `dbms.databases.default_to_read_only`, `dbms.databases.read_only`, and `dbms.database.writable`.
For details, see the section on xref::database-administration/standard-databases/configuration-parameters.adoc#[Configuration parameters].
A database that was created with read-write access mode can be changed to read-only.
To change it to read-only, you can use the `ALTER DATABASE` command with the sub-clause `SET ACCESS READ ONLY`.
Subsequently, the database access mode can be switched back to read-write using the sub-clause `SET ACCESS READ WRITE`.
Altering the database access mode is allowed at all times, whether a database is online or offline.

If conflicting modes are set by the `ALTER DATABASE` command and the configuration parameters, i.e. one says read-write and the other read-only, the database will be read-only and prevent write queries.

The `WAIT` _sub-clause was added as an option to the_ `ALTER DATABASE` _command in Neo4j 5.7._

[NOTE]
====
Modifying access mode is only available to standard databases and not composite databases.
====


=== Alter database access mode to read-only

.Query
[source, cypher]
----
ALTER DATABASE customers SET ACCESS READ ONLY
----

The database access mode can be seen in the `access` output column of the command `SHOW DATABASES`.

.Query
[source, cypher]
----
SHOW DATABASES yield name, access
----

.Result
[role="queryresult"]
----
+----------------------------+
| name | access |
+----------------------------+
| "customers" | "read-only" |
| "movies" | "read-write" |
| "neo4j" | "read-write" |
| "system" | "read-write" |
+----------------------------+
----

=== Alter database access using `IF EXISTS`

`ALTER DATABASE` commands are optionally idempotent, with the default behavior to fail with an error if the database does not exist.
Appending `IF EXISTS` to the command ensures that no error is returned and nothing happens should the database not exist.

.Query
[source, cypher]
----
ALTER DATABASE nonExisting IF EXISTS
SET ACCESS READ WRITE
----

== Alter database topology

In a cluster environment, you can use the `ALTER DATABASE` command to change the number of servers hosting a database.
For more information, see xref::clustering/databases.adoc#alter-topology[Managing databases in a cluster].

[[alter-database-options]]
== Alter database options

The `ALTER DATABASE` command can be used to set or remove specific options for a database.

[options="header", cols="1m,1m,3a"]
|===
| Key
| Value
| Description

| txLogEnrichment
| FULL\|DIFF\|NONE
| Defines the level of enrichment applied to transaction logs for Change Data Capture (CDC) purposes.
For details about enrichment mode, see link:{neo4j-docs-base-uri}/cdc/{page-version}/getting-started/enrichment-mode[Change Data Capture Manual -> Getting Started -> Enrichment mode].
|===

[NOTE]
====
There are no available `OPTIONS` values for composite databases.
====

=== Alter the options set for a database

.Query
[source, cypher]
----
ALTER DATABASE `movies`
SET OPTION txLogEnrichment 'FULL'
----

The database set options can be seen in the `options` output column of the command `SHOW DATABASES`.

.Query
[source, cypher]
----
SHOW DATABASES yield name, options
----
// Limited result set.
// The output has been capped.
.Result
[role="queryresult",options="header,footer",cols="2*<m"]
|===
| +name+ | +options+
| +"customers"+ | +{}+
| +"movies"+ | +{txLogEnrichment: "FULL"}+
| +"neo4j"+ | +{}+
| +"system"+ | +{}+
2+d|Rows: 4
|===

=== Remove the options set for a database

.Query
[source, cypher]
----
ALTER DATABASE `movies`
REMOVE OPTION txLogEnrichment
----

The `REMOVE OPTION` clause removes the specified option from the database using the `ALTER DATABASE` command.

.Query
[source, cypher]
----
SHOW DATABASES YIELD name, options
----
// Limited result set.
// The output has been capped.
.Result
[role="queryresult",options="header,footer",cols="2*<m"]
|===
| +name+ | +options+
| +"customers"+ | +{}+
| +"movies"+ | +{}+
| +"neo4j"+ | +{}+
| +"system"+ | +{}+
2+d|Rows: 4
|===
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Regardless of settings of `server.databases.default_to_read_only`, `server.datab

[NOTE]
====
Another way of preventing writes is to set the database access to read-only using the xref:database-administration/standard-databases/manage-databases.adoc#manage-databases-alter[ALTER DATABASE] command.
Another way of preventing writes is to set the database access to read-only using the xref:database-administration/standard-databases/alter-databases.adoc#manage-databases-alter[ALTER DATABASE] command.
====


Expand Down
Loading

0 comments on commit 99281a8

Please sign in to comment.