<commit_before>// Module included in the following assemblies:
//
// * post_installation_configuration/cluster-tasks.adoc
// * scalability_and_performance/recommended-host-practices.adoc

[id="etcd-defrag_{context}"]
= Defragmenting etcd data

Defragment etcd data to reclaim disk space after events that cause disk fragmentation, such as etcd history compaction.

History compaction is performed automatically every five minutes and leaves gaps in the back-end database. This fragmented space is available for use by etcd, but is not available to the host file system. You must defragment etcd to make this space available to the host file system.

Defragmentation occurs automatically, but you can also trigger it manually.

[NOTE]
====
Automatic defragmentation is good for most cases, because the etcd operator uses cluster information to determine the most efficient operation for the user.
====

== Automatic defragmentation

The etcd Operator automatically defragments disks. No manual intervention is needed.

Verify that the defragmentation process is successful by viewing one of these logs:

* etcd logs
* cluster-etcd-operator pod
* operator status error log

.Example log output
[source,terminal]
----
I0907 08:43:12.171919       1
defragcontroller.go:198] etcd member "ip-
10-0-191-150.us-west-2.compute.internal"
backend store fragmented: 39.33 %, dbSize:
349138944
----

== Manual defragmentation

You can monitor the `etcd_db_total_size_in_bytes` metric to determine whether manual defragmentation is necessary.

[WARNING]
====
Defragmenting etcd is a blocking action. The etcd member will not response until defragmentation is complete. For this reason, wait at least one minute between defragmentation actions on each of the pods to allow the cluster to recover.<commit_msg>add IDs to new H2s<commit_after>// Module included in the following assemblies:
//
// * post_installation_configuration/cluster-tasks.adoc
// * scalability_and_performance/recommended-host-practices.adoc

[id="etcd-defrag_{context}"]
= Defragmenting etcd data

Defragment etcd data to reclaim disk space after events that cause disk fragmentation, such as etcd history compaction.

History compaction is performed automatically every five minutes and leaves gaps in the back-end database. This fragmented space is available for use by etcd, but is not available to the host file system. You must defragment etcd to make this space available to the host file system.

Defragmentation occurs automatically, but you can also trigger it manually.

[NOTE]
====
Automatic defragmentation is good for most cases, because the etcd operator uses cluster information to determine the most efficient operation for the user.
====

[id="automatic-defrag-etcd-data_{context}"]
== Automatic defragmentation

The etcd Operator automatically defragments disks. No manual intervention is needed.

Verify that the defragmentation process is successful by viewing one of these logs:

* etcd logs
* cluster-etcd-operator pod
* operator status error log

.Example log output
[source,terminal]
----
I0907 08:43:12.171919       1
defragcontroller.go:198] etcd member "ip-
10-0-191-150.us-west-2.compute.internal"
backend store fragmented: 39.33 %, dbSize:
349138944
----

[id="manual-defrag-etcd-data_{context}"]
== Manual defragmentation

You can monitor the `etcd_db_total_size_in_bytes` metric to determine whether manual defragmentation is necessary.

[WARNING]
====
Defragmenting etcd is a blocking action. The etcd member will not response until defragmentation is complete. For this reason, wait at least one minute between defragmentation actions on each of the pods to allow the cluster to recover.
{'fraction_non_alphanumeric': 0.06528835690968444, 'fraction_numerical': 0.02366702937976061, 'mean_word_length': 4.902086677367576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3915985', 'n_tokens_mistral': 1063, 'n_tokens_neox': 983, 'n_words': 441}