[id='configuring-global-persistent-location_{context}']
= Configuring the global persistent location

Enable and configure the location where {brandname} stores global state for clustered embedded caches.

[NOTE]
====
{brandname} Server enables global persistence and configures a default location.
You should not disable global persistence or change the default configuration for remote caches.
====

.Prerequisites

* Add {brandname} to your project.

.Procedure

. Enable global state in one of the following ways:
+
* Add the `global-state` element to your {brandname} configuration.
* Call the `globalState().enable()` methods in the `GlobalConfigurationBuilder` API.

. Define whether the global persistent location is unique to each node or shared between the cluster.
+
[%header%autowidth,cols="1,1",stripes=even]
|===
|Location type |Configuration

|Unique to each node
|`persistent-location` element or `persistentLocation()` method

|Shared between the cluster
|`shared-persistent-location` element or `sharedPersistentLocation(String)` method
|===

. Set the path where {brandname} stores cluster state.
+
For example, file-based cache stores the path is a directory on the host filesystem.
+
Values can be:
+
* Absolute and contain the full location including the root.
* Relative to a root location.

. If you specify a relative value for the path, you must also specify a system property that resolves to a root location.
+
For example, on a Linux host system you set `global/state` as the path.
You also set the `my.data` property that resolves to the `/opt/data` root location.
In this case {brandname} uses `/opt/data/global/state` as the global persistent location.

[discrete]
== Global persistent location configuration

.XML
[source,xml,options="nowrap",subs=attributes+,role="primary"]
----
include::xml/global_persistent_location.xml[]
----

.JSON
[source,json,options="nowrap",subs=attributes+,role="secondary"]
----
include::json/global_persistent_location.json[]
----

.YAML
[source,yaml,options="nowrap",subs=attributes+,role="secondary"]
----
include::yaml/global_persistent_location.yaml[]
----

.GlobalConfigurationBuilder
[source,java,options="nowrap",subs=attributes+,role="secondary"]
----
include::code_examples/GlobalPersistentLocation.java[]
----

[role="_additional-resources"]
.Additional resources
* link:{configdocroot}[{brandname} configuration schema]
* link:{javadocroot}/org/infinispan/configuration/global/GlobalStateConfiguration.html[org.infinispan.configuration.global.GlobalStateConfiguration]
