Migrate the database
Teku version 21.5.0 and later use LevelDB2 as the default database for new installations. Earlier Teku versions use RocksDB. Teku continues to support RocksDB in all versions.
LevelDB2 databases use less memory and proves to be more stable with Teku.
We recommend Teku nodes running in archive mode use the automatic migration method, and Teku nodes running in prune mode use the manual migration.
Automatic migration
Teku nodes running in [archive mode] must resynchronize from genesis to migrate from RocksDB to LevelDB2.
Use the migrate-database subcommand to migrate the database.
Once migration completes there will be two databases in Teku's data folder.
Manually verify that Teku starts and has the expected data before you remove the RocksDB database.
You need double the disk space of the existing Teku storage folder for the migration process. Once you are satisfied with the migration then you can delete the RocksDB to free up space.
Ensure that Teku isn't running when using the migrate-database subcommand.
The duration of the migration depends on various factors, but principally on the disk speed.
Status updates display during the migration process.
To migrate the database:
-
Shut down the local Teku instance.
-
Run
migrate-databaseto create a LevelDB2 database. Pass your configuration file or CLI options so that Teku has the correct paths and context.Exampleteku migrate-database --data-path /etc/teku/data/At a minimum, provide the
--networkand--data-pathoptions.noteIf not supplied
--networkdefaults tomainnet. -
The migration process informs you if it succeeded, or provides context to errors. If successful, then confirm Teku functions correctly.
Exampleteku --data-path /etc/teku/data/ -
If Teku is running correctly, remove the
beacon.olddirectory from the--data-pathdirectory.
If migration fails, resolve any issues and retry. Contact support on the Teku Discord channel if you need help resolving issues.
Manual migration
Users can manually migrate Teku nodes running a RocksDB database to a LevelDB2 database if the Teku node runs in prune mode.
Teku nodes running in [archive mode] must resynchronize from genesis to migrate. Use the automatic migration to migrate Teku nodes running in [archive mode].
To migrate a RocksDB database in prune mode to a LevelDB2 database:
-
Download the latest finalized state from a beacon node:
curl -o state.ssz -H 'Accept: application/octet-stream' http://other-node:5051/eth/v2/debug/beacon/states/finalizednoteThis step is optional, you can also supply the finalized checkpoint state via URL from a beacon chain node or Infura when restarting Teku in the step below.
-
Stop the Teku node you intend to migrate.
-
Delete the
beacondirectory in your data path.warningEnsure not to delete the
validatordirectory if one is present as this contains your slashing protection data. -
Restart Teku and specify the downloaded finalized state using the
--initial-statecommand.
Teku creates a LevelDB2 database, and starts from the specified recent state. Teku should be in sync and validating within minutes.