Rman 通过NSF服务 异机实施步骤
         (案例测试)
 
 
 

    Oracle版本:
11.2G
操作系统:
Linux 5.4
版本号:
1.0初稿
制订日期:
2012-01-17
制定部门:
 

 
目录
 
 
 
 
 
 
 
 
 
 
一、    测试环境(VMware Workstation 8.0)

序号
项目
主机A
主机B
1
操作系统版本
Linux Rhel 5.4
Linux Rhel 5.4
2
Oracle版本
Oracle 11.2G
Oracle 11.2G
3
IP地址
192.168.44.128
192.168.44.129
4
主机名
dbp
dbstby
5
nsf
NFS 客户端
NFS 服务端

 
二、   NFS服务配置
1.     
2.     
2.1.    NFS 服务端设置
[root@dbstby ~]# cd /
[root@dbstby /]# mkdir /sharetest
[root@dbstby /]# chown -R oracle:oinstall /sharetest/
[root@dbstby /]# chmod -R 777 /sharetest/
[root@dbstby /]# vi /etc/exports
/sharetest 192.168.44.128/24(rw,sync,no_root_squash)
[root@dbstby /]# service portmap start
[root@dbstby /]# service nfs start
*** 可使用
[root@dbstby /]#  chkconfig --level 345 nfs on 自动运行
 
2.2.    NFS 客户端设置
建立测挂载点测试目录
[root@dbp mnt]# mkdir sharetest
分配测试权限为所有用户都可以读写
[root@dbp mnt]# chmod -R 777 sharetest/
修改目录的所属用户及用户组
[root@dbp mnt]# chown -R oracle:oinstall sharetest/
手工挂载
[root@dbp mnt]# mount -t nfs 192.168.44.129:/sharetest /mnt/sharetest
进入目录手工创建文件进行测试,如果保存时没有错误提示信息,表示参数配置成功
[root@dbp mnt]# cd sharetest/
[root@dbp sharetest]# vi aa.txt
如果需要每次随机启动时挂载需要在/etc/fstab中增加以下内容
[root@dbp sharetest]# vi /etc/fstab
加入以下内容然后保存
192.168.44.129:/sharetest /mnt/sharetest   nfs     defaults      0   0
[root@dbp sharetest]# exportfs -ra 刷新
 
三、   nsf 客户端Rman 配置
[root@dbp sharetest]# su -l oracle
[oracle@dbp ~]$ rman target /
RMAN> show all;
显示所有配置参数
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name DBP are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/store1/ctl_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT   '/store/backup_%U.bak';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/store1/backup_%U.bak';
CONFIGURE MAXSETSIZE TO 10 G;
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'HIGH' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE;
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/oracle/product/10.2.0/db/dbs/snapcf_orcl.f'; # default
 
设置开启优化需要开启
RMAN> CONFIGURE BACKUP OPTIMIZATION on;
 
new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored
 
RMan> configure device type disk parallelism 2;
设置备份的并行级别,通道数
 
RMAN> configure channel 1 device type disk fomat '/mnt/sharetest/backup_%s_%p_%t.bak';
 
配置通道的format保存格式有几个channel 就需要指定几个format 本例子是使用两个(一个用于备份控制文件的格式,其它一个备份数据文件的格式)如果不在此处指定format也可以直接在备份脚本写format格式
RMAN> CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/mnt/sharetest/level_0_%d_%t_%U.dbf';
 
old RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/mnt/sharetest/level_0_%d_%t_%U.dbf';
new RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT   '/mnt/sharetest/level_0_%d_%t_%U.dbf';
new RMAN configuration parameters are successfully stored
 
脚本指定数据保存位位置及格式
RMAN>  backup incremental level 0 tag='db0' format='/mnt/sharetest/level_0_%d_%t_%U.dbf' database;
 
Starting backup at 16-JAN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=47 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=40 device type=DISK
channel ORA_DISK_1: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/opt/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00003 name=/opt/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/opt/oracle/oradata/tbuser1.dbf
input datafile file number=00004 name=/opt/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 16-JAN-12
channel ORA_DISK_2: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00001 name=/opt/oracle/oradata/orcl/system01.dbf
input datafile file number=00006 name=/opt/oracle/oradata/tbuser2.dbf
channel ORA_DISK_2: starting piece 1 at 16-JAN-12
channel ORA_DISK_1: finished piece 1 at 16-JAN-12
piece handle=/mnt/sharetest/level_0_ORCL_772759291_29n0unnr_1_1.dbf tag=DB0 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:03:30
channel ORA_DISK_1: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/opt/oracle/oradata/cus_ts.dbf
channel ORA_DISK_1: starting piece 1 at 16-JAN-12
channel ORA_DISK_1: finished piece 1 at 16-JAN-12
四、   rman 备份还原测试
进行oracle 所在的数据目录删除文件序号为6的tbuser2.dbf
RMAN> report schema;
 
Report of database schema for database with db_unique_name DBP
 
List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    690      SYSTEM               ***     /opt/oracle/oradata/orcl/system01.dbf
2    570      SYSAUX               ***     /opt/oracle/oradata/orcl/sysaux01.dbf
3    95       UNDOTBS1             ***     /opt/oracle/oradata/orcl/undotbs01.dbf
4    37       USERS                ***     /opt/oracle/oradata/orcl/users01.dbf
5    0        TB1                  ***     /opt/oracle/oradata/tbuser1.dbf
6    50       TB2                  ***     /opt/oracle/oradata/tbuser2.dbf
7    20       CUS_TS01             ***     /opt/oracle/oradata/cus_ts.dbf
 
RMAN> shutdown abort;
Oracle instance shut down
RMAN> startup mount;
connected to target database (not started)
Oracle instance started
database mounted
 
Total System Global Area     146472960 bytes
 
Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   2531328 bytes
 
RMAN> sql ' alter database datafile 6 offline';
 
sql statement: alter database datafile 6 offline
 
RMAN> restore datafile 6;
 
Starting restore at 17-JAN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=21 device type=DISK
 
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00006 to /opt/oracle/oradata/tbuser2.dbf
channel ORA_DISK_1: reading from backup piece /mnt/sharetest/level_0_ORCL_772759291_2an0unnr_1_1.dbf
channel ORA_DISK_1: piece handle=/mnt/sharetest/level_0_ORCL_772759291_2an0unnr_1_1.dbf tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 17-JAN-12
 
RMAN> recover datafile 6;
 
Starting recover at 17-JAN-12
using channel ORA_DISK_1
using channel ORA_DISK_2
 
starting media recovery
media recovery complete, elapsed time: 00:00:00
 
Finished recover at 17-JAN-12
 
RMAN> sql 'alter database datafile 6 online';
sql statement: alter database datafile 6 online
RMAN> alter database open;
database opened
 
RMAN> sql 'select * from dual';
sql statement: select * from dual
 
从挂载点中仍然可以恢复删除的数据文件
 
 
 
 
 
5.1.    NFS 主机网络断线(备份过程中)
SQL> select t.start_time,t.end_time,t.status from v$rman_backup_job_details t where t.start_time >to_date('2012-01-16 00:00:00','yyyy-mm-dd hh24:mi:ss');
 
 
START_TIME   END_TIME    STATUS
------------ ------------ -----------------------
17-JAN-12    17-JAN-12  COMPLETED WITH WARNINGS
16-JAN-12    16-JAN-12  COMPLETED WITH WARNINGS
17-JAN-12    17-JAN-12  COMPLETED WITH WARNINGS
 
在备份过程人为的将NFS服务端网卡禁用掉10秒钟后,并没有发现Rman因网络故障而停下来,而是完成备份计划从以上的招行状态视图。而with warnings 是因为本机的归档日志 deletion policy(删除策略)设置有问题!
5.2.    NFS主机重启
如果NFS正在传送数据时,nfs因异常原来停止,如重启后,NFS客户端挂载时出现一段长时间的无反应,但最终还是提示数据备份完毕。
 
dataGuard主机上进行数据备份,主库不参与数据备份。