Oracle 11g R2 RAC Rman Backup Script Example

Source: Internet
Author: User
Tags db2 log log

First, switch the RAC to archive mode 1. Modify the archive mode of the database, usually in the installation of the RAC will be configured to archive and use the Flash back zone, has been configured in the following way can be skipped.

Sql> alter system set CLUSTER_DATABASE=FALSE scope=spfile sid= ' * ';

2. Close all instances (shutdown on both sides)

sql> shutdown Immediate

Or close all instances directly
$ srvctl Stop database-d ORCL

3. On either instance, boot the database to mount state and modify the database archive mode

sql> startup Mount;
sql> ALTER DATABASE Archivelog;
Sql> alter system set CLUSTER_DATABASE=TRUE scope=spfile sid= ' * ';
sql> shutdown immediate;

4. Start all instances

$ srvctl Start database-d ORCL

5. Verify that the archive mode is turned on

sql> archive log list;


Second, configure the NFS shared directory for storing Rman backup Data 1. Configure the NFS service to ensure that both sides of the backup directory are accessible, testing here, and using node 1 to provide services for NFS.

Node1 Configuration:

# Cat/etc/exports

#说明节点二同时也挂载节点的RMAN备份目录.
/data/rman_bak DB2 (Rw,no_root_squash)


2. Node2 Configuration, Node 2 is mounted as an NFS client, and the two directories remain consistent.

# manual Mount
# mount-t NFS Db1:/data/rman_bak/data/rman_bak

# Configure boot Auto mount
# Cat/etc/fstab
Db1:/data/rman_bak/data/rman_bak NFS Defaults 0 0


Third, Oracle 11g RAC database parameter modification 1. To modify the save backup time for a control file

Description: Default 7 days, modify as appropriate.

Sql> show parameter control;
Sql> alter system set CONTROL_FILE_RECORD_KEEP_TIME=40 Scope=both;


2. RMAN Configuration Parameters

Turn on automatic backup of control files, and automatically back up control files and spfile files when database backup or data files (such as adding data files) are modified.
Rman> Configure Controlfile autobackup on;
Rman> Configure retention Policy to recovery window of the days;


3. Backup Policy

Make sure the database is running in archive mode, once a day to the database, you can determine the time to store backups based on the disk space on the backup server and the custom policy.
Level 0 backup per Sunday
Every Monday, two, three, four, five, six level 1 backup


Iv. Rman Backup script configuration 1. Prepare the Catalog

# su–oracle

Description: You can create the relevant directory according to the actual situation, note the directory permissions.
$ mkdir-p/u01/app/oracle/rman_bak/scripts
$ mkdir-p/data/rman_bak/data
$ mkdir-p/data/rman_bak/logs

Description: If you use ASM for backup of RAC, backup is done on only one node. This means that the backup is stored on one of the nodes, and other nodes can be restored if they are using NFS.


2. Create Script Content

$ vi/u01/app/oracle/rman_bak/scripts/rman_bak.sh
$ chmod u+x/u01/app/oracle/rman_bak/scripts/rman_bak.sh


3. Add a Scheduled task

$ crontab-e
# RMAN
XX 1 * * 0/u01/app/oracle/rman_bak/scripts/rman_bak.sh 0
XX 1 * * 1,2,3,4,5,6/u01/app/oracle/rman_bak/scripts/rman_bak.sh 1


4. Manual Test Channel

Manually add DB1,DB2 Local Service name configuration, 11g RAC default only scan IP server, local service name needs to be added manually as follows:

# su-oracle
$ vi/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = scan-cluster) (PORT = 1521))
(Connect_data =
(SERVER = dedicated)
(service_name = ORCL)
)
)

ORCL1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = DB1-VIP) (PORT = 1521))
(Connect_data =
(SERVER = dedicated)
(service_name = ORCL)
(instance_name = ORCL1)
)
)

ORCL2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = DB2-VIP) (PORT = 1521))
(Connect_data =
(SERVER = dedicated)
(service_name = ORCL)
(instance_name = Orcl2)
)
)


Manual Test Channel

Rman Target/

Configure Channel 1 device type disk connect ' sys/[email protected] ';
Configure Channel 2 device type disk connect ' sys/[email protected] ';


4. Script Step Programme

$ vi/u01/app/oracle/rman_bak/scripts/rman_bak.sh

#!/bin/bash
Export Oracle_base=/u01/app/oracle
Export Oracle_home=/u01/app/oracle/product/11.2.0/db_1
Export ORACLE_SID=ORCL1
Export Nls_lang=american_america. Zhs16gbk
Export path= $ORACLE _home/bin: $PATH
[Email protected]
Date= ' Date +%w '
date_2= ' Date +%y%m%d '
Backup_path= "/data/rman_bak"
bin= $ORACLE _home/bin

if [$#! = 1]; Then
echo "usage:rman_bak.sh N
where n is the Rman backup level (only 0,1 is permitted). "
Exit 1
Fi

If [email protected]-ne 0-a [email protected]-ne 1]; Then
echo "usage:rman_bak.sh N
where n is the Rman backup level (only 0,1 is permitted). "
Exit 2
Fi

if [[$LEVEL = 0]]; Then
$BIN/rman log $BACKUP _path/logs/level. $ORACLE _sid. $LEVEL. $DATE _2.log <<eof

Connect target/;  
run{   
Allocate channel C1 device type disk connect  ' sys/[email  Protected] ';   &NBSP;
Allocate channel C2 device type Disk connect  ' sys/[email protected] ';    
Crosscheck backupset of Archivelog all;    
Backup archivelog  all format ' $BACKUP _path/data/archlog.%d.level. $LEVEL.%u_%t ' Delete all input ;    
Delete noprompt expired backupset of Archivelog all;    
Release channel C1;    release Channel C2;    
}

run{
Allocate channel C1 device type disk connect ' sys/[email protected] ';
Allocate channel C2 device type disk connect ' sys/[email protected] ';
Crosscheck backupset of database;
Backup incremental level $LEVEL database format ' $BACKUP _path/data/data.%d.level. $LEVEL.%u_%t ';
Backup SPFile tag= ' spfile ' format ' $BACKUP _path/data/spfile_%u_%t ';
Backup current controlfile tag= ' control ' format= ' $BACKUP _path/data/control_%u_%t ';
Delete noprompt expired backupset of database;
Delete NoPrompt obsolete;
Release channel C1;
Release channel C2;
}
Exit
Eof

Else

$BIN/rman log $BACKUP _path/logs/level. $ORACLE _sid. $LEVEL. $DATE _2.log <<eof

Connect target/;  
run{   
Allocate channel C1 device type disk connect  ' sys/[email  Protected] ';   &NBSP;
Allocate channel C2 device type Disk connect  ' sys/[email protected] ';    
Crosscheck backupset of Archivelog all;    
Backup archivelog all format ' $BACKUP _path/data/archlog.%d.level. $LEVEL.%u_%t ' Delete all input;    
Delete noprompt expired backupset of Archivelog all;    
Release channel C1;    release Channel C2;    
}

run{
Allocate channel C1 device type disk connect ' sys/[email protected] ';
Allocate channel C2 device type disk connect ' sys/[email protected] ';
Crosscheck backupset of database;
Backup incremental level $LEVEL database format ' $BACKUP _path/data/data.%d.level. $LEVEL.%u_%t ';
Backup SPFile tag= ' spfile ' format ' $BACKUP _path/data/spfile_%u_%t ';
Backup current controlfile tag= ' control ' format= ' $BACKUP _path/data/control_%u_%t ';
Delete noprompt expired backupset of database;
Delete NoPrompt obsolete;
Release channel C1;
Release channel C2;
}

Exit
Eof

Fi


5. Perform the test manually

$/u01/app/oracle/rman_bak/scripts/rman_bak.sh 0

Test attention to detail:

1) Observe the Rman log log for any exception errors.
2) Observe if the Archivelog is backed up and deleted.

This article is from the "Koumm Linux Technology blog" blog, be sure to keep this source http://koumm.blog.51cto.com/703525/1728612

Oracle 11g R2 RAC Rman Backup Script Example

Related Article

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.