mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 11:45:50 +00:00
Reorg infrastructure folders
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
---
|
||||
html: configure-advisory-deletion.html
|
||||
parent: data-retention.html
|
||||
blurb: Use advisory deletion to delete older ledger history on a schedule rather than as new history becomes available.
|
||||
labels:
|
||||
- Core Server
|
||||
- Data Retention
|
||||
---
|
||||
# Configure Advisory Deletion
|
||||
|
||||
The default config file sets [`rippled`](xrpl-servers.html) to automatically delete outdated [history](ledger-history.html) of XRP Ledger state and transactions as new ledger versions become available. If your server uses most of its hardware resources during peak hours, you can configure the server to delete ledgers only when prompted by a command scheduled to run during off-peak hours, so that online deletion is less likely to impact [server performance](capacity-planning.html).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This tutorial assumes your server meets the following prerequisites:
|
||||
|
||||
- You are on a supported operating system: Ubuntu Linux, Red Hat Enterprise Linux (RHEL), or CentOS.
|
||||
|
||||
- The `rippled` server is already [installed](install-rippled.html) and [online deletion](online-deletion.html) is enabled.
|
||||
|
||||
The default config file enables online deletion after 2000 ledger versions.
|
||||
|
||||
- A `cron` daemon is installed and running.
|
||||
|
||||
Ubuntu Linux runs a `cron` daemon by default.
|
||||
|
||||
On RHEL or CentOS, you can install the `cronie` package:
|
||||
|
||||
$ sudo yum install cronie
|
||||
|
||||
- Your server has enough disk space to store your chosen amount of history in its ledger store.
|
||||
|
||||
See [Capacity Planning](capacity-planning.html) for details of how much storage is required for different configurations. With advisory deletion enabled, the maximum history a server may accumulate before deletion is equal to the number of ledger versions configured in the `online_delete` setting **plus** the amount of time between online deletion prompts.
|
||||
|
||||
- You know which hours are least busy for your server.
|
||||
|
||||
## Configuration Steps
|
||||
|
||||
To configure advisory deletion with a daily schedule, perform the following steps:
|
||||
|
||||
1. Enable `advisory_delete` in the `[node_db]` stanza of your `rippled`'s config file.
|
||||
|
||||
[node_db]
|
||||
# Other settings unchanged ...
|
||||
online_delete=2000
|
||||
advisory_delete=1
|
||||
|
||||
- Set `advisory_delete` to `1` to run online deletion only when prompted. (Set it to `0` to run online deletion automatically as new ledger versions become available.)
|
||||
- Set `online_delete` to the minimum number of ledger versions to keep after running online deletion. The server accumulates more history than this until online deletion runs.
|
||||
|
||||
{% include '_snippets/conf-file-location.md' %}<!--_ -->
|
||||
|
||||
2. Test running the [can_delete method][] to prompt the server to run online deletion.
|
||||
|
||||
You can use the [`rippled` commandline interface](get-started-using-http-websocket-apis.html#commandline) to run this command. For example:
|
||||
|
||||
$ rippled --conf=/etc/opt/ripple/rippled.cfg can_delete now
|
||||
|
||||
The response indicates the maximum ledger index that the server may delete from its ledger store. For example, the following message indicates that ledger versions up to and including ledger index 43633667 can be deleted:
|
||||
|
||||
{
|
||||
"result": {
|
||||
"can_delete": 43633667,
|
||||
"status": "success"
|
||||
}
|
||||
}
|
||||
|
||||
The server only deletes those ledger versions if the number of _newer_ validated ledger versions it has is equal to or greater than the `online_delete` setting.
|
||||
|
||||
3. Configure your `cron` daemon to run the `can_delete` method you tested in the previous step at a scheduled time.
|
||||
|
||||
Edit your `cron` configuration:
|
||||
|
||||
$ crontab -e
|
||||
|
||||
The following example sets the server to run deletion at 1:05 AM server time daily:
|
||||
|
||||
5 1 * * * rippled --conf /etc/opt/ripple/rippled.cfg can_delete now
|
||||
|
||||
Be sure that you schedule the command to run based on your server's configured time zone.
|
||||
|
||||
**Tip:** You do not need to schedule a `cron` job to run online deletion if you have `advisory_delete` disabled. In that case, `rippled` runs online deletion automatically when the difference between the server's oldest and current validated ledger versions is at least the value of `online_delete`.
|
||||
|
||||
4. Start (or restart) the `rippled` service.
|
||||
|
||||
$ sudo systemctl restart rippled
|
||||
|
||||
5. Periodically check your server's `complete_ledgers` range using the [server_info method][] to confirm that ledgers are being deleted as scheduled.
|
||||
|
||||
The lowest ledger index in `complete_ledgers` should increase after online deletion.
|
||||
|
||||
Deletion may take several minutes to complete when it runs, depending on how busy your server is and how much history you delete at a time.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If online deletion does not seem to be running after configuring it, try the following:
|
||||
|
||||
- Check that the user who configured the `cron` job has permissions to run the `rippled` server as a commandline client.
|
||||
- Check the syntax of your `cron` job and the time when it is supposed to run.
|
||||
- Check that the `rippled` executable is available at the path specified in your `cron` configuration. If necessary, specify the absolute path to the executable, such as `/opt/ripple/bin/rippled`.
|
||||
- Check your `rippled` logs for messages that begin with `SHAMapStore::WRN`. This can indicate that [online deletion is being interrupted](online-deletion.html#interrupting-online-deletion) because your server fell out of sync with the network.
|
||||
|
||||
## See Also
|
||||
|
||||
- **Concepts:**
|
||||
- [Ledger History](ledger-history.html)
|
||||
- [Online Deletion](online-deletion.html)
|
||||
- **Tutorials:**
|
||||
- [Configure Online Deletion](configure-online-deletion.html)
|
||||
- [Diagnosing Problems with rippled](diagnosing-problems.html)
|
||||
- [Understanding Log Messages](understanding-log-messages.html)
|
||||
- **References:**
|
||||
- [server_info method][]
|
||||
- [can_delete method][]
|
||||
- [logrotate method][]
|
||||
- [Ledger Data Formats](ledger-data-formats.html)
|
||||
|
||||
<!--{# common link defs #}-->
|
||||
{% include '_snippets/rippled-api-links.md' %}
|
||||
{% include '_snippets/tx-type-links.md' %}
|
||||
{% include '_snippets/rippled_versions.md' %}
|
||||
@@ -0,0 +1,117 @@
|
||||
---
|
||||
html: configure-full-history.html
|
||||
parent: data-retention.html
|
||||
blurb: Full history servers provide a record of every transaction ever to occur in the XRP Ledger, although they are expensive to run.
|
||||
labels:
|
||||
- Core Server
|
||||
- Data Retention
|
||||
---
|
||||
# Configure Full History
|
||||
|
||||
In its default configuration, the `rippled` server automatically deletes outdated history of XRP Ledger state and transactions as new ledger versions become available. This is enough for most servers, which do not need older history to know the current state and process transactions. However, it can be useful for the network if some servers provide as much history of the XRP Ledger as possible.
|
||||
|
||||
## Warnings
|
||||
|
||||
Storing full history is expensive. As of 2023-07-19, the full history of the XRP Ledger occupies approximately **26 terabytes** of disk space, which must be entirely stored on fast solid state disk drives for proper server performance. Such a large amount of solid state storage is not cheap, and the total amount of history you must store increases by approximately 12 GB per day.
|
||||
|
||||
Additionally, storing full history in NuDB requires single files that are larger than the 16 TB limit of ext4 filesystems, which is the default on many Linux distributions. You must use a filesystem with a larger single-file limit, such as XFS (recommended) or ZFS.
|
||||
|
||||
Acquiring full history from the peer-to-peer network takes a long time (several months) and requires that your server has enough system and network resources to acquire older history while keeping up with new ledger progress. To get a faster start on acquiring ledger history, you may want to find another server operator who has a large amount of history already downloaded, who can give you a database dump or at least allow your server to explicitly peer with theirs for a long time to acquire history. The server can load ledger history from a file and verify the integrity of the historical ledgers it imports.
|
||||
|
||||
You do not need a full history server to participate in the network, validate transactions, or know the current state of the network. Full history is only useful for knowing the outcome of transactions that occurred in the past, or the state of the ledger at a given time in the past. To get such information, you must rely on other servers having the history you need.
|
||||
|
||||
If you want to contribute to storing the history of the XRP Ledger network without storing the full history, you can [configure history sharding](configure-history-sharding.html) to store randomly-selected chunks of ledger history instead.
|
||||
|
||||
## Configuration Steps
|
||||
|
||||
To configure your server to acquire and store full history, complete the following steps:
|
||||
|
||||
1. Stop the `rippled` server if it is running.
|
||||
|
||||
$ sudo systemctl stop rippled
|
||||
|
||||
0. Remove (or comment out) the `online_delete` and `advisory_delete` settings from the `[node_db]` stanza of your server's config file, and change the type to `NuDB` if you haven't already:
|
||||
|
||||
[node_db]
|
||||
type=NuDB
|
||||
path=/var/lib/rippled/db/nudb
|
||||
#online_delete=2000
|
||||
#advisory_delete=0
|
||||
|
||||
On a full-history server, you should use NuDB for the ledger store, because RocksDB requires too much RAM when the database is that large. For more information, see [Capacity Planning](capacity-planning.html). You can remove the following performance-related configuration options from the default `[node_db]` stanza, because they only apply to RocksDB: `open_files`, `filter_bits`, `cache_mb`, `file_size_mb`, and `file_size_mult.`
|
||||
|
||||
**Caution:** If you have any history already downloaded with RocksDB, you must either delete that data or change the paths to the databases in the config file when you switch to NuDB. You must change both the `path` field of the `[node_db]` stanza **and** the `[database_path]` (SQLite database) setting. Otherwise, the server may [fail to start](server-wont-start.html#state-db-error).
|
||||
|
||||
{% include '_snippets/conf-file-location.md' %}<!--_ -->
|
||||
|
||||
0. Set the `[ledger_history]` stanza of your server's config file to `full`:
|
||||
|
||||
[ledger_history]
|
||||
full
|
||||
|
||||
0. Set the `[ips_fixed]` stanza of your server's config file to explicitly peer with at least one server that has full history available.
|
||||
|
||||
[ips_fixed]
|
||||
169.55.164.20 51235
|
||||
50.22.123.215 51235
|
||||
|
||||
Your server can only download historical data from the peer-to-peer network if one its direct peers has the data available. The easiest way to ensure you can download full history is to peer with a server that already has full history.
|
||||
|
||||
**Tip:** Ripple makes a pool of full history servers publicly available. You can resolve the domain `s2.ripple.com` a few times to get the IP addresses of these servers. Ripple offers these servers as a public service, so be aware that their availability to peer with other servers is limited and you may be blocked if you abuse them.
|
||||
|
||||
0. If you have a database dump from another full-history server to use as a basis, set the `[import_db]` stanza of your server's config file to point to the data to be imported. (Otherwise, skip this step.)
|
||||
|
||||
[import_db]
|
||||
type=NuDB
|
||||
path=/tmp/full_history_dump/
|
||||
|
||||
0. Remove your server's existing database files, if you have any from previously running `rippled`.
|
||||
|
||||
After disabling online deletion, the server ignores any data that was downloaded while online deletion was enabled, so you may as well clear up the disk space. For example:
|
||||
|
||||
rm -r /var/lib/rippled/db/*
|
||||
|
||||
**Warning:** Be sure that you have not put any files you want to keep in the folder before you delete it. It is generally safe to delete all of a `rippled` server's database files, but you should only do this if the configured database folder is not used for anything other than `rippled`'s databases.
|
||||
|
||||
0. Start the `rippled` server, importing the database dump if you have one available:
|
||||
|
||||
If you have a database dump to load configured in `[import_db]`, start the server explicitly and include the `--import` [commandline option](commandline-usage.html#daemon-mode-options):
|
||||
|
||||
$ /opt/ripple/bin/rippled --conf /etc/opt/ripple/rippled.cfg --import
|
||||
|
||||
Importing a large database dump may take several minutes or even hours. During this time, the server is not fully started and synced with the network. Watch the server logs to see the status of the import.
|
||||
|
||||
If you are not importing a database dump, start the server normally:
|
||||
|
||||
$ sudo systemctl start rippled
|
||||
|
||||
0. If you added an `[import_db]` stanza to your server's config file, remove it after the import completes.
|
||||
|
||||
Otherwise, your server may try to import the same data again the next time it is restarted.
|
||||
|
||||
0. Monitor your server's available history with the [server_info method][].
|
||||
|
||||
The range of available ledgers reported in the `complete_ledgers` field should increase over time.
|
||||
|
||||
The earliest available ledger version in the production XRP Ledger's history is ledger index **32570**. The first two weeks or so of ledger history was lost due to a bug in the server at the time. [Test nets and other chains](parallel-networks.html) generally have history going back to ledger index **1**.
|
||||
|
||||
## See Also
|
||||
|
||||
- **Concepts:**
|
||||
- [Ledger History](ledger-history.html)
|
||||
- [rippled Server Modes](rippled-server-modes.html)
|
||||
- **Tutorials:**
|
||||
- [Capacity Planning](capacity-planning.html), particularly [Disk Space](capacity-planning.html#disk-space)
|
||||
- [Configure Online Deletion](configure-online-deletion.html)
|
||||
- [Diagnosing Problems with rippled](diagnosing-problems.html)
|
||||
- [Understanding Log Messages](understanding-log-messages.html)
|
||||
- **References:**
|
||||
- [server_info method][]
|
||||
- [can_delete method][]
|
||||
- [Ledger Data Formats](ledger-data-formats.html)
|
||||
- [rippled Commandline Usage Reference](commandline-usage.html)
|
||||
|
||||
<!--{# common link defs #}-->
|
||||
{% include '_snippets/rippled-api-links.md' %}
|
||||
{% include '_snippets/tx-type-links.md' %}
|
||||
{% include '_snippets/rippled_versions.md' %}
|
||||
@@ -0,0 +1,91 @@
|
||||
---
|
||||
html: configure-history-sharding.html
|
||||
parent: data-retention.html
|
||||
blurb: Set up a server to contribute to preserving shards of historical XRP Ledger data.
|
||||
labels:
|
||||
- Data Retention
|
||||
- Core Server
|
||||
---
|
||||
# Configure History Sharding
|
||||
|
||||
[History Sharding](history-sharding.html) lets servers contribute to preserving historical XRP Ledger data without each server needing to store the full history. By default, `rippled` servers do not store history shards.
|
||||
|
||||
**Tip:** While both validator and tracking (or stock) `rippled` servers can be configured to store history shards, Ripple recommends _not_ configuring validator `rippled` servers to store shards, to reduce overhead on those servers. If you run a validator and want to contribute to storing XRP Ledger history, Ripple recommends you run a separate `rippled` server with history sharding enabled.
|
||||
|
||||
To configure your `rippled` to store shards of ledger history, complete the following steps:
|
||||
|
||||
## 1. Determine how many shards to maintain
|
||||
|
||||
Before you configure your `rippled` server to store history shards, you must decide how many history shards you want to keep, which is mostly determined by how much disk space is available for the shard store. This also affects how much history you keep in the default ledger store. You should consider the following when deciding what size to configure your shard store:
|
||||
|
||||
- The ledger store (defined by the `[node_db]` stanza) is separate from the history shard store. The ledger store is required for all servers, and always contains a range of recent history, defined by how many ledgers to keep available in the `online_delete` parameter. (The default configuration stores the most recent 2000 ledgers.)
|
||||
- If you keep at least 2<sup>15</sup> ledgers (32768) in the ledger store, you can efficiently import chunks of recent history from the ledger store into the shard store.
|
||||
- The history shard store (defined by the `[shard_db]` stanza) is only required for storing history shards. The configuration stanza should be omitted from servers that do not store history shards. The total number of shards stored is defined by the `max_historical_shards` parameter; the server attempts to store no more than this many complete shards. The history shard store _MUST_ be stored on a solid-state disk or similar fast media. Traditional spinning hard disks are insufficient.
|
||||
- A shard consists of 2<sup>14</sup> ledgers (16384) and occupies approximately 200 MB to 4 GB based on the age of the shard. Older shards are smaller because there was less activity in the XRP Ledger at the time.
|
||||
- The history shard store and the ledger store _MUST_ be stored at different file paths. You can configure the ledger store and history store to be on different disks or partitions if desired.
|
||||
- It is possible but redundant to hold full ledger history in both the ledger store and the history shard store.
|
||||
- The time to acquire a shard, number of file handles needed by the `rippled` server, and memory cache usage is directly affected by the size of the shard.
|
||||
- You can specify additional paths to store older history shards by providing a `[historical_shard_paths]` stanza. These paths may be on different, slower disks because they hold data that is used less often. The most recent two shards (the ones with the largest ledger indexes) are always stored in the path specified in the `[shard_db]` stanza. [New in: rippled 1.7.0][]
|
||||
|
||||
## 2. Edit rippled.cfg
|
||||
|
||||
<!-- SPELLING_IGNORE: cfg -->
|
||||
|
||||
Edit your `rippled.cfg` file to add a `[shard_db]` stanza and optionally a `[historical_shard_paths]` stanza.
|
||||
|
||||
{% include '_snippets/conf-file-location.md' %}<!--_ -->
|
||||
|
||||
The following snippet shows an example of a `[shard_db]` stanza:
|
||||
|
||||
```
|
||||
[shard_db]
|
||||
path=/var/lib/rippled/db/shards/nudb
|
||||
max_historical_shards=12
|
||||
|
||||
# Optional paths for shards other than the newest 2
|
||||
[historical_shard_paths]
|
||||
/mnt/disk1
|
||||
/mnt/disk2
|
||||
```
|
||||
|
||||
The `type` field of `[shard_db]` can be omitted. If present, it _MUST_ be `NuDB`. [New in: rippled 1.3.1][]
|
||||
|
||||
**Caution:** If `rippled` detects the wrong type of data in the shard store path, it may [fail to start](server-wont-start.html). You should use a new folder for the shard store. If you previously used a RocksDB shard store (`rippled` 1.2.x and lower), use a different path or delete the RocksDB shard data.
|
||||
|
||||
For more information, reference the `[shard_db]` example in the [rippled.cfg configuration example](https://github.com/XRPLF/rippled/blob/master/cfg/rippled-example.cfg).
|
||||
|
||||
## 3. Restart the server
|
||||
|
||||
```
|
||||
systemctl restart rippled
|
||||
```
|
||||
|
||||
## 4. Wait for shards to download
|
||||
|
||||
After your server syncs to the network, it automatically starts downloading history shards to fill the available space in the shard store. You can see which shards are being downloaded by looking at which folders are created in the folder where you configured your shard store. (This is defined by the `path` field of the `[shard_db]` stanza in the `rippled.cfg` file.)
|
||||
|
||||
This folder should contain a numbered folder for each shard your server has. At any given time, up to one folder may contain a `control.txt` file, indicating it is incomplete.
|
||||
|
||||
You can instruct your server to download and import a shard from an archive file using the [download_shard method][].
|
||||
|
||||
To list the shards your server and its peers have available, you can use the [crawl_shards method][] or the [Peer Crawler](peer-crawler.html).
|
||||
|
||||
|
||||
## See Also
|
||||
|
||||
- **Concepts:**
|
||||
- [Ledger History](ledger-history.html)
|
||||
- [Online Deletion](online-deletion.html)
|
||||
- **Tutorials:**
|
||||
- [Configure Online Deletion](configure-online-deletion.html)
|
||||
- [Configure the Peer Crawler](configure-the-peer-crawler.html)
|
||||
- [Capacity Planning](capacity-planning.html)
|
||||
- **References:**
|
||||
- [download_shard method][]
|
||||
- [crawl_shards method][]
|
||||
- [Ledger Data Formats](ledger-data-formats.html)
|
||||
|
||||
<!--{# common link defs #}-->
|
||||
{% include '_snippets/rippled-api-links.md' %}
|
||||
{% include '_snippets/tx-type-links.md' %}
|
||||
{% include '_snippets/rippled_versions.md' %}
|
||||
@@ -0,0 +1,90 @@
|
||||
---
|
||||
html: configure-online-deletion.html
|
||||
parent: data-retention.html
|
||||
blurb: Configure how far back your server should store transaction history.
|
||||
labels:
|
||||
- Core Server
|
||||
- Data Retention
|
||||
---
|
||||
# Configure Online Deletion
|
||||
|
||||
In its default configuration, [the `rippled` server](xrpl-servers.html) [deletes history](online-deletion.html) older than the most recent 2000 [ledger versions](ledgers.html), keeping approximately 15 minutes of [ledger history](ledger-history.html) (based on the current rate between ledgers). This page describes how to configure the amount of history your `rippled` server stores before deleting.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This tutorial assumes your server meets the following prerequisites:
|
||||
|
||||
- You are on a supported operating system: Ubuntu Linux, Red Hat Enterprise Linux (RHEL), or CentOS.
|
||||
|
||||
- The `rippled` server is already [installed](install-rippled.html) and [online deletion](online-deletion.html) is enabled.
|
||||
|
||||
If you followed the installation instructions for a recommended platform, online deletion is enabled by default.
|
||||
|
||||
- Your server has [enough disk space](capacity-planning.html#disk-space) to store your chosen amount of history in its ledger store.
|
||||
|
||||
|
||||
## Configuration Steps
|
||||
|
||||
To change the amount of history your server stores, perform the following steps:
|
||||
|
||||
1. Decide how many ledger versions' worth of history to store.
|
||||
|
||||
New ledger versions are usually validated 3 to 4 seconds apart, so the number of ledger versions corresponds roughly to the amount of time you want to store. See [Capacity Planning](capacity-planning.html) for details of how much storage is required for different configurations.
|
||||
|
||||
Online deletion is based on how many ledger versions to keep _after_ deleting history, so you should have enough disk space to store twice as many ledgers as you set it to keep.
|
||||
|
||||
0. In your `rippled`'s config file, edit the `online_delete` field of the `[node_db]` stanza.
|
||||
|
||||
[node_db]
|
||||
# Other settings unchanged ...
|
||||
online_delete=2000
|
||||
advisory_delete=0
|
||||
|
||||
Set `online_delete` to the minimum number of ledger versions to keep after running online deletion. With automatic deletion (the default), the server typically runs deletion when it has accumulated about twice this many ledger versions.
|
||||
|
||||
{% include '_snippets/conf-file-location.md' %}<!--_ -->
|
||||
|
||||
0. Start (or restart) the `rippled` service.
|
||||
|
||||
$ sudo systemctl restart rippled
|
||||
|
||||
0. Wait for your server to sync to the network.
|
||||
|
||||
Depending on your network and system capabilities and how long your server was offline, it may take between 5 and 15 minutes to fully sync.
|
||||
|
||||
When your server is synced with the network, the [server_info method][] reports a `server_state` value of `"full"`, `"proposing"`, or `"validating"`.
|
||||
|
||||
0. Periodically check your server's `complete_ledgers` range using the [server_info method][] to confirm that ledgers are being deleted.
|
||||
|
||||
After online deletion runs, the `complete_ledgers` range reflects that older ledgers are no longer available. As your server accumulates history, the total number of ledgers available should slowly increase to twice the `online_delete` value you configured, then decrease when online deletion runs.
|
||||
|
||||
0. Monitor your `rippled` logs for messages that begin with `SHAMapStore::WRN`. This can indicate that [online deletion is being interrupted](online-deletion.html#interrupting-online-deletion) because your server fell out of sync with the network.
|
||||
|
||||
If this happens regularly, your server may not have sufficient specifications to keep up with the ledger while running online deletion. Check that other services on the same hardware (such as scheduled backups or security scans) aren't competing with the `rippled` server for resources. You may want to try any of the following:
|
||||
|
||||
- Increase your system specs. See [System Requirements](system-requirements.html) for recommendations.
|
||||
- Change your configuration to store less history. (Step 2 of this tutorial)
|
||||
- Change your server's [`node_size` parameter](capacity-planning.html).
|
||||
- Use [NuDB instead of RocksDB](capacity-planning.html) for the ledger store.
|
||||
- [Schedule online deletion using Advisory Deletion](configure-advisory-deletion.html).
|
||||
|
||||
|
||||
## See Also
|
||||
|
||||
- **Concepts:**
|
||||
- [Ledger History](ledger-history.html)
|
||||
- [Online Deletion](online-deletion.html)
|
||||
- **Tutorials:**
|
||||
- [Configure Advisory Deletion](configure-advisory-deletion.html)
|
||||
- [Configure History Sharding](configure-history-sharding.html)
|
||||
- [Capacity Planning](capacity-planning.html)
|
||||
- **References:**
|
||||
- [server_info method][]
|
||||
- [Ledger Data Formats](ledger-data-formats.html)
|
||||
|
||||
|
||||
|
||||
<!--{# common link defs #}-->
|
||||
{% include '_snippets/rippled-api-links.md' %}
|
||||
{% include '_snippets/tx-type-links.md' %}
|
||||
{% include '_snippets/rippled_versions.md' %}
|
||||
@@ -0,0 +1,54 @@
|
||||
---
|
||||
html: history-sharding.html
|
||||
parent: data-retention.html
|
||||
blurb: History sharding divides the work of keeping historical ledger data among rippled servers.
|
||||
labels:
|
||||
- Data Retention
|
||||
- Core Server
|
||||
---
|
||||
# History Sharding
|
||||
|
||||
[Introduced in: rippled 0.90.0][]
|
||||
|
||||
As XRP Ledger servers run, they naturally produce a database containing data about the ledgers they built or acquired during network runtime. Each server stores that ledger data in its _ledger store_, but [online deletion](online-deletion.html) removes old ledgers' data automatically over time. History sharding provides a separate storage system for older ledger history so that the network can divide up the work of recording the entire (multiple terabyte) history of the XRP Ledger.
|
||||
|
||||
Historical sharding distributes the transaction history of the XRP Ledger into segments, called shards, across servers in the XRP Ledger network. A shard is a range of ledgers. A server uses mostly the same format for ledgers in both the ledger store and the shard store, but the two stores are separate.
|
||||
|
||||
[](img/xrp-ledger-network-ledger-store-and-shard-store.png)
|
||||
|
||||
<!-- Diagram source: https://docs.google.com/presentation/d/1mg2jZQwgfLCIhOU8Mr5aOiYpIgbIgk3ymBoDb2hh7_s/edit#slide=id.g417450e8da_0_316 -->
|
||||
|
||||
## Acquiring and Sharing History Shards
|
||||
|
||||
Servers acquire and store history shards only if configured to do so. Acquiring shards begins after synchronizing with the network and backfilling ledger history to the configured number of recent ledgers. During this time of lower network activity, a server set to maintain a shard database randomly chooses a shard to add to its shard store. To increase the probability for an even distribution of the network ledger history, shards are randomly selected for acquisition, and the most recent shard is given no special consideration.
|
||||
|
||||
Once a shard is selected, the ledger acquire process begins by fetching the sequence of the last ledger in the shard and working backwards toward the first. The retrieval process begins with the server checking for the data locally. For data that is not available, the server requests data from its peers. Those servers that have the data available for the requested period respond with their history. The requesting server combines those responses to create the shard. The shard is complete when it contains all the ledgers in a specific range.
|
||||
|
||||
The server selects and downloads additional shards until it reaches the maximum number of shards it is configured to store. If a server runs out of space before completely acquiring a shard, it stops its retrieval process until it has space available to continue.
|
||||
|
||||
## XRP Ledger Network Data Integrity
|
||||
|
||||
The history of all ledgers is shared by servers agreeing to keep particular ranges of historical ledgers. This makes it possible for servers to confirm that they have all the data they agreed to maintain, and produce "proof trees" or "ledger deltas" which shows how each ledger in the blockchain's history was the result of applying transactions to the previous state. Since servers that are configured with history sharding randomly select the shards that they store, the entire history of all closed ledgers is stored in a normal distribution curve, increasing the probability that the XRP Ledger Network evenly maintains the history.
|
||||
|
||||
History shards are recorded in a deterministic format, so that any two servers assembling the same shard produce the exact same binary data no matter what order they acquired the data and where they got it from. This makes it possible to compare checksums or cryptographic hashes of the shard data to verify the integrity of the data, and it is possible to share and import history shards through other formats. (For example, you could download shard data using Bittorrent or acquire physical media with the shard data pre-loaded on it, and verify that it matches the data that can be downloaded from the network.) [New in: rippled 1.8.1][]
|
||||
|
||||
|
||||
## See Also
|
||||
|
||||
- **Concepts:**
|
||||
- [Ledgers](ledgers.html)
|
||||
- [Consensus](consensus.html)
|
||||
- **Tutorials:**
|
||||
- [Capacity Planning](capacity-planning.html)
|
||||
- [Configure `rippled`](configure-rippled.html)
|
||||
- [Configure History Sharding](configure-history-sharding.html)
|
||||
- **References:**
|
||||
- [crawl_shards method][]
|
||||
- [download_shard method][]
|
||||
- [Peer Crawler](peer-crawler.html)
|
||||
|
||||
|
||||
<!--{# common link defs #}-->
|
||||
{% include '_snippets/rippled-api-links.md' %}
|
||||
{% include '_snippets/tx-type-links.md' %}
|
||||
{% include '_snippets/rippled_versions.md' %}
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
html: data-retention.html
|
||||
parent: configure-rippled.html
|
||||
template: pagetype-category.html.jinja
|
||||
blurb: Control how much data your server should keep and when it should remove old data.
|
||||
---
|
||||
# Data Retention
|
||||
|
||||
Control how much data your server should keep and when it should remove old data, including old versions of the ledger state and past transactions.
|
||||
@@ -0,0 +1,141 @@
|
||||
---
|
||||
html: online-deletion.html
|
||||
parent: data-retention.html
|
||||
blurb: Online deletion purges outdated transaction and state history.
|
||||
labels:
|
||||
- Data Retention
|
||||
- Core Server
|
||||
---
|
||||
# Online Deletion
|
||||
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/misc/SHAMapStoreImp.cpp "Source")
|
||||
|
||||
The online deletion feature lets the `rippled` server delete the server's local copy of old ledger versions to keep disk usage from rapidly growing over time. The default config file sets online deletion to run automatically, but online deletion can also be configured to run only when prompted. [New in: rippled 0.27.0][]
|
||||
|
||||
The server always keeps the complete _current_ state of the ledger, with all the balances and settings it contains. The deleted data includes older transactions and versions of the ledger state that are older than the stored history.
|
||||
|
||||
The default config file sets the `rippled` server to keep the most recent 2000 ledger versions and automatically delete older data.
|
||||
|
||||
**Tip:** Even with online deletion, the amount of disk space required to store the same time span's worth of ledger data increases over time, because the size of individual ledger versions tends to grow over time. This growth is very slow in comparison to the accumulation of data that occurs without deleting old ledgers. For more information on disk space needs, see [Capacity Planning](capacity-planning.html).
|
||||
|
||||
|
||||
## Background
|
||||
|
||||
The `rippled` server stores [ledger history](ledger-history.html) in its _ledger store_. This data accumulates over time.
|
||||
|
||||
Inside the ledger store, ledger data is "de-duplicated". In other words, data that doesn't change from version to version is only stored once. The records themselves in the ledger store do not indicate which ledger version(s) contain them; part of the work of online deletion is identifying which records are only used by outdated ledger versions. This process is time consuming and affects the disk I/O and application cache, so the server cannot delete old data every time it closes a new ledger.
|
||||
|
||||
|
||||
## Online Deletion Behavior
|
||||
|
||||
The online deletion settings configure how many ledger versions the `rippled` server should keep available in the ledger store at a time. However, the specified number is a guideline, not a hard rule:
|
||||
|
||||
- The server never deletes data more recent than the configured number of ledger versions, but it may have less than that amount available if it has not been running for long enough or if it lost sync with the network at any time. (The server attempts to backfill at least some history; see [fetching history](ledger-history.html#fetching-history) for details.)
|
||||
- The server may store up to slightly over twice the configured number of ledger versions if online deletion is set to run automatically. (Each time it runs, it reduces the number of stored ledger versions to approximately the configured number.)
|
||||
|
||||
If online deletion is delayed because the server is busy, ledger versions can continue to accumulate. When functioning normally, online deletion begins when the server has twice the configured number of ledger versions, but it may not complete until after several more ledger versions have accumulated.
|
||||
|
||||
- If advisory deletion is enabled, the server stores all the ledger versions that it has acquired and built until its administrator calls the [can_delete method][].
|
||||
|
||||
The amount of data the server stores depends on how often you call [can_delete][can_delete method] and how big an interval of time your `online_delete` setting represents:
|
||||
|
||||
- If you call `can_delete` _more often_ than your `online_delete` interval, the server stores **up to twice the `online_delete` number** of ledger versions. (After deletion, this is reduced to approximately the `online_delete` value.)
|
||||
|
||||
For example, if you call `can_delete` with a value of `now` once per day and an `online_delete` value of 50,000, the server typically stores up to 100,000 ledger versions before running deletion. After running deletion, the server keeps at least 50,000 ledger versions (about two days' worth). With this configuration, approximately every other `can_delete` call results in no change because the server does not have enough ledger versions to delete.
|
||||
|
||||
- If you call `can_delete` _less often_ than your `online_delete` interval, the server stores at most ledger versions spanning an amount of time that is approximately **twice the interval between `can_delete` calls**. (After deletion, this is reduced to approximately one interval's worth of data.)
|
||||
|
||||
For example, if you call `can_delete` with a value of `now` once per day and an `online_delete` value of 2000, the server typically stores up to two full days' worth of ledger versions before running deletion. After running deletion, the server keeps approximately one day's worth (about 25,000 ledger versions), but never fewer than 2000 ledger versions.
|
||||
|
||||
|
||||
With online deletion enabled and running automatically (that is, with advisory delete disabled), the total amount of ledger data stored should remain at minimum equal to the number of ledger versions the server is configured to keep, with the maximum being roughly twice that many.
|
||||
|
||||
When online deletion runs, it does not reduce the size of SQLite database files on disk; it only makes space within those files available to be reused for new data. Online deletion _does_ reduce the size of RocksDB or NuDB database files containing the ledger store.
|
||||
|
||||
The server only counts validated ledger versions when deciding how far back it can delete. In exceptional circumstances where the server is unable to validate new ledger versions (either because of an outage in its local network connection or because the global XRP Ledger network is unable to reach a consensus) `rippled` continues to close ledgers so that it can recover quickly when the network is restored. In this case, the server may accumulate many closed but not validated ledger versions. These unvalidated ledgers do not affect how many _validated_ ledger versions the server keeps before running online deletion.
|
||||
|
||||
### Interrupting Online Deletion
|
||||
|
||||
Online deletion automatically stops if the [server state](rippled-server-states.html) becomes less than `full`. If this happens, the server writes a log message with the prefix `SHAMapStore::WRN`. The server attempts to start online deletion again after the next validated ledger version after becoming fully synced.
|
||||
|
||||
If you stop the server or it crashes while online deletion is running, online deletion resumes after the server is restarted and the server becomes fully synced.
|
||||
|
||||
To temporarily disable online deletion, you can use the [can_delete method][] with an argument of `never`. This change persists until you re-enable online deletion by calling [can_delete][can_delete method] again. For more information on controlling when online deletion happens, see [Advisory Deletion](#advisory-deletion).
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
The following settings relate to online deletion:
|
||||
|
||||
- **`online_delete`** - Specify how many validated ledger versions to keep. The server periodically deletes any ledger versions that are older than this number. If not specified, no ledgers are deleted.
|
||||
|
||||
The default config file specifies 2000 for this value. This cannot be less than 256, because some events like [Fee Voting](fee-voting.html) and the [Amendment Process](amendments.html#amendment-process) update only every 256 ledgers.
|
||||
|
||||
**Caution:** If you run `rippled` with `online_delete` disabled, then later enable `online_delete` and restart the server, the server disregards but does not delete existing ledger history that your server already downloaded while `online_delete` was disabled. To save disk space, delete your existing history before re-starting the server after changing the `online_delete` setting.
|
||||
|
||||
- **`[ledger_history]`** - Specify how many validated ledgers to backfill. Must be equal to or less than `online_delete`. If the server does not have at least this many validated ledger versions, it attempts to fetch the data from peers when it can.
|
||||
|
||||
The default for this setting is 256 ledgers.
|
||||
|
||||
The following diagram shows the relationship between `online_delete` and `ledger_history` settings:
|
||||
|
||||
{{ include_svg("img/online_delete-vs-ledger_history.svg", "Ledgers older than `online_delete` are automatically deleted. Ledgers newer than `ledger_history` are backfilled. Ledgers in between are kept if available but not backfilled") }}
|
||||
|
||||
- **`advisory_delete`** - If enabled, online deletion is not scheduled automatically. Instead, an administrator must manually trigger online deletion. Use the value `0` for disabled or `1` for enabled.
|
||||
|
||||
This setting is disabled by default.
|
||||
|
||||
- **`[fetch_depth]`** - Specify how many ledger versions to serve to peers. The server does not accept fetch requests from peers for historical data that is older than the specified number of ledger versions. Specify the value `full` to serve any available data to peers.
|
||||
|
||||
The default for `fetch_depth` is `full` (serve all available data).
|
||||
|
||||
The `fetch_depth` setting cannot be higher than `online_delete` if both are specified. If `fetch_depth` is set higher, the server treats it as equal to `online_delete` instead.
|
||||
|
||||
The following diagram shows how `fetch_depth` works:
|
||||
|
||||
{{ include_svg("img/fetch_depth.svg", "Ledger versions older than fetch_depth are not served to peers") }}
|
||||
|
||||
For estimates of how much disk space is required to store different amounts of history, see [Capacity Planning](capacity-planning.html#disk-space).
|
||||
|
||||
### Advisory Deletion
|
||||
|
||||
The default config file schedules online deletion to happen automatically and periodically. If the config file does not specify an `online_delete` interval, online deletion does not occur. If config file enables the `advisory_delete` setting, online deletion only happens when an administrator triggers it using the [can_delete method][].
|
||||
|
||||
You can use advisory deletion with a scheduled job to trigger automatic deletion based on clock time instead of the number of ledger versions closed. If your server is heavily used, the extra load from online deletion can cause your server to fall behind and temporarily de-sync from the consensus network. If this is the case, you can use advisory deletion and schedule online deletion to happen only during off-peak times.
|
||||
|
||||
You can use advisory deletion for other reasons. For example, you may want to manually confirm that transaction data is backed up to a separate server before deleting it. Alternatively, you may want to manually confirm that a separate task has finished processing transaction data before you delete that data.
|
||||
|
||||
The `can_delete` API method can enable or disable automatic deletion, in general or up to a specific ledger version, as long as `advisory_delete` is enabled in the config file. These settings changes persist even if you restart the `rippled` server, unless you disable `advisory_delete` in the config file before restarting.
|
||||
|
||||
|
||||
## How It Works
|
||||
|
||||
Online deletion works by creating two databases: at any given time, there is an "old" database, which is read-only, and a "current" database, which is writable. The `rippled` server can read objects from either database, so current ledger versions may contain objects in either one. If an object in a ledger does not change from ledger version to ledger version, only one copy of that object remains in the database, so the server does not store redundant copies of that object. When a new ledger version modifies an object, the server stores the modified object in the "new" database, while the previous version of the object (which is still used by previous ledger versions) remains in the "old" database.
|
||||
|
||||
When it comes time for online deletion, the server first walks through the oldest ledger version to keep, and copies all objects in that ledger version from the read-only "old" database into the "current" database. This guarantees that the "current" database now contains all objects used in the chosen ledger version and all newer versions. Then, the server deletes the "old" database, and changes the existing "current" database to become "old" and read-only. The server starts a new "current" database to contain any newer changes after this point.
|
||||
|
||||
{{ include_svg('img/online-deletion-process.svg', "Diagram showing how online deletion uses two databases") }}
|
||||
|
||||
## See Also
|
||||
|
||||
- **Concepts:**
|
||||
- [Ledgers](ledgers.html)
|
||||
- [Consensus](consensus.html)
|
||||
- **Tutorials:**
|
||||
- [Capacity Planning](capacity-planning.html)
|
||||
- [Configure `rippled`](configure-rippled.html)
|
||||
- [Configure Online Deletion](configure-online-deletion.html)
|
||||
- [Configure Advisory Deletion](configure-advisory-deletion.html)
|
||||
- [Configure History Sharding](configure-history-sharding.html)
|
||||
- [Configure Full History](configure-full-history.html)
|
||||
- **References:**
|
||||
- [ledger method][]
|
||||
- [server_info method][]
|
||||
- [ledger_request method][]
|
||||
- [can_delete method][]
|
||||
- [ledger_cleaner method][]
|
||||
|
||||
|
||||
<!--{# common link defs #}-->
|
||||
{% include '_snippets/rippled-api-links.md' %}
|
||||
{% include '_snippets/tx-type-links.md' %}
|
||||
{% include '_snippets/rippled_versions.md' %}
|
||||
Reference in New Issue
Block a user