📄 archival.so
字号:
m4_comment([$Id: archival.so,v 10.56 2005/02/10 20:02:41 bostic Exp $])m4_ref_title(m4_tam Applications, Database and log file archival, [archival in @transaction protected applications, catastrophic recovery], transapp/checkpoint, transapp/logfile)m4_p([dnlThe third component of the administrative infrastructure, archival forcatastrophic recovery, concerns the recoverability of the database inthe face of catastrophic failure. Recovery after catastrophic failureis intended to minimize data loss when physical hardware has beendestroyed -- for example, loss of a disk that contains databases or logfiles. Although the application may still experience data loss in thiscase, it is possible to minimize it.])m4_p([dnlFirst, you may want to periodically create snapshots (that is, backups)of your databases to make it possible to recover from catastrophicfailure. These snapshots are either a standard backup, which creates aconsistent picture of the databases as of a single instant in time; oran on-line backup (also known as a m4_italic(hot) backup), which createsa consistent picture of the databases as of an unspecified instantduring the period of time when the snapshot was made. The advantage ofa hot backup is that applications may continue to read and write thedatabases while the snapshot is being taken. The disadvantage of a hotbackup is that more information must be archived, and recovery based ona hot backup is to an unspecified time between the start of the backupand when the backup is completed.])m4_p([dnlSecond, after taking a snapshot, you should periodically archive thelog files being created in the environment. It is often helpful tothink of database archival in terms of full and incremental filesystembackups. A snapshot is a full backup, whereas the periodic archival ofthe current log files is an incremental backup. For example, it mightbe reasonable to take a full snapshot of a database environment weeklyor monthly, and archive additional log files daily. Using both thesnapshot and the log files, a catastrophic crash at any time can berecovered to the time of the most recent log archival; a time long afterthe original snapshot.])m4_p([dnlTo create a standard backup of your database that can be used to recoverfrom catastrophic failure, take the following steps:])m4_nlistbeginm4_nlist([Commit or abort all ongoing transactions.])m4_nlist([dnlStop writing your databases until the backup has completed. Read-onlyoperations are permitted, but no write operations and no filesystemoperations may be performed (for example, the m4_ref(dbenv_remove) andm4_refT(dbh_open)s may not be called).])m4_nlist([dnlForce an environment checkpoint (see m4_ref(db_checkpoint) for moreinformation).])m4_nlist([dnlRun m4_ref(db_archive) m4_option(s) to identify all the database datafiles, and copy them to a backup device such as CD-ROM, alternate disk,or tape.])m4_p([dnlIf the database files are stored in a separate directory from the otherm4_db files, it may be simpler to archive the directory itself insteadof the individual files (see m4_ref(dbenv_set_data_dir) for additionalinformation). m4_bold([Note: if any of the database files did not havean open m4_ref(Db) handle during the lifetime of the current log files,m4_ref(db_archive) will not list them in its output!]) This is anotherreason it may be simpler to use a separate database file directory andarchive the entire directory instead of archiving only the files listedby m4_ref(db_archive).])m4_nlist([dnlRun m4_ref(db_archive) m4_option(l) to identify all the log files,and copy the last one (that is, the one with the highest number) to abackup device such as CD-ROM, alternate disk, or tape.])m4_nlistendm4_idefz(hot @backup)m4_p([dnlTo create a m4_italic(hot) backup of your database that can be used torecover from catastrophic failure, take the following steps:])m4_nlistbeginm4_nlist([Archive your databases, as described in the previous step [#4].You do not have to halt ongoing transactions or force a checkpoint. Asthis is a hot backup, and the databases may be modified during the copy,the utility you use to copy the databases must read database pagesatomically (as described by m4_link(M4RELDIR/ref/transapp/reclimit,[m4_db recoverability])).])m4_nlist([dnlArchive m4_bold(all) of the log files. The order of these two operationsis required, and the database files must be archived m4_bold(before) thelog files. This means that if the database files and log files are inthe same directory, you cannot simply archive the directory; you mustmake sure that the correct order of archival is maintained.m4_p([dnlTo archive your log files, run the m4_ref(db_archive) utility usingthe m4_option(l) option to identify all the database log files, andcopy them to your backup media. If the database log files are storedin a separate directory from the other database files, it may be simplerto archive the directory itself instead of the individual files (seethe m4_refT(dbenv_set_lg_dir) for more information).])])m4_nlistendm4_p([dnlTo minimize the archival space needed for log files when doing a hotbackup, run db_archive to identify those log files which are not in use.Log files which are not in use do not need to be included when creatinga hot backup, and you can discard them or move them aside for use withprevious backups (whichever is appropriate), before beginning the hotbackup.])m4_p([dnlAfter completing one of these two sets of steps, the databaseenvironment can be recovered from catastrophic failure (seem4_link(recovery, Recovery procedures) for more information).])m4_p([dnlFor an example of a hot backup implementation in the m4_db distribution,see the source code for the m4_ref(db_hotbackup) utility.])m4_p([dnlTo update either a hot or cold backup so that recovery from catastrophicfailure is possible to a new point in time, repeat step [#2] under thehot backup instructions and archive m4_bold(all) of the log files in thedatabase environment. Each time both the database and log files arecopied to backup media, you may discard all previous database snapshotsand saved log files. Archiving additional log files does not allow youto discard either previous database snapshots or log files. Generally,updating a backup must be integrated with the application's log fileremoval procedures.])m4_p([dnlThe time to restore from catastrophic failure is a function of thenumber of log records that have been written since the snapshot wasoriginally created. Perhaps more importantly, the more separate piecesof backup media you use, the more likely it is that you will have aproblem reading from one of them. For these reasons, it is often bestto make snapshots on a regular basis.])m4_p([m4_bold([dnlObviously, the reliability of your archive media will affect the safetyof your data. For archival safety, ensure that you have multiple copiesof your database backups, verify that your archival media is error-freeand readable, and that copies of your backups are stored offsite!])])m4_p([dnlThe functionality provided by the m4_ref(db_archive) utility is alsoavailable directly from the m4_db library. The following code fragmentprints out a list of log and database files that need to be archived:])include(ref/transapp/archival.cs)m4_page_footer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -