![]() | ![]() | contents |
Because VoltDB is an in-memory database, once the database server process stops, the data itself is removed from memory. If you restart the database without taking any other action, the database starts fresh without any data. However, in many cases you want to retain the data across sessions. There are two ways to do this:
Save and restore database snapshots
Use command logging and recovery to reload the database automatically (Enterprise Edition feature)
A database snapshot is exactly what it sounds like — a point-in-time copy the database contents written to disk. You can later use the snapshot to restore the data.
To save and restore data across sessions, you can perform a snapshot before shutting down the database and then restore the snapshot after the database restarts. You can perform a manual snapshot using the voltadmin command or using the @SnapshotSave system procedure. For example, the following commands pause the database, perform a manual snapshot, then do a shutdown on the current system:
$ voltadmin pause $ voltadmin save 'voltdbroot/snapshots' 'MySnapshot' $ voltdbadmin shutdown
You can also have the database automatically create periodic snapshots using the snapshot feature in the deployment file. See Chapter 9, Saving & Restoring a VoltDB Database for more information about using snapshots to save and restore the database.
Another option for saving data across sessions is to use command logging and recovery. Command logging is a feature of the VoltDB Enterprise Edition and requires a commercial license.
When you enable command logging, the database not only performs periodic snapshots, it also keeps a log of all stored procedures that are initiated at each partition. If the database stops for any reason — either intentionally or due to system failure — when the server process restarts, the database restores the last snapshot and then "replays" the command log to recover all of the data committed prior to the cluster shutting down.
To support command logging, an alternative startup action is available on the command line when starting the server process. The valid startup actions are:
create — explicitly creates a new, empty database and ignores any command log information, if it exists.
recover — starts a new database process and recovers the command log from
the last database session. The recover action is explicit; if the command log content is not found
or is incomplete, the server initialization process stops and reports an error.
Even if you are using the VoltDB community edition, rather than the Enterprise Edition, you can use the
create and recover actions. The community edition does not support creating or
replaying command logs; however, for start and recover, it will attempt to restore
the last snapshot found in the snapshot paths. Therefore, using automated snapshots and the recover
action, it is possible with the community edition to automatically recover all of the data from the previous database
session up until the last snapshot.
The following example illustrates how to recover a database from a previous session.
$ voltdb recover \
host voltsvr1 \
catalog mycatalog.jar \
deployment deployment.xml \
license /opt/voltdb/voltdb/license.xmlThe advantages of command logging are that:
The command log ensures that all data is recovered, including transactions between snapshots.
The recovery is automated, ensuring no client activity occurs until the recovery is complete.
See Chapter 10, Command Logging and Recovery for more information about enabling and configuring command logging.
The Tao of VoltDB
The 5 Principles of VoltDB
VoltDB Technosphere
Products and Solutions
Technical Support
Key Features
Download VoltDB
No Limits
VoltDB Application Gallery
Infinite Possibilities
VoltBuilder Program
