Oracle 19c hot backup mode? (二)
Oracle 19c hot backup mode? (一)
Hot Backups
To take hot backups, the database must be in ARCHIVELOG mode. If you are using RMAN, the tablespace does not need to be put into backup mode.
Unlike user-managed tools, RMAN does not require extra logging or backup mode because it knows the format of data blocks. RMAN is guaranteed not to back up fractured blocks. During an RMAN backup, a database server session reads each data block and checks whether it is fractured by comparing the block header and footer. If a block is fractured, then the session rereads the block. If the same fracture is found, then the block is considered permanently corrupt. Also, RMAN does not need to freeze the data file header checkpoint because it knows the order in which the blocks are read, which enables it to capture a known good checkpoint for the file.
Mechanisms of hot backup:
1. datafile checkpoint structure is frozen
2. backup is transparent to usrs.
3. Block splits during hot backups:
4. data block is written by DBW0 while it is read by the O/S copy utility.
5. Can cause fractured or split blocks.
6. Redo for whole blocks is logged to the redo stream.
7. More redo is generated during hot backups.
8. Tablespace should be taken out of backup mode as soon as the file copy is completed.
Fractured blocks may occur when there is an update to a database block while the block is being backed up at the OS level. Because Oracle blocks normally consist of more than one OS block, it is possible that part of the block is backed up, the block is changed, and then the rest of the block is backed up. The two halves of the block are not consistent with each other.
To prevent this, Oracle copies the entire block to the redo logs. During recovery, the block is copied from the redo log and any further changes logged in the redo are applied to the recovered block.
if the database crashes during a hot backup , file in hot backup mode will require media recovery on startup:
take datafiles out of hot backup mode.V$BACKUP shows data files that are in hot backup mode.
if any redo logs are missing, recovery is impossible.
to take a tablespace out of backup on startup, mount the database and issue the following commond:
alter database datafile ‘xxxx’ end backup;
This updates the data file header and control file..
Alternatively, you can issue the RECOVER DATABASE command but this will involve checking all the redo logs for missing transactions since the hot backup started.
When taking hot backups, securing all the redo necessary to restore the datafiles to a consistent point in time is critical. To do this, follow these steps:
1. Alter system switch logfile. Make note of the current log.
2. Put tablespaces in backup mode one by one and copy at OS level.
3. After all files have been backed up, make a backup copy of the control file.
4. Issue an ARCHIVE LOG CURRENT so that all changes in the online logs are archived. Make note of the last log to be archived.
The backup set now consists of all datafiles, the control file backup, and all the archive logs from the current log in step 1 to the last archived log in step 4. These are all archive logs that could possibly contain information needed to recover the backup set.
Restore From a Hot Backup
When taking hot backups, the file header is frozen while the file is being copied. This means that each data file can have a different checkpoint in your backup set. To make the backup set consistent, all files need to be recovered until their SCNs match again and the fuzzy bits have been reset.
Backup scn, time: Updated when executing BEGIN BACKUP on the tablespace. RMAN does not update this field.
(The next few lines in the dump are incorrectly indented, erroneously suggesting they belong to the backup SCN.)
select fhfno,fhscn,fhbcp_scn from x$kcvfh;
Checkpoint Structure
Records the last checkpoint information
Frozen when file is in hot backup mode
Backup checkpoint SCN
Updated during hot backups
Used in conjunction with the alter database end backup command
Creation SCN is when the file was created. No redo exists prior to this SCN for this file. Backup taken at SCN is updated at BEGIN BACKUP and indicates when a hot backup started.
Resetlogs Data lists the timestamp of the most recent resetlogs and the SCN of the file after resetlogs. This information is compared with controlfile ( database entry ) information when the file is brought online.
Status Definition ( from kcv3.h )
#define KCVFHHBP 0x01 /* hotbackup-in-progress on file (fuzzy file) */
#define KCVFHOFZ 0x04 /* Online FuZzy because it was online and db open */
#define KCVFHMFZ 0x10 /* Media recovery FuZzy – file in media recovery */
#define KCVFHAFZ 0x40 /* Absolutely FuZzy – fuzzyness from file scan */
A hot or online backup is taken when the database is open. ARCHIVELOG mode is a prerequisite. For manual hot backups, the involved tablespaces must be placed in backup mode. With RMAN online backups, a different mechanism ensures block consistency. Thus you do not place tablespaces into any special mode for backup. There are usually two steps to a perform a media recovery: The optional first step is restore, which is a simple copying of files from the backup system to the database locations.
(RMAN may need to assemble the file from several incremental RMAN backups.) The second step is the recover step, when the server applies the archive and online redo logs. Normally when people refer to recovery, they are referring to the restore phase.
Hot backup in progress ( Bit 0X01 ) : Applies only to hot backups made using utilities outside the kernel. This flag indicates that the file is in fuzzy state from its checkpoint until its end hot backup marker. It is set at begin hot backup. Recovery clears this flag when it crosses the end of hot backup marker.
Online fuzzy ( Bit 0X04 ) : Indicates that the file is in fuzzy state from its checkpoint until the crash recovery marker. It is set when the data files is first open or online or made read-write. It is cleared when the datafile is close , offline ( normal ) or made read-only.
The database cannot be shut down cleanly if a tablespace is in hot backup mode:
ORA-01149: cannot shutdown – file 1 has online backup set
ORA-01110: data file 1 : ‘/u02/oracle/or8i/system01.dbf’
open
SQL> startup ORACLE instance started. Total System Global Area 1073738888 bytes Fixed Size 9143432 bytes Variable Size 792723456 bytes Database Buffers 268435456 bytes Redo Buffers 3436544 bytes Database mounted. ORA-10873: file 1 needs to be either taken out of backup mode or media recovered ORA-01110: data file 1: '/u01/app/oracle/oradata/ANBOB19C/system01.dbf'
Solution:
SQL> alter database end backup; Database altered. SQL> alter database open; Database altered.
kcvfhsta
#define KCVFH_FUZZY (KCVFHHBP|KCVFHOFZ|KCVFHMFZ|KCVFHAFZ|KCVFHPCP|KCVFHSBY)
#define KCVFH_OOFUZZY (KCVFHHBP|KCVFHMFZ|KCVFHAFZ|KCVFHPCP|KCVFHSBY)
#define KCVFH_NMFUZZY (KCVFH_FUZZY^KCVFHMFZ^KCVFHSBY) /* non-MR fuzzy */
#define KCVFHBCP 0x100 /* Bad Checkpoint – no enabled thread bitvec */
#define KCVFHFMH 0x200 /* Freshly Munged Header. resetlogs not finished */
#define KCVFHXCH 0x400 /* eXternally CacHed by operating system */
#define KCVFHZBA 0x800 /* Zeroed Blocks Allowed */
#define KCVFHPCP 0x1000 /* Proxy Copy in Progress */
#define KCVFHRBS 0x2000 /* does kcvfhrdb point to bootstrap$ ? */
#define KCVFHSBY 0x4000 /* media rcv fuzzy due to standby apply */
#define KCVFHL0C 0x8000 /* Incremental level 0 copy */
/* bits that can be set in kcvfh_status2 for move datafile */
#define KCVFH_SECONDARY 0x01 /* secondary file for datafile move */
#define KCVFH_NOT_CURRENT 0x02 /* file not current after datafile move */
#define KCVMAXBKSEC 256 /* maximum sections in a multi-section backup */
对不起,这篇文章暂时关闭评论。