Illustra databases require two kinds of regular maintenance. First, each database must be vacuumed to purge deleted rows from the database and update statistics to help the optimizer speed access to your data. Second, each database must be dumped regularly to ensure against file system failure.
It is also possible to enable transaction level recovery using the Illustra transaction log. This will allow you to recover a database up to the latest commited transaction if a disk fails. See the Illustra System Administrator's Guide for detailed information on enabling transaction level logging.
Illustra implements an advanced no-overwrite storage mechanism by writing new records on update instead of updating the row in place. In addition, it marks records as invalid instead of physically reclaiming their storage space when deleting them. These methods provide important features:
However, the copies of deleted and updated rows in the database continue to use disk space. Database vacuuming is the process by which Illustra purges these deleted rows. In addition, while purging deleted rows, Illustra updates various statistics about the tables in the database to help the query optimizer determine the fastest path to access data.
To vacuum a database, connect to the database using the nsql
command and execute the vacuum
SQL statement. The nsql command is a command-line program used to send SQL statements directly to the database. The vacuum
statement is described in detail in Chapter 3 of the Illustra System Administrator's Guide.
nsdb
database. To start nsql:
\> nsql -U miadmin nsdb
vacuum
SQL command as described in Chapter 3 of the Illustra System Administrator's Guide. Normally you want to vacuum the entire database and update statistics using the syntax:
vacuum all with(statistics);
The Illustra database stores tables in individual files in the file system. However, because Illustra caches important data and implements a complex transaction control system above the file system, it is unsafe to simply back up the database files with ordinary file system backup tools. Instead, you must use the Illustra dump
SQL statement to copy a consistent snapshot of the database to ordinary file system files, which can then be backed up by your file system backup procedures.
You can also use the Illustra SQL dump statement to back up directly to a tape drive configured for use by Illustra. See the Ilustra System Administrator's Guide for details. The instructions provided below only describe dumping a database to an ordinary file that can be backed up by your normal file system backup tools.
To dump an Illustra database, connect to the database using the nsql command and execute the dump
SQL statement. The nsql command is a command-line program used to send SQL statements directly to the database. The dump
statement uses the following syntax:
dump
leveldevice
'
file_path_spec'
The level is an integer from 0 to 3, similar to the dump levels of the Unix dump
utility:
The device is the name of a device configured to be used by Illustra for backups. The simplest case, used in the instructions below, is the device named disk, so the database is backed up to an ordinary disk file. Other possibilities include tape_8mm and tape_qic150; see the Illustra Systems Administrator's Guide for more information on available devices.
The frequency of dumps depends on the requirements of the particular installation. A site with few changes to the database may implement a simple once-a-week level 0 dump strategy. A site with many daily updates to the database may instead need a nightly backup that uses the dump levels to avoid copying previously backed up data.
nsql
command from within a terminal window on Unix. To dump the database, you must connect as the Illustra miadmin user using the -U flag before the database name, for example:
\> nsql -U miadmin <database>
dump
SQL command as described in Chapter 3 of the Illustra System Administrator's Guide.
dump 0 disk `/backupdisk/illustradumps/mydb.0';
Be sure to dump your database to a different physical disk or to immediately back up the file, using your ordinary file system backup utility, to another backup medium.
\> nsql -U miadmin <database>
dump
SQL command as described in Chapter 3 of the Illustra System Administrator's Guide. To incrementally perform a level 1 dump to copy updated data in the database since the last level 0 dump, use the following syntax:
dump 1 disk `/backupdisk/illustradumps/mydb.1';
Be sure to dump your database to a different physical disk or to immediately back up the file, using your ordinary file system backup utility, to another backup medium.
To recover the database after a file system failure, you must first reinstall Illustra, and then recover the individual database in use by your site from database dump files restored from your file system backup software.
To recover an Illustra database from a database dump file, use the Illustra SQL restore
command. It uses the following syntax:
restore database_name {level | level to level} device
file_path_spec
You can restore multiple levels of a dump in a single restore. To restore multiple levels, specify the start level and the end level. The different levels can reside on different devices and in different directories. Specify the device and path name from the lowest level of the dump (level 0) in the restore statement. You will be prompted for the devices and path names of subsequent levels during the restore process.
If a database having the specified database name already exists on the server when restoring a level 0 dump, the restore process destroys the old database, creates a new one, and loads the data into it. If no database with the specified database name exists on the server, the restore process creates a new database.
Possible devices are the same as those for the dump procedure described above. The example below assumes you perform regular dumps to disk files and restore the disk dump files using your ordinary file system backup software. Because you cannot connect to the database that you intend to restore, you must connect to the special template1 database to execute the SQL restore
command.
\> nsql -U miadmin template1
restore
SQL command as described in Chapter 3 of the Illustra System Administrator's Guide. Use a single restore
command to restore from a level 0 and any incremental levels you have. For example, to restore the mydb database base using level 0, 1, and 2 disk file dumps, use the following syntax:
restore mydb 0 to 2 disk
`/backupdisk/illustradumps/mydb.0';
You will be prompted for the location of the level 1 and 2 dump files. In addition, if the mydb database already exists, it will be removed before it is restored from the dump files.