RMAN's use

zhaozj2021-02-16  97

RMAN's use

Author: David Zhang

RMAN (Recovery Manager, Recovery Manager) is an advantageous tool for backup and recovery from Oracle 8, which has two use interfaces: GUI (graphical user interface) and CLI (command line interface). Using RMAN can not only complete the various tasks of Oracle database backup and recovery, but also have a considerable comprehensive reporting function.

Use RMAN for the form

• Managing a local database You can use OS authentication, which is set in the initialization parameter file, which must be used in the initialization parameter file; but to manage the remote database must use the password authentication to set the parameter remote_login_passwordfile = Exclusive.

• Users who do backup and recovery must have SYSDBA privileges

• The device used in the backup must be that the RMAN user has the right to use.

• To use the RMAN backup data to the tape drive, you will need to install and configure backup media management software similar to the LEGATO Storage Manager.

Perform the execution process of Oracle database backup using RMAN

1. When the user issues a RMAN command to back up the database, the RMAN first has to link to the target database, that is, verify the user's connection permission;

2. Check if the recovery directory is installed;

3. Verify that the database has been registered to RMAN;

4. If no registration, the error declaration database is not registered and requires the user to register the database;

5. If you have already registered, create a server session connection, and compile the user's backup commands issued by the RMAN prompt.

Compared with the OS command backup, use RMAN's advantages

• No manual intervention is required during the backup execution, thus reducing the opportunity to operate;

• Can effectively combine backups and recovery;

• Support all backup types other than logical backups, including full backup, incremental backup, tablespace backup, data file backup, control file backup, and archive log file backup;

? You can identify the Corrupted block;

• Convenient implementation period (timing) backup;

• Automatically generate backup logs;

• RMAN's backup teaching and OS are not related to the portation;

? Powerful reporting features can be convenient for the availability of backups

Using RMAN shortcomings compared to the OS command backup mode

• The backup process is opaque;

• RMAN backup data can only be recovered using RMAN;

• If you manage multiple databases on your network, you usually use a separate database to use a RMAN recovery directory. If this database fails, all database backups cannot be used unless this database is restored. Then to ensure that this database is fettered in the database that is used to store the RMAN recovery directory, it is usually necessary to use the OS command backup for this database.

• If there is a database that needs to be backed up, the backup information will record in the control file, so the control file is not backed up, and it cannot be lost.

• RMAN Backup You cannot back up the Redo Log Files, the parameter file (init.ora), password file, the operating system file, and the file of Offline.

RMAN supported backup type

1. Backup set (created using the backup command)

· Backup sets can include archive logs or data files, but cannot include both, that is, archive logs and data files cannot be merged into a backup set, even in a backup operation, the backup archive log and data file, RMAN Two backup sets are also automatically generated, which are used to archive logs and data files, respectively. · Backup set can be a complete backup or an incremental backup. Fully back up all data blocks containing data files used by the database (and no backups that are not used). Incremental backups contain only post-modified data blocks after the last statistic or lower backup.

· Incremental backups use cumulative and noncumulative two options

· Use the restore command to recover files from backup

2. Data file copy (ie, the impression copy, create the copy command)

• Data file copies are created using the Oracle Server Process process instead of using OS.

· Before copying, there is no need to use an ALTER TABLESPACE ... Begin Backup.

· You can use the data file copy to replace the original file without restoring, but you must use the set ewname or switch command to make the data file into the current version. If necessary, media recovery can be made on the data file copy.

3. Operating system backup (such as COPY, CP, etc. OS command)

· For this backup, you can register them in the recovery directory with RMAN's catalog command.

• You must use an ALTER TABLESPACE ... Begin Backup when backed up.

· View the backup set:

Rman> List backupset;

Backup set list

===================

BS Keyword Type LV Size Device Type After Time Completion Time

---------- - ------------------------------------ --------

128 Full 424k disk 00:00:02 25- Jan -02

BP Keywords: 129 Status: Available Tag: Tag20020125T105458

Segment name: E: / Oracle / ORA92 / DATABASE / 03DF4GC3_1_1

Data file list in backup set 128

File LV Type CKP SCN CKP Time Name

- - - - - - ----------------------

6 Full 676301 25-Jan -02 E: /oracle/ora92/test/USERS01.DBF

Rman>

View Archive Logs backup:

Rman> List copy;

Archive log replica list

Keyword THRD SEQ S short time name

------- ---- -------- ---------- ----

103 1 29 A 16- Jan -02 E: /oracle/oradata/test/archive/1_29.arc

104 1 30 A 16- January -02 E: /oracle/oradata/test/archive/1_30.arc

105 1 31 A 17-Jan -02 E: /oracle/oradata/test/archive/1_31.arc106 1 32 A 18-JanData/test/archive/1_32.arc

107 1 33 A 18- Jan -02 E: /oracle/oradata/test/archive/1_33.arc

108 1 34 A 19-January -02 E: /oracle/oradata/test/archive/1_34.arc

109 1 35 A 21- Jan -02 E: /oracle/oradata/test/archive/1_35.arc

110 1 36 A 21- January -02 E: /oracle/oradata/test/archive/1_36.arc

111 1 37 A 22- Jan -02 E: /oracle/oradata/test/archive/1_37.arc

112 1 38 A 22-Jan -02 E: /oracle/oradata/test/archive/1_38.arc

113 1 39 A 22- Jan -02 E: /oracle/oradata/test/archive/1_39.arc

114 1 40 A 23- January -02 E: /oracle/oradata/test/archive/1_40.arc

115 1 41 A 24-January -02 E: /oracle/oradata/test/archive/1_41.arc

Rman>

Create a recovery directory

1. Create a user storage to restore the table space (RMAN) and a user who makes RMAN backups and recovery (RMAN):

SQL> CREATE TABLESPACE RMAN DATAFILE 'E: / Oracle/ora92/test/rman01.dbf' size 50m

2 Extent Management Local Autoallocate;

The table space has been created.

SQL> Create User Rman Identified by rman

2 Default TableSpace Rman

3 Temporary TableSpace Temp

4 Quota Unlimited On RMAN

5 quota 0m on system;

User has created

SQL>

2. Grant the RMAN user to Connect, Resource, Recovery_catalog_owner permissions and roles:

SQL> Grant Connect, Resource, Recovery_catalog_owner to rman

Authorized success.

SQL>

3. Connect to the recovery directory database:

C: /> rman catalog rman / rman @ test target lunar / lunar @ TEST

Recovery Manager: Version 9.2.0.1.0 - Production

CopyRight (C) 1995, 2002, Oracle Corporation. All Rights Reserved.

Connect to target database: test (dbid = 1749233635)

Connect to the recovery directory database

No recovery catalog

Rman>

4. Create a recovery directory:

In Oracle 8i:

Create Catalog TableSpace 'Rman';

(Note in 8i, the name of the table space is case sensitive, and must be used by single quotes)

In Oracle 9i:

Rman> CREATE CATALOG

The recovery directory has been created

Rman>

Registration database

Rman> Register Database;

Register the database in the recovery directory

Rosync that is starting all restored directories

Complete all RESYNC

Rman>

Since the information of the Redo Log and Archive Log will not automatically update to the recovery directory, you need a regular synchronous recovery directory.

Restore directory synchronization

Rman> resync catalog;

Rosync that is starting all restored directories

Complete all RESYNC

Rman>

Log out the registered database from the recovery directory

Important:

1. Implement using the DBMS_RCVCAT package;

2. Once you log out, the target database is not available in the backup set in this recovery directory;

3. Logout database must know the identification code (DB_ID) of the target database and the database key value (DB_KEY);

operating:

1. Target database identification code (DB_ID) needs to view when connecting:

2. Database key value (db_key) View:

SQL> SELECT DB_KEY, RPAD (TO_CHAR (DB_ID), 12) "DB_ID_NUMBER"

2 from DB

3 where db_id = '1749233635'

4 /

DB_KEY DB_ID_NUMBER

---------- ------------------------

1 1749233635

SQL>

(Because DB represents the object of the RMAN user, it must be connected in the RMAN user)

3. Log out the database:

SQL> Execute dbms_rcvcat.unregisterDatabase (1,174,9233,635);

The PL / SQL process has been successfully completed.

SQL>

Change the recovery directory

If you delete a backup card, a data file copy or archive log from the recovery directory, you need to update the recovery directory using the Change command.

Example: Delete a copy of a file

Rman> List backup;

Backup set list

===================

BS Keyword Type LV Size Device Type After Time Completion Time

---------- - ------------------------------------ --------

117 Full 424k disk 00:00:03 24- Jan -02

BP Keywords: 118 Status: Available Tag: Tag20020124T194408

Segment name: E: / Oracle / ORA92 / DATABASE / 01DF2R09_1_1

Data file list in the backup set 117

File LV Type CKP SCN CKP Time Name

- - - - - - ----------------------

6 Full 658191 24-Jan -02 E: /oracle/ora92/test/USERS01.DBF

BS Keyword Type LV Size Device Type After Time Completion Time

---------- - ------------------------------------ ------ 121 Full 424k disk 00:00:02 24- Jan -02

BP Keywords: 122 Status: Available Tag: Tag20020124T195718

Section: E: / Oracle / ORA92 / DATABASE / 02DF2ROU_1_1

Data file list in the backup set 121

File LV Type CKP SCN CKP Time Name

- - - - - - ----------------------

6 Full 658520 24-Jan -02 E: /oracle/ora92/test/USERS01.DBF

Rman>

Rman> Change Backupset 121 Delete;

Use channel ORA_DISK_1

Backup segment list

BP Keyword BS Keyword PC # CP # Status Equipment Type Segment Name

------- -------------------------------------- -

122 121 1 1 Available Disk E: / Oracle / ORA92 / DATABASE / 02DF2RO

U_1_1

Is it sure to delete the above object (input Yes or NO)? YES

Removed backup segment

Backup section Handle = E: / Oracle / ORA92 / DATABASE / 02DF2ROU_1_1 Recid = 2 stamp = 452030238

1 object has been deleted

Rman>

Rule of full backup database

• Full Database Backup contains all control files and data files belonging to the database, and backup includes all data blocks, whether they are used.

· When the database is turned on, the database is required to require the database to be in ArchiveLog mode; full database backup is performed when the database is closed, requiring the database to be in the NOARCHIVELOG mode.

• When the database is in ArchiveLog mode, you can perform full backup, table space backup, and data file backup; when the database is in the NOARCHIVELOG mode, you can only perform full backup.

Full backup in NOARCHIVELOG mode

In 9i:

1) Determine the archiving mode of the data to noarchiveLog:

SQL> SELECT log_mode from v $ database;

LOG_MODE

----------------

NoarchiveLog

SQL>

2) Perform full backup

C: /> Rman Target /

Recovery Manager: Version 9.2.0.1.0 - Production

CopyRight (C) 1995, 2002, Oracle Corporation. All Rights Reserved.

Target database (not started)

Rman>

Rman> Startup Mount;

Oracle routines have been started

Database has been loaded

System Global Region Total 135338868 bytes

Fixed size 453492 byte

Variable size 109051904 bytes

Database buffers 25165824 bytes

Redo buffers 667648 bytes

RMAN> Backup Database;

Start Backup on 25- January -02

Assigned channel: ORA_DISK_1

Channel ORA_DISK_1: SID = 11 DevType = Disk

Channel ORA_DISK_1: Start Full Data File Backup Set

Channel ORA_DISK_1: Data file being specified in the backup set

In the backup set contains current SPFile

Backup Concentration includes current control files

Enter data file fno = 00001 Name = E: /oracle/ora92/test/system01.dbf

Enter data file fno = 00003 name = e: /oracle/ora92/test/drsys01.dbf

Enter data file fno = 00002 name = E: /oracle/ora92/test/undotbs01.dbf

Enter data file fno = 00007 name = E: /oracle/ora92/test/xdb01.dbf

Enter data file fno = 00009 Name = E: /oracle/ora92/test/rman01.dbf

Enter data file fno = 00004 name = E: /oracle/ora92/test/indx01.dbf

Enter data file fno = 00005 name = E: /oracle/ora92/test/tools01.dbf

Enter data file fno = 00006 Name = E: /oracle/ora92/test/USERS01.DBF

Channel ORA_DISK_1: Start Segment 1 in 25 - January -02

Channel ORA_DISK_1: Completed Segment 1 in 25- January -02

Segment Handle = E: / Oracle / ORA92 / DATABASE / 05DF51K1_1_1 Comment = None

Channel ORA_DISK_1: The backup set has been completed, after the time: 00: 01: 27

Complete Backup in 25- January -02

Rman>

Create a full database backup data file copy

(Note, first need to take the database has been in the MOUNT state)

9i under:

1) First check the data file that you need to back up:

Rman> Report Schema;

Database scheme report

File KB Table Space RB SEGS Data File Name

---- ---------- --------------------------------- ------------

1 358400 system *** E: /oracle/ora92/test/system01.dbf

2 51200 Undotbs1 *** E: /oracle/ora92/test/undotbs01.dbf

3 102400 drsys *** E: /oracle/ora92/test/drsys01.dbf

4 30720 index *** E: /oracle/ora92/test/indx01.dbf

5 30720 Tools *** E: /oracle/ora92/test/tools01.dbf

6 30720 Users *** E: /oracle/ora92/test/USERS01.DBF

7 51200 xdb *** E: /oracle/ora92/test/xdb01.dbf

9 51200 rman *** E: /oracle/ora92/test/rman01.dbf

Rman>

2) Create a data file copy of the full database backup

Rman> COPY

2> DataFile 1 to 'E: /SYS01.BAK',

3> DataFile 2 to 'E: /undo01.bak',

4> DataFile 3 to 'E: /DRSYS01.BAK',

5> DataFile 4 to 'E: /INDX01.BAK',

6> DataFile 5 to 'E: /TOOLS01.BAK',

7> DataFile 6 to 'E: /USERS01.BAK',

8> DataFile 7 To 'E: /XDB01.BAK',

9> DataFile 9 to 'E: /RMAN01.BAK',

10> Current ControlFile to 'E: /CONTROL.BAK';

Start COPY 26- January -02

Use channel ORA_DISK_1

Channel ORA_DISK_1: Copy Data File 1

Output file name = E: /SYS01.BAK Recid = 2 stamp = 452181102

Channel ORA_DISK_1: Copy Data File 2

Output file name = E: /undo01.bak recid = 3 stamp = 452181117

Channel ORA_DISK_1: Copy Data File 3

Output file name = E: /DRSYS01.BAK RECID = 4 stamp = 452181142

Channel ORA_DISK_1: Copy Data File 4

Output file name = E: /indx01.bak recid = 5 stamp = 452181153

Channel ORA_DISK_1: Copy Data File 5

Output file name = E: /Tools01.bak Recid = 6 stamp = 452181160

Channel ORA_DISK_1: Reproduced Data File 6

Output file name = E: /Users01.bak recid = 7 stamp = 452181167

Channel ORA_DISK_1: Reproduced Data File 7

Output file name = E: /XDB01.BAK RECID = 8 stamp = 452181179

Channel ORA_DISK_1: Reproduced Data File 9

Output file name = E: /RMAN01.BAK Recid = 9 stamp = 452181193

Channel ORA_DISK_1: Copy the current control file

Output file name = E: /Control.bak

Complete COPY 26- January -02

Rman>

In 9i, RMAN has three command mode

1) Single command (Standalone Commands)

· The Standalone Commands command cannot appear in the run subcommand, only running under the RMAN command prompt.

· The following commands belong to StandalOne Commands:

N connectionct

N Configure

n create Catalog, Drop Catalog, Upgrade Catalog

N Create Script, Delete Script, Replace Script

N list

N report

2) Job Commands

· The Job Commands command must appear in the backup set using the Run command. The Run command defines a command execution unit. Oracle will release all server-side resources when the last command is executed.

· The following commands belong to Job Commands: N Allocate Channel

N switch

3) Special Commands (Command Excetions)

• These commands can be used as Standalone Commands, or as Job Commands. Placed in the run command. These commands typically allocate CHANEL, no matter what, if you want to manually assign Chanel, you can only be used in the run command.

N Backup

N BlockRecover

n copy

N restore

N Recover

N validate

RMAN command execution method

1) Interactive mode:

The way the RMAN backup command is executed in the RMAN prompt. Such as:

RMAN> Backup Database;

2) Batch mode (Batch Mode)

Write the RMAN backup command you want to use to a script, and perform this script in the command line. ,Such as;

C: /> Rman Target / Catalog RMAN / TMAN @ TEST CMDFILE E: /TEST_B1.RCV log E: /TESTB1_LOG.F

3) Use storage scripts (Stored Scripts)

The storage script is stored in the recovery directory, we can use the storage script for backup, recovery testing.

转载请注明原文地址:https://www.9cbs.com/read-11602.html

New Post(0)