10gocm-) session3-) data backup and recovery

Source: Internet
Author: User
This experiment examines how to recover our database services in the shortest time when the database goes down and data is lost. RMAN planning hosttarget library catalog library ocm01ow.bocm02ocmdb02 a simulated ControlFile loss troubleshooting (Instance) We simulate control file loss failure and go forward

This experiment examines how to recover our database services in the shortest time when the database goes down and data is lost. RMAN planning host target database catalog Database ocm01 ocmdb ocm02 ocmdb02 a simulation of Control File loss troubleshooting (Instance) We simulate Control File loss failure and go forward

This experiment examines how to recover our database services in the shortest time when the database goes down and data is lost.
RMAN Planning
Host Target Library Catalog Library
Ocm01 Ocmdb
Ocm02 Ocmdb02

One simulated Control File loss troubleshooting (Instance)
We simulate a control file loss failure and perform rapid recovery.
Forcibly stop a database
Select open_mode, log_mode from v $ database;
1. shutdown abort
Rm command to delete Control File
Rm control01.ctl
When startup starts the database, an error is reported.
We checked the alert Log to learn about the loss of the control file.
Shutdown immediate stop the database
2. Restore Lost control files with intact control files
Cp control02.ctl ../disk1/control01.ctl
Restart Database
Startup

2. Create a CATALOG database to save the RMAN backup information
1. The catalog Database uniformly manages RMAN backup information, that is, metadata information. If there is no catalog database, it writes the RMAN backup information to the control file.
2. The target database must be registered in the catalog database before it can be used.
Official documentation: Backup and Recovery Reference-> create catalog and REGISTER
Backup and Recovery Advanced User's Guide-> 10 Managing the Recovery Catalog-> Creating a Recovery Catalog
Note: ocmdb is the target database.
Ocmdb02 is a CATALOG Database
1. Create a tablespace. This tablespace stores the contents of the catalog database.
Sqlplus sys/oracle @ ocmdb02 as sysdba
Create tablespace catalog_tbs datafile '/u01/oracle/oradata/ocmdb02/catalog_tbs01.dbf' size 100 m autoextend on;
2. Create a catalog_database to manage the user catalog_admin default tablespace catalog_tbs
Create user catalog_admin identified by catalog_admin default tablespace catalog_tbs;
3. Grant the recovery_catalog role to the catalog_admin user for backup and recovery.
Note: Some students may ask if I can grant the DBA role directly. In fact, the DBA role is not omnipotent. It does not include the preceding roles. Therefore, we need to set them separately.
Select * from dba_roles where role like '% RECOVER %'; is this role available?
Select * from role_sys_privs where role = 'recovery _ CATALOG_OWNER '; Which permissions does this role have?
Grant connect, resource, recovery_catalog_owner to catalog_admin; only three roles are required.
4. log on to RMAN to create a CATALOG Database
Rman catalog_admin/catalog_admin @ ocmdb02
Create catalog tablespace catalog_tbs; specify the catalog_tbs tablespace as the catalodatabase
Exit
5. register the target database
Register ocmdb
You must log on to the database as an administrator to register an ordinary user.
Rman target sys/oracle @ ocmdb1521 catalog catalog_admin/catalog_admin @ ocmdb02
Register database;
Register ocmdb02
Rman target sys/oracle catalog catalog_admin/catalog_admin
Register database;
[Unregister database;] The unregister command
6. Check which databases have been registered to the catalog Database.
Sqlplus catalog_admin/catalog_admin @ ocmdb02
Select * from rc_database;
7. Enable archiving in ocmdb
Alter system set log_archive_dest_1 = 'location =/u01/oracle/arcdata' scope = spfile;
Shutdown immediate
Startup mount
Alter database archivelog;
Alter database open;
Select log_mode from v $ database;

Iii. Set RMAN Environment Variables
Official documentation: Backup and Recovery Reference-> CONFIGURE
When we use the RMAN tool for Backup recovery, we can first specify the Backup recovery option in command line mode.
Second, you can set the RMAN environment variable in advance to automatically trigger when the trigger condition is met (Purpose)
You must connect to the target database before you can view the set variable value.
Rman target sys/oracle @ ocmdb1521 catalog catalog_admin/catalog_admin @ ocmdb02
Show all;
Configure retention policy to redundancy 1; # default REDUNDANCY configuration retention policy: the number of REDUNDANCY is 1
Configure backup optimization off; # enable Incremental BACKUP by default: OFF
Configure default device type to disk; # default DEFAULT backup DEVICE is DISK
Configure controlfile autobackup off; # automatic backup of default control file: OFF
Configure controlfile autobackup format for device type disk to '% F'; # default control file automatic backup directory and FORMAT: % F [backup DEVICE: Disk]
Configure device type disk parallelism 1 backup type to backupset; # default BACKUP degree of PARALLELISM: 1. backup type: BACKUP set [several channels are allocated for a few degree of PARALLELISM]
Configure datafile backup copies for device type disk to 1; # default data files are backed up by Replication
Configure archivelog backup copies for device type disk to 1; # default archive logs are backed up by copying
Configure maxsetsize to unlimited; # default maximum value: UNLIMITED
Configure encryption for database off; # default encrypted DATABASE: OFF
Configure encryption algorithm 'aes128 '; # The default encryption algorithm uses the AES128 ALGORITHM to encrypt the tablespace.
Configure archivelog deletion policy to none; # default archive log deletion policy: NULL
Configure snapshot controlfile name to snapshot control file NAME
RMAN default backup media storage directory/home/oracle/backup
Configure channel device type disk format'/home/oracle/backup/ocmdb _ % U ';
Automatic Backup of Control Files
Configure controlfile autobackup on;
Configure controlfile autobackup format for device type disk to '/home/oracle/backup/control/controlfile _ % F ';
Backup concurrency 2
Configure device type disk parallelism 2;
Incremental Backup
Configure backup optimization on;
Backup media retention period: 30 days
Configure retention policy to recovery window of 30 days;
Display the configured parameters
Show all;
4. RMAN backup and flash back database
Official documentation: Backup and Recovery Reference-> BACKUP
Backup and Recovery Basics-> 4 Backing Up Databases Using RMAN-> 4.2.5 Using Compressed Backupsets for RMAN Backup
1. Full backup Compression
Backup as compressed backupset database plus archivelog; use the default backup media directory and format, and use control files and parameter files for automatic backup
2. The RMAN module version compresses the backup database and uses the compressed backup mode for full database backup.
Run {
Backup as compressed backupset full database
Format '/home/oracle/backup/full_ocmdb _ % u % p % s. rmn'
Include current controlfile;
Backup as compressed backupset archivelog all
Format '/home/oracle/backup/arch_ocmdb _ % u % p % s. rmn'
Delete all input;
}
3. Use the default backup media directory and format, and delete the archived logs that have been backed up.
Backup as compressed backupset full database include current controlfile plus archivelog delete all input;
4. "one-line RMAN command" to compress the backup database
Backup as compressed backupset full database format
'/Home/oracle/backup/full_ocmdb _ % u % p % s. rmn' include current controlfile
Plus
Archivelog format '/home/oracle/backup/arch_ocmdb _ % u % p % s. rmn' delete all input;
5. Check all backup Sets
List backupset summary;
6. Configure the flashback Database
Flash back database: use the flash back log to restore the database to a previous time point.
To enable the flash back function, you must enable archiving. Archive logs can help you complete the flash back function. You do not need to archive these logs.
1. Check the database status
Select open_mode, log_mode, flashback_on from v $ database; whether it is in the mount and archive status
Archive log list;
Set the size of the quick recovery area before setting the Directory
Alter system set db_recovery_file_dest_size = 2g;
Mkdir-p/home/oracle/flash
Alter system set db_recovery_file_dest = '/home/oracle/flash'; (Save the flash log)
Set the flash back retention period to 24 hours (1 day) in minutes
Alter system set db_flashback_retention_target = 1440 scope = spfile;
2. Restart to make the parameter take effect
Shutdown immediate
Startup mount
Show parameter db_recovery
Enable the flash back function
Alter database flashback on;
3. Open the database
Alter database open;
Select open_mode, log_mode, flashback_on from v $ database;
Flash Back Type
Flash back query undo
Flashback table recycbin
Flash back version undo
Flash back transaction undo
Flash back database flash back log
Flash back to archive tablespace (New Features of permanent saving of 11 GB)

Source OCM lab Selection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.