In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you what the specific use of RMAN is, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Recovery manager (RMAN) is a DBA tool provided by ORACLE to manage backup and restore operations. RMAN can only be used in ORACLE8 or later. It can back up the entire database or database parts, including tablespaces, data files, control files and archive files. RMAN can access and perform backups and restores as required.
RMAN backup has the following advantages
☆ supports online hot backup
☆ supports multi-level incremental backup
☆ supports parallel backup and recovery
☆ reduces the amount of spare parts required
☆ backup and recovery are easy to use.
[$nbsp] [$nbsp] [$nbsp] importantly, using the recovery manager allows you to make incremental block-level backups (this is very different from export / import increments). Incremental RMAN backups are time and space efficient because they only back up those blocks that have changed since the last backup. Another space-efficient RMAN feature is that it only backs up blocks used in data files, ignoring empty, unused blocks, which is of great benefit to pre-allocated tablespaces.
[$nbsp] [$nbsp] starting from 9i, it also increases the block-level recovery of RMAN, which can further reduce database recovery time.
RMAN supports the following different types of backups
Full backup of FULL database, including all data blocks
INCREMENTAL incremental backup, backing up only blocks that have been modified since the last incremental backup. A level 0 increment is required as the basis for the increment, which can support level 5 increments.
OPEN is used when the database is open
CLOSED backs up when the database is installed (MOUNT) but is not open, and the off backup can be of type CONSISTENT or IN CONSISTENT.
CONSISTENT is used when the database is installed, is not opened, and the database is completely closed before installation (rather than being corrupted or exited abnormally). CONSISTENT backups can be simply RESTORE instead of RECOVER
INCONSISTENT is used when the database is opened or installed (but not opened). INCONSISTENT backups need to be restored after the database shuts down or crashes normally.
Understand the BACKUP,RESTORE,RECOVER command, which is the three most basic commands of RMAN, which can backup, restore and restore the database.
[$nbsp] [$nbsp] [$nbsp] understand the recovery directory, RMAN can be run without the recovery directory (NOCATALOG), when the backup information is saved in the control file. The backup information saved in the control file is very dangerous, if the destruction of the control file will lead to the loss of backup information and the failure of recovery, moreover, without restoring the directory, many RMAN commands will not be supported. Therefore, for important databases, it is recommended to create a recovery directory, which is also a database, but this database is used to store backup information, and a recovery directory can be used to back up multiple databases.
[$nbsp] [$nbsp] create a RMAN directory. The following steps explain the process of trying to RMAN a directory in a database.
a. Create a separate tablespace for the catalog
SQL > Create tablespace tools datafile 'fielname' size 50m
b. Create a RMAN user
SQL > Create user RMAN identified by RMAN default tablespace tools temporary tablespace temp
c. Grant permissions to RMAN
SQL > Grant connect, resource, recovery_catalog_owner to rman
d. Open RMAN
$> RMAN
e. Connect to the database
RMAN > connect catalog rman/rman
f. Create a recovery directory
RMAN > Create catalog tablespace rman
Register the target database, and after the recovery directory is created successfully, you can register the target database. The target database is the database that needs to be backed up. A recovery directory can register multiple target databases. The command to register the target database is as follows:
[$nbsp] [$nbsp] $> RMAN target internal/password catalog rman/rman@rcdb
RMAN > Register database
Once the database is registered, you can use RMAN for backup. For more commands, please refer to the ORACLE online manual or the ORACLE8i backup and recovery manual.
RMAN uses scripts to back up databases. Here are some examples of RMAN backing up.
a. Back up the entire database
Backup full tag 'basicdb' format' / bak/oradata/full_%u_%s_%p' database
b. Back up a tablespace
[$nbsp] [$nbsp] backup tag 'tsuser' format' / bak/oradata/tsuser_%u_%s_%p' tablespace users
c. Backup archive log
Backup tag 'alog' format' / bak/archivebak/arcbak_%u_%s_%p' archivelog all delete input
ii. Maintain RMAN
The maintenance of RMAN is mainly divided into several aspects
1. [$nbsp] [$nbsp] View the information of RMAN
[$nbsp] [$nbsp] check for existing backups
[$nbsp] [$nbsp] RMAN > list backup
[$nbsp] [$nbsp] lists expired backups
[$nbsp] [$nbsp] RMAN > report obsolete
[$nbsp] [$nbsp] Delete expired backups
[$nbsp] [$nbsp] RMAN > allocate channel for maintenance type disk
[$nbsp] [$nbsp] RMAN > change backupset id delete
[$nbsp] [$nbsp] RMAN > release channel
2. [$nbsp] [$nbsp] synchronize or reset RMAN
If the physical object of the target database changes, such as adding a data file, you need to synchronize with the following command:
RMAN > resync catalog
If the target database reset the database, you need to synchronize with the following command
RMAN > reset database
When you manually delete the archive file for the database, perform the following script synchronization
RMAN > allocate channel for maintenance type disk
RMAN > change archivelog all crosscheck
RMAN > release channel
[$nbsp] [$nbsp] when the RMAN backup of the database is manually deleted, perform the following script synchronization
[$nbsp] [$nbsp] RMAN > allocate channel for maintenance type disk
RMAN > crosscheck backup
RMAN > delete expired backup
RMAN > release channel
Fourth, customize the appropriate backup strategy
i. Customize the right strategy
The correct backup strategy can not only ensure the high performance of the database server, but also ensure the rapidity and reliability of backup and recovery. We will discuss RMAN's multi-level incremental backup as an example of a backup strategy. The use of multi-level backup is to reduce the time needed for daily backup, and to ensure that the system has a good recovery. There is a tradeoff between recovery time and backup time. For example, as long as a full backup of the database, and then only backup archives can ensure that the database can be restored to the latest state, but such recovery time will not be tolerated. Multi-level backup is also designed to solve this problem, here is an example of multi-level backup:
Make a full backup of the database every six months (including all data and read-only tablespaces)
Make a level zero backup once a month (excluding read-only tablespaces)
Make a first-level backup once a week
Make a secondary backup once a day
Any changes to the database require resynchronization of the CATALOG directory and re-backup (such as adding data files) or re-backup (such as modifying the tablespace to read-only)
You can back up the archive log or back up the archive log regularly after each backup.
If possible, you can back up directly to the tape.
Script for full backup of database
Run {
Allocate channel c1 type disk
Allocate channel c2 type disk
Allocate channel c3 type disk
Backup full tag 'dbfull' format' / u01Accord oradata database backupfull% uplink% slots% p' database
Include current controlfile
Sql 'alter system archive log current'
Backup fileaperset 3 format'/ u01Accord oradata Universe backupchar% uplink% slots% p'
Archivelog all delete input; # backup archiving is optional and can be backed up separately and regularly
Release channel c1
Release channel c2
Release channel c3
}
Script for level zero backup
Run {
Allocate channel c1 type disk
Allocate channel c2 type disk
Allocate channel c3 type disk
Backup incremental level 0 tag 'db0' format' / u01Universe oradataAccord backupDb0% upright% slots% p'
Database skip readonly
Sql 'alter system archive log current'
Backup fileaperset 3 format'/ u01Accord oradata Universe backupchar% uplink% slots% p'
Archivelog all delete input; # backup archiving is optional and can be backed up separately and regularly
Release channel c1
Release channel c2
Release channel c3
}
Similarly, we can get first-level backup, second-level backup scripts, such as first-level backup scripts.
Run {
Allocate channel c1 type disk
Allocate channel c2 type disk
Allocate channel c3 type disk
Backup incremental level 1 tag 'db1' format' / u01Universe oradataPlacement backupDb1% uplink% slots% p'
Database skip readonly
Sql 'alter system archive log current'
Backup fileaperset 3 format'/ u01Accord oradata Universe backupchar% uplink% slots% p'
Archivelog all delete input; # backup archiving is optional and can be backed up separately and regularly
Release channel c1
Release channel c2
Release channel c3
}
If you follow the above backup strategy, the amount of data that needs to be backed up every day is only changed by one day. When doing recovery, you need to restore at most one zero-level backup of the current month, three first-level backups, six second-level backups and archived files of the same day. If you cannot accept such a recovery time, you can reduce the interval between level zero backups.
[$nbsp] [$nbsp] in principle, the archived logs before the backup point can be deleted after each backup, but for further security and future needs (such as using LOGMNR to find the required information), it is recommended that the archived logs be kept for one year and can be stored on magnetic tapes and other cheap access devices.
ii. Optimization related to RMAN backup
The backup operation mainly completes the following three steps
1. Read data from disk
2. Processing data blocks in memory
3. Write data to disk or tape
The above read and write operations can be completed synchronously or asynchronously. In synchronous IPUBO operations, only one IO operation is allowed at a time, but in asynchronous ICPO operations, multiple IO operations are allowed at one time. Therefore, the tuning of backup and recovery is mainly focused on the following aspects:
1. [$nbsp] [$nbsp] improve the ability to operate synchronously or asynchronously.
On operating systems that support asynchronous operations, you can set up TAPE_AYSNCH_IO,DISK_ASYNCH_IO and BACKUP_TYPE_IO_SLAVES to support asynchronous operations and improve the ability to write.
2. [$nbsp] [$nbsp] improve disk read ability
You can set up DISKRATIO after the backup command to ensure that data is read from multiple disks and that there is a continuous data flow.
3. [$nbsp] [$nbsp] set buffer and parameter values correctly
Set LARGE_POOL_SIZE so that backups can use continuous buffer pools, and buffer utilization can be improved by setting DB_FIL_DIRECT_IO_COUNT. If you use tape backup, you can also set up BACKUP_TYPE_IO_SLAVES to improve the tape write ability.
4. [$nbsp] [$nbsp] uses parallel backup
Open up multiple channels to achieve parallel backup and recovery
iii. Back up the RMAN database
RMAN's own database also needs to be backed up, but it is small and does not change very often, so after each RMAN backup is complete, you can back up the RMAN database with the following script.
EXP pafile = exprman.sql
Exprman.sql is
USERID=RMAN/RMAN
BUFFER=32768
OWNER=RMAN
FILE=RMAN.DMP
ROWS=Y
GRANTS=Y
COMPRESS=Y
CONSISTENT=Y
iv. Make automatic backup of database
There are no more than three ways to automatically back up databases
Task planning under [$nbsp] [$nbsp] WINDOWS (At command)
Crontab under [$nbsp] [$nbsp] UNIX
[$nbsp] [$nbsp] third-party tools such as Viritas
In the above three ways, Viritas is a third-party tool, and many people may not have contact with it. Let's mainly talk about windows's task plan and unix's cron.
1. Generate script files, such as backup.rcv
Assume that the contents of the file are as follows:
$> cat backup.rcv
Connect target sys/password rcvcat rman/rman@localname
Run {
Allocate channel c1 type disk
Allocate channel c2 type disk
Allocate channel c3 type disk
Backup fileaperset 3 format'/ u01Accord oradata Universe backupchar% uplink% slots% p'
Archivelog all delete input
Release channel c1
Release channel c2
Release channel c3
}
[$nbsp] [$nbsp] 2. Generate execution file
Generate backup_archive.bat on windows, including
Rman cmdfile = backup.rcv
Generate backup_archive.sh under unix, including
/ oracle/ramn/rman cmdfile = backup.rcv
3. Join the scheduling
You can use the Task scheduling Wizard in windows, or use the at command.
In unix, write a file on the target machine to start the automatic backup process. Assuming the file name is ORACLE, the file will be placed in the / var/spool/cron/crontabs directory
$> cat oracle
0 23 * * 0 backup_archive.sh
# means to back up the database at 23:00 on Sunday
0 12pr 18 * backup_archive.sh
[$nbsp] [$nbsp] # means backup at 12:00, 18:00 every day
Each line of the Crontab file consists of six minutes,hours,day of month,month,day of week,command, separated by spaces or Tab
The above content is what is the specific use of RMAN? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, 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.