Oracle RAC 利用RMAN自動排程備份

尛樣兒發表於2010-04-05
1.    環境
[root@rhel1 bin]# cat /etc/issue
Red Hat Enterprise Linux Server release 5.4 (Tikanga)

2.    伺服器
rhel1:172.168.6.111
rhel2:172.168.6.112

3.    配置NFS
3.1.    rhel1,rhel2執行
[root@rhel1 bin]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost

172.168.6.111 rhel1
172.168.6.112 rhel2

10.0.0.111 rhel1-priv
10.0.0.112 rhel2-priv

172.168.6.121 rhel1-vip
172.168.6.122 rhel2-vip

10.0.0.111 nas1
10.0.0.112 nas2

3.2.    rhel1,rhel2執行
[root@rhel1 bin]# cat /etc/exports
/u02 *(rw,sync,no_wdelay,insecure_locks,no_root_squash)

3.3.    rhel1,rhel2執行
[root@rhel1 bin]# cat /etc/fstab
nas1:/u02       /u01/backup01   nfs     rw 0  0
nas2:/u02       /u01/backup02   nfs     rw 0  0

3.4.    rhel1,rhel2執行
[root@rhel1 bin]# mount
nas1:/u02 on /u01/backup01 type nfs (rw,addr=10.0.0.111)
nas2:/u02 on /u01/backup02 type nfs (rw,addr=10.0.0.112)

4.    RMAN配置
[root@rhel1 bin]# su - oracle
[oracle@rhel1 ~]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Wed Apr 7 04:04:59 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database: RACTEST (DBID=3230313564)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 2;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/backup01/rman/RACTEST_%s_%p_%T.RMAN',   '/u01/backup02/rman/RACTEST_%s_%p_%T.RMAN';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/db_1/dbs/snapcf_ractest1.f'; # default

5.    自動備份指令碼
5.1.    level 0級別備份:
5.1.1.    
[oracle@rhel1 u01]$ cat rmanBackupL0
run{
crosscheck archivelog all;
sql 'alter system archive log thread 1 current';
sql 'alter system archive log thread 2 current';
backup as compressed backupset incremental level 0 database;
delete noprompt archivelog all;
sql 'alter system archive log thread 1 current';
sql 'alter system archive log thread 2 current';

crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
delete noprompt backup of archivelog all;
backup current controlfile;
sql 'alter database backup controlfile to trace';
}
5.1.2.    
[oracle@rhel1 u01]$ cat rmanBackupL0.sh
#!/bin/sh
export ORACLE_HOME=/u01/app/oracle/db_1
export ORACLE_SID=ractest1
/u01/app/oracle/db_1/bin/rman target / nocatalog cmdfile=/u01/rmanBackupL0 log=/u01/rmanBackupL0.log append
5.1.3.    
[oracle@rhel1 u01]$ crontab -l
*/30 * * * * sh /u01/rmanBackupL0.sh

5.2.    level 1級備份:
5.2.1.    
[oracle@rhel1 u01]$ cat rmanBackupL1
run{
crosscheck archivelog all;
sql 'alter system archive log thread 1 current';
sql 'alter system archive log thread 2 current';
backup as compressed backupset incremental level 1 database;
delete noprompt archivelog all;
sql 'alter system archive log thread 1 current';
sql 'alter system archive log thread 2 current';

crosscheck backup;
delete noprompt backup of archivelog all;
backup current controlfile;
sql 'alter database backup controlfile to trace';
}
5.2.2.    
[oracle@rhel1 u01]$ cat rmanBackupL1.sh
#!/bin/sh
export ORACLE_HOME=/u01/app/oracle/db_1
export ORACLE_SID=ractest1
/u01/app/oracle/db_1/bin/rman target / nocatalog cmdfile=/u01/rmanBackupL1 log=/u01/rmanBackupL1.log append
5.2.3.    
[oracle@rhel1 u01]$ crontab -l
*/30 * * * * sh /u01/rmanBackupL0.sh
*/10 * * * * sh /u01/rmanBackupL1.sh

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23135684/viewspace-631346/,如需轉載,請註明出處,否則將追究法律責任。

相關文章