Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to master the composition, configuration and detection of RMAN

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to master the composition, configuration and detection of RMAN". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to master the composition, configuration and detection of RMAN".

RMAN components:

1. RMAN executes the program, that is, the RMAN command.

2. Server session: the process on the server is really used for work.

3. Target database: the database you want to back up

4. RMAN Repository: the source data of RMAN, which can be stored in control file or separately in the database. A database used to store backup and recovery information is not recommended to be created on the target database. The recovery directory can be used to manage multiple target databases at the same time, store more backup information, and store backup scripts. If you do not use the recovery directory, you can use control files instead of the recovery directory. Oracle 9i can use control files to replace the recovery directory to a large extent because of the function of controlling the automatic backup of files.

5. Channel: a channel used to connect a database to a backup storage medium.

6. Media Management Library: generally refers to the driver given by the manufacturer of the storage medium. We usually store it on disk.

Note: rman users can not back up online redo log files, parameter file, password file, personal is not sure!

Establishment of RMAN catalog:

It is best to create another database instead of using the original target database. Then, create the following on that new database: so use control file to save metadata information, but consider using the reply directory when there are multiple databases that need to be backed up.

1) establish the tablespace used by the recovery directory:

Create tablespace rman_ts datafile'/ xxx/rman_ts.dbf' size 20m; (just create it in the target database)

2) create a rman user in the catalog database and authorize:

Create user rman identified by rman default tablespace rman_ts temporary tablespace temp quota unlimited on rman_ts

Grant connect, resource, recovery_catalog_ownerto rman;-authorization

3) create a recovery directory in the catalog database

Rman catalog rman/rman (connect to the catalog database at the operating system prompt)

Create catalog tablespace rman_ts;-create a recovery directory

4) register the target database. A recovery directory can register multiple target databases. The command to register the target database is:

Rman catalog rman/rman target sys/sys

Register database

RMAN connection

Connecting to the target database refers to the connection established between the RMAN and the target database. RMAN can connect to the target data either without a recovery directory or with a recovery directory.

In addition, it is not recommended to use the sys user to connect to the target database (target). You should create another user and give that user sysdba permission.

1. No recovery directory

(1) C:\ > rman target /

(2) C:\ > rman target sys/password nocatalog

2. There are recovery directories

If there is a recovery directory, in fact, to put it bluntly, it is to establish two links for the target database and the directory database respectively.

(1) enter rman first to enter the rman command environment

-- connect to the target database: connect target sys/sys

-- Connect to the recovery database: connect catalog rman/rman

(2) directly connect together:

Rman target sys/sys catalog rman/rman

When there is a recovery directory in rman, it is necessary to register the database after connecting to the target database, that is, the control files in the target database are transferred to the recovery directory, and only one target database can be registered in the same recovery directory.

Register database

3. The difference between the two: whether there is a recovery directory or not.

(1) nocatalog uses control file as catalog. Every backup has to write a lot of backup information into the control file, and there will be more and more backup information in the control file. If you are catalog, you must first create a directory backup database and establish a recovery directory.

(2) when using rman nocatalog to restore, the database must be in the "mount" state. The prerequisite for Oracle startup mount is that control must exist. Therefore, you must restore controlfile before restoring datafile. When using rman catalog mode, you can startup nomount and then restore controlfile;, but when using rman nocatalog, you must first restore controlfile as a file.

(3) recovery steps are different.

Rman nocatalog recovery:

1) establish an oracle running environment (including init or sp files)

2) restore controlfile to the location specified by the init file (copy, paste)

3) startup mount

4) rman, restore datafile

5) alter database open resetlogs

Rman catalog recovery:

1) establish an oracle running environment (including init or sp files)

2) rman, restore controfile

3) alter database mount

4) rman, restore datafile

5) alter database open resetlogs

RMAN configuration:

I. Channel and channel allocation

1. The concept of channel

A channel represents a data stream to the device (disk or tape) and generates a corresponding server session (server session) on the target database or secondary database instance.

Multiple channels generate multiple server sessions, which will complete backup, restore and restore operations, etc.

The channel is divided into disk channel (disk channel) for backup or restore to disk and tape channel (SBT) for backup and restore to tape.

Channels must be assigned before backing up and restoring the database

The ALLOCATE CHANNEL command starts a server process in the target database, and you must define the Icano type that the server process uses to perform backup or restore operations.

In fact, channel is used to control the behavior of backup and restore.

The role of the channel control command:

Control the OS resources used by RMAN

Affect parallelism

Specify the limit value of the bandwidth of the Icano (set the limit read rate parameter)

Define limits on the size of backup slices (set limit kbytes)

Specify the limit value for the currently open file (set limit maxopenfiles)

two。 Automatically assign channels

You can use the following command to automatically assign channels, and once RMAN sets the following parameters, RMAN automatically allocates channels according to these configurations

CONFIGURE DEVICE TYPE... PARALLELISM

CONFIGURE DEFAULT DEVICE TYPE

CONFIGURE CHANNEL

Assuming that backup datafile 1 is executed at the RMAN prompt, RMAN assigns a channel to it using preconfigured channel parameters

When these commands backup, restore, delete run in non-run blocks, channels are automatically assigned according to the values set by the configure command.

However, the above command requires manual channel assignment in the run block.

CONFIGURE DEFAULT DEVICE TYPE TO sbt;-default is disk

CONFIGURE DEVICE TYPE DISK PARALLELISM 3;-- configure parallelism for automatically assigned channels, affecting the performance of Icano, etc.

-- configure automatic channel preferences

CONFIGURE CHANNEL DEVICE TYPE DISK

FORMAT ='/ BACKUP/RMAN/%U'

CONFIGURE CHANNEL DEVICE TYPE DISK

MAXPIECESIZE 4G

3. Manually assign channels

Commands such as BACKUP,COPY,RESTORE,RECOVER need to assign at least one channel

Assigning a channel starts a service process on the server where the target database is located, and the assigned channel actually specifies the degree of concurrency

You can specify backup to different media, and you can specify read and write speed when manual channels

RMAN > RUN {

2 > ALLOCATE CHANNEL ch2 TYPE disk

3 > BACKUP DATAFILE 1, 2, 4

4 > FORMAT'/ u01According to the following example, the following example assigns multiple channels and uses different channels for different data files to complete the backup

RMAN > RUN {

2 > allocate channel ch2 device type disk

3 > allocate channel ch3 device type disk

4 > allocate channel ch4 device type disk

5 > backup

6 > incremental level 0

7 > (datafile 1 channel ch2 4)

8 > (datafile 2 and 3 channel ch3)

9 > (datafile 5, 6 channel ch4)

10 > alter system archive log current;}

The ALLOCATE CHANNEL command starts a server process in the target database, and you must define the Icano type that the server process uses to perform backup or restore operations.

In fact, channel is used to control the behavior of backup and restore.

4. Channel configuration option

Connect: is an Oracle Net connection string. Generally not suitable for single instance environment

Format: determine the path and file name for the backup slice or image copy created by the channel

Duration: controls the total amount of time for the job, specified in hours and minutes

Maxopenfiles: this option limits the number of input files that RMAN can open at a time. The default is

Maxpiecesize: limits the size of a backup slice split into a backup set in bytes (default), k, m, g

Parms: can be used to set any variable required by the sbt_type channel

Filesperset: the number of files that can be contained in the backup set

Backup set: a collection that consists of one or more physical files and is a logical unit.

Backup piece: is a true output file, limited by a single operating system file, that is, the parameter maxpiecesize.

Connection rman test:

Rman target / nocatalog-Log in with operating system privileges

Rman target sys/oracle@trgt-remote login

Show default device type;-View the default backup media, which is disk by default

Configure default device type clear;-restore the backup media to the default disk.

Supplement: filesperset parameters:

Filesperset is the maximum number of files contained in each backup set and has nothing to do with channel.

Allocate channel provides backup concurrency. If the average number of files is crosscheck backupset;-- check the backup set

RMAN > crosscheck copy;-- verify the mirror copy

RMAN > crosscheck backup of controlfile;-- check the backup control file

RMAN > crosscheck backup of archivelog all;-- verify the archive logs of all backups

RMAN > crosscheck backup of datafile 1, 2;-- check datafile 1, 2

RMAN > crosscheck backup of tablespace sysaux,system;-- check tablespace sysaux,system

RMAN > crosscheck backup completed between'13, and, 10, and, 23, 10, 10, 23, 10, 10, 10, 10, 13, 10, and, 10, and, 10,-- check the time period. The format of the time period is set by NLS_DATE_FORMAT.

RMAN > crosscheck backupset 1067, 1068;-- verify the specified backup set

Backup common commands

1. Set backup marker

Backup database tag='full_bak1'; note: each tag must be unique, and the same tag can be used for multiple backups to restore only the latest backup.

two。 Set the backup set size (all results of a backup are one backup set, pay attention to the backup set size)

Backup database maxsetsize=100m tag='datafile1'

Note: maxsetsize limits the size of the backup set. So it must be larger than the size of the total data file in the database, otherwise an error will be reported.

RMAN-06183: datafile or datafile copy larger than MAXSETSIZE: file# 1 / data/oradata/system01.dbf

3. Set the backup slice size (tape or file system limit)

Run {

Allocate channel C1 type disk maxpicecsize 100m format'/ data/backup/full_0_%U_%T'

Backup database tag='full_0'

Release channel c1

}

You can set the size of each backup slice in the allocate clause to reach the tape or system limit.

You can also set the backup slice size in configure.

Configure channel device type disk maxpiecesize 100 m

Configure channel device type disk clear

4. Save strategy for backup set

Backup database keep forever;-permanently retain backup files, which requires support for restoring directories

Backup database keep until time='sysdate+30';-keep the backup for 30 days

5. Override the configure exclude command

Backup databas noexclude keep forever tag='test backup'

6. Check for database errors

Backup validate database; uses rman to scan the database for physical and logical errors, but does not actually perform backup operations.

Use RMAN to scan the database for physical / logical errors and do not perform an actual backup.

7. Skip offline, inaccessible or read-only files

Backup database skip readonly

Backup database skip offline

Backup database skip inaccessible

Backup database ship readonly skip offline ship inaccessible

8. Forced backup

Backup database force

9. Back up data files based on the last backup time

1 > back up only the new data files you added

Backup database not backed up

2 > back up data files that are not backed up "within a limited time period"

Backup database not backed up since time='sysdate-2'

10. Check for logic errors during backup operation

Backup check logical database

Backup validate check logical database

11. Make a backup copy

Backup database copies=2

twelve。 Backup control file

Backup database device type disk includ current controlfile

Database initialization parameters

Control_file_record_keep_time: specifies the minimum number of days to retain RMAN information in the control file before it is overwritten

Db_recovery_file_dest: if you back up RMAN here, you need to set this parameter

Db_recovery_file_dest_size: if you back up RMAN here, you need to set this parameter

Environmental variable parameters

Nls_date_format: setting date

Nls_lang: setting environment variables affects restore, recover, report and other commands

Format format string:

The various substitution variables that can be used when using the FORMAT parameter are shown below (note case):

The activation ID of the a:Oracle database is RESETLOG_ID.

% c: the number of copies of the backup segment (numbered from 1, up to 256).

D:Oracle database name.

% D: day in the current time, formatted as DD.

% e: archive serial number.

% f: absolute file number.

% F: unique name determined based on DBID+ time, in the form of c-IIIIIIIIII-YYYYMMDD-QQ, where IIIIIIIIII is the DBID,YYYYMMDD of the database is the date, and QQ is a sequence of 1x 256.

% h: archive log thread number.

DBID of the I:Oracle database.

% M: month in the current time, formatted as MM.

% N: tablespace name.

% n: database name, and will be populated with x characters on the right to keep it at 8 in length. For example, if the database name is JSSBOOK, the generated name is JSSBOOKx.

% p: the number of the backup segment in the backup set, starting at 1.

% s: backup set number.

% t: backup set timestamp.

% T: the year, month and day format of the current time (YYYYMMDD).

% u: is an 8-character name composed of backup set number and establishment time compression. With% u, you can generate a unique name for each backup set.

% U: the default is the shorthand form of% u_%p_%c, which allows you to generate a unique name for each backup fragment (that is, disk file). This is the most commonly used naming method, and different rules are generated when performing different backup operations, as shown below:

% U=%u_%p_%c when generating backup fragments

% U=data-D-%d_id-%I_TS-%N_FNO-%f_%u when generating data file mirror replication

% U=arch-D_%d-id-%I_S-%e_T-%h_A-%a_%u when generating archive image replication

% U=cf-D_%d-id-%I_%u when generating control file mirror replication.

% Y: the year in the current time, formatted as YYYY.

Note: if the FORMAT option is not specified in the BACKUP command, RMAN uses% U to name the backup fragment by default.

Commonly used RMAN settin

1) set auto backup control file, CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO'% F'

2) set redundancy to 5, CONFIGURE RETENTION POLICY TO REDUNDANCY 5, or CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS

3) parallelism is set to 2, but it seems that this must be an enterprise version of oracle to CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET

Personal favorite backup format:

Complete: full_%d_%U

Datafile: df_%d_%U

Tablespace: tb_%d_%U

Thank you for your reading, the above is the content of "how to master the composition, configuration and detection of RMAN". After the study of this article, I believe you have a deeper understanding of how to master the composition, configuration and detection of RMAN, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report