In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to backup and restore ORACLE RMAN. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
RMAN can perform incremental backups: databases, tablespaces, data files
Only used block can be backed up as backup set
Correspondence between tablespaces and data files: dba_data_files / v$datafile_header
In noarchivelog mode, you can use RMAN to back up the table spaces of read-only and offline
ORACLE RMAN downtime backup:
Backup
RMAN connection under ORACLE,WINDOWS in command mode
RMAN TARGET /
The local authentication mode is used to connect to the local database. The RMAN connection database must be in dedicate mode. Therefore, the database in share mode should configure a dedicate connection for RMAN connections.
If you want to back up the control files and parameter files together
Configure controfile autobackup on;// opens autobackup
Configure controfile autobackup off;// shuts down autobackup
Shut down the database
RMAN > shutdown immediate
The backup of mount database RMAN must be in MOUNT mode, which is important to control file backup.
RMAN > startup mount
The simplest backup
RMAN > backup database
That's it, OK.
For such a backup, the backup set is in the default location of the database. % oracle_home%/ora92/database
Of course, you can also use run to define your backup flexibly.
RMAN > run {
> allocate chennel D1 type disk; / / assign channels
> backup full database / / full backup of the database
> include current controlfile / / including the current controlfile
> format'e:\ oracle\ orders\ db_%d_%s_%p_%t_%T'; / / backup file location and file name format
> release channel d1bomber / release channel
>}
Restore
1. The data file is corrupted, but the control file is good, or has been restored.
RMAN connects to the database
Startup mount
Restore database
Recover database noredo
Alter database open resetlogs
Recover database noredo this command instructs RMAN to perform the final restore operation in preparation for opening the database. Because it is in NOARCHIVELOG mode and no archived redo logs are applied and the online redo logs are lost, the noredo parameter is required in this command.
Finally, open the database using alter database open resetlogs. Because the control file has been restored and the redo log needs to be rebuilt, you must use resetlogs.
2. Restore control files
Startup nomount
Set dbid =
Restore controlfile from autobackup
Alter database mount
Restore database
Recover database noredo
Alter database open resetlogs
Alter database open
In this example, there is a DBID that can
Found in select * from v$database. But a database in the control file is broken, how can OPEN see it? this is to write down the DBID at ordinary times.
This is the simplest example of backup and recovery with RMAN, but you can see the outline of RMAN backup and recovery.
ORACLE RMAN online backup:
1. Before ORACLE RMAN online backup, you need to change the log mode to archive log.
a. Shut down the database
SQL > shutdown immediate
b. Start the database to mount state
SQL > startup mount
c. Enable archive mode
SQL > alter database archivelog
d. View the modified database backup and recovery strategy and the location of the archived files
SQL > archive log list
Note: after changing to archive mode, all previous database backups are invalid.
e. Modify the corresponding initialization parameters
Before Oracle10g, you also need to modify the initialization parameters to put the database in automatic archiving mode.
You can view it with SQL > show parameter log_archive_start;.
NAME TYPE VALUE
Log_archive_start boolean FALSE
SQL > alter system set log_archive_start=true scope=spfile
Restart the database this parameter takes effect, and the database is in automatic archiving mode.
Of course, you can skip step 5 and go directly.
SQL > archive log start
Enable automatic archiving of the database, but the database is still in manual archiving mode after restart.
two。 Run: RMAN target /
3. Save RMAN information: it is saved in control file by default with a preservation period of 7 days.
Adjust: alter system set control_file_record_keep_time= days
4. Set up an independent database to save RMAN backup information
Since there is only one database, it is built on its own database.
a. Create tablespace RC:create tablespace rc datafile size 10m autoextend on next 1m
b. Create a user RC:
CREATE USER rc IDENTIFIED BY rc TEMPORARY TABLESPACE temp DEFAULT TABLESPACE rc QUOTA UNLIMITED ON rc
c. Authorized RC: GRANT RECOVERY_CATALOG_OWNER TO rc
d. Build:
Rman catalog rc/rc@orcl
RMAN > create catalog
RMAN > exit
Rman target / catalog rc/rc@orcl
RMAN > register database
e. Use:
Rman target / catalog rc/rc@orcl
After this connection, the data will be stored in the control file and one copy each in the catalog
5. Global parameter configuration:
Viewing: show all
Modify: specific settings of configure parameter name
For example: modify whether to automatically save controlfile: configure controlfile autobackup on
Restore default value: configure parameter name clear
Key parameters:
a. Save cycle: retention policy
Default is redundancy 1: keep a backup
Available value: recovery window of 7 days: keep backups that meet the 7-day recovery cycle
Check based on condition: report obsolete:RMAN lists backups that can be deleted based on the save cycle parameter
Delete more than backup: delete obsolete
b. Optimized backup: backup optimization:RMAN automatically ignores content that has been backed up (data files, archive logs, backup blocks)
Prerequisite: backup specifies the same channel
c. Default backup channel: default device type to disk: default backup to disk, path is flash recovery area
Channel Type:
Disk: file system path
Flash recovery area: default path
Sbt: tape Devic
Modify to another path to disk: configure channel device type disk format 'path /% U'
For example: configure channel device type disk format'/ tmp/movedata/%U'
6. Backup result
Backupset:backup (as backupset) backup content, which is divided into one or more backup piece, only this type of backup can be compressed.
Copy:backup as copy backup content
View by type:
Backupset View: list backup summary (list backupset summary)
View details: list backupset BS
Copy View: list copy
View by content:
Entire database: list backup of database
Tablespace:list backup of tablespace users
Data file: list backup of datafile n
Control file: list backup of controlfile
Archive logs: list archivelog all
View by rule:
View files that can be deleted according to save rules: report obsolete
View what needs to be backed up according to the save rules: report
Combined inspection of RMAN and OS: corsscheck content
7. Backup mode
Full: complete
Incremental: incremental backup
Types of incremental backups: databases, data files, tablespaces
a. First of all, you need to do a level 0 backup as a basis. For example: backup incremental level 0 backup content; (backup content: all used data block, different from image copy)
b. Increment type:
Cumulative increment: backup cumulative level 1 backup content
Differential increment: backup incremental level 1 backup content
Difference: cumulative increments are always level 0-based backups
The first differential increment is based on level 0 backup; from the second, it is based on the previous incremental backup.
C. Image backup increment method:
The first time: based on the complete Image
The second time: based on complete, do incremental backup; after completion, synthesize into a complete Image
The third time: make incremental backup based on the second complete Image, and synthesize it into a complete Image after completion
Achieve:
For example: for tablespace example
RUN {
RECOVER COPY OF tablespace example WITH TAG 'incr_update'
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update'
Tablespace example
}
d. Enable the parameter "block change tracking" to improve the speed
View status: SELECT status FROM v$block_change_tracking
Default value: DISABLED
Enable: ALTER DATABASE ENABLE BLOCK CHANGE TRACKING; (DB_CREATE_FILE_DEST in the default storage path OMF)
Set the file path:
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE'/ u01 REUSE oradata REUSE
Turn off: ALTER DATABASE DISABLE BLOCK CHANGE TRACKING
Backup and check: bakcup check logical backup contents
No backup, just check the file: backup validate backup contents
If an error is reported in the check, check: vogue backupsetting corruptionwitch vandalism copywriting
8. Backup content:
The whole database: RMAN > backup database
Classic full library backup: backup as compressed backupset database include current controlfile plus archivelog delete input
Tablespace:RMAN > backup tablespace name
Data file: RMAN > backup datafile n; (n: specific data file number select file_name,file_id,tablespace_name from dba_data_files;)
Control file: RMAN > backup current controlfile
Or RMAN > backup database include current controlfile
Log file: RMAN > backup archivelog all
Or RMAN > backup database plus archivelog
Parameter file: RMAN > backup spfile
9. Reduction
a. Complete recovery
Method 1: restore the entire database from the most recent backup set, and the database automatically runs redo and archive logs (full recovery):
SQL > shutdown immediate
SQL > startup mount
RMAN > restore database
RMAN > recover database
RMAN > sql 'alter database open'
Method 2: restore the entire database from tag, and the database also runs redo and archive logs (full recovery), and the result is the same as the script above:
1. View the label:
RMAN > list backupset summary
Key TY LV S Device Type Completion Time # Pieces # Copies Compressed Tag
25 B An A DISK 25-JUL-11 11 NO TAG20110725T104634
28 B 0 A DISK 25-JUL-11 11 NO TAG20110725T104645
29 B An A DISK 25-JUL-11 11 NO TAG20110725T104711
30 B F A DISK 25-JUL-11 11 NO TAG20110725T104713
31 B An A DISK 25-JUL-11 11 NO TAG20110725T105333
32 B An A DISK 25-JUL-11 11 NO TAG20110725T105350
33 B 1 A DISK 25-JUL-11 11 NO TAG20110725T105353
34 B An A DISK 25-JUL-11 11 NO TAG20110725T105408
35 B F A DISK 25-JUL-11 11 NO TAG20110725T105411
36 B An A DISK 25-JUL-11 11 NO TAG20110725T111403
37 B 1 A DISK 25-JUL-11 11 NO TAG20110725T111405
38 B An A DISK 25-JUL-11 11 NO TAG20110725T111421
39 B F A DISK 25-JUL-11 11 NO TAG20110725T111423
two。 Restore the database:
SQL > shutdown immediate
SQL > startup mount
RMAN > restore database from tag TAG20110725T104645
RMAN > recover database from tag TAG20110725T104645
RMAN > alter database open
b. Incomplete recovery:
SQL > shutdown immediate
SQL > startup mount
RMAN > restore database from tag TAG20110725T104645
RMAN > recover database until time "to_date ('2011-08-04 15 to_date 3714 25mm hh34:mi:ss')"
RMAN > alter database open resetlogs
Note: all backup sets are invalid after use. To ensure security, you need to recomplete the database (after ORACLE10G, backups before resetlog are still available).
Critical tablespace recovery (system / undotbs1 / sysaux):
SQL > shutdown abort
SQL > startup mount
RMAN > restore tablespace name
RMAN > recover tablespace name
RMAN > sql 'alter database open'
Non-critical tablespace recovery (example / users):
Select * from vested datafile headers; correspondence between tablespaces and data files
SQL > alter database datafile Digital offline
RMAN > restore tablespace name
RMAN > recover tablespace name
SQL > alter database datafile Digital online
10. Delete backup
All backup backup sets: delete backup
All copy backup machines: delete copy
Specific backup: delete backupset 19
Delete Files can be deleted according to save rules: delete obsolete
Delete expired backups:
Delete expired backupset
Delete expired copy
11. RUN block
For example:
RMAN > RUN {
ALLOCATE CHANNEL c1 DEVICE TYPE sbt
ALLOCATE CHANNEL c2 DEVICE TYPE sbt
ALLOCATE CHANNEL c3 DEVICE TYPE sbt
BACKUP
INCREMENTAL LEVEL = 0
FORMAT'/ disk1/backup/df_%d_%s_%p.bak'
(DATAFILE 1, 4, 5, CHANNEL C1)
(DATAFILE 2, 3, 3, 9 CHANNEL c2)
(DATAFILE 6, 7, 8, CHANNEL c3)
ALTER SYSTEM ARCHIVE LOG CURRENT
}
twelve。 External variables:
Language: set nls_lang=american
Date: set nls_date_format=yyyy-mm-dd....
13. RMAN sciprt
Prerequisites: have catalog
Written: (global indicates that it can be called by multiple databases)
Create global script. Name
Comment "remarks"
{script content}
For example:
Create global script. Abc
Comment "test"
{backup current controlfile;}
Call: run {execute script. First name}
For example: run {execute script. Abc;}
View: print script. Name
Rewrite:
Replace global script. Name
Comment "remarks"
{script content}
Delete: delete script. First name
14. Permanent retention backup
The condition is that the backup cannot be kept in flash recovery area.
a. Create a backup:
RUN
{
ALLOCATE CHANNEL C1 DEVICE TYPE disk format'/ tmp/autobackup/%U'
BACKUP tablespace example
}
b. Find the backup:
List backupset of tablespace example
c. Change the property to permanent
Change backupset number keep forever nologs
15. Establish multiple fixed-size backups
For example: example test backup size is greater than 50m
Run
{
Allocate channel C1 device type disk maxpiecesize 10m format'/ tmp/autobackup/%U'
Backup tablespace example
}
There are six files in / tmp/autobackup directory
16. Run script: backup recovery area
Backup content:
A. Control file autobackup
B. Incremental backup sets
17.block change tracking
a. For the entire database
b. Default storage path: background_dump_dest
The above is the editor for you to share how to carry out ORACLE RMAN backup and restore, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.