1、切换服务器归档模式,如果已经是归档模式可跳过此步:
%sqlplus /nolog (启动sqlplus)
SQL> conn / as sysdba (以DBA身份连接数据库)
SQL> shutdown immediate; (立即关闭数据库)
SQL> startup mount (启动实例并加载数据库,但不打开)
SQL> alter database archivelog; (更改数据库为归档模式)
SQL> alter database open; (打开数据库)
SQL> alter system archive log start; (启用自动归档)
SQL> exit (退出)
2、建立recovery catalog db数据库的相关内容
a,建好catalog库并建catalog表空间
SQL> create tablespace tbs_rman datafile ‘d:/Oracle/product/10.1.0/oradata/wind/rman.dbf’ size 200M;
b,建好管理catalog的rman的user,并给recovery_catalog_owner权限:
SQL>create user rmanuser identified by rmanuser
temporary tablespace TEMP
default tablespace tbs_rman
quota unlimited on tbs_rman;
c,分配权限
SQL> grant recovery_catalog_owner to rmanuser;
3.创建 catalog
#有些时候直接使用rman linux会认为是他本身的命令,所以加入全路径比较保险
>$ORACLE_HOME/bin/rman
RMAN> connect catalog rmanuser/rmanuser@rman_db;
RMAN> create catalog; ##这句就是把 userrman 的默认表空间分配给 catalog;
RMAN> create catalog tablespace tbs_catalog;##如果user_rman有默认表空间那么就不需要这句
##如果想删除catalog可以使用两边 RMAN>drop catalog; RMAN>drop catalog;
将目标数据库注册到catalog
RMAN> register database;
4.配置NFS
查看nfs服务是否启动 service nfs status
启动nfs service nfs start
vim /etc/exports
/oracle/rmanbak 10.1.50.81(rw,no_root_squash)
在target服务器上挂载远程备份目录
关于备份路径的挂载点是有要求的,而且参数上也有要求如下,,挂载在 $ORACLE_HOME目录及其父目录下
mount -o rw,bg,intr,hard,timeo=600,wsize=32768,rsize=32768 -t nfs 10.1.50.80:/oracle/rmanbak /home/oracle/rmanbak
5.开始备份
做一个全库备份
run{
allocate channel d1 type disk;
backup as compressed backupset
format=’/home/oracle/rmanbak/full_%d_%u_%s_%p’
tag=’fullbak’
channel=d1
database plus archivelog delete input;
release channel d1;
}
增量备份 0
run{
allocate channel d1 device type disk;
backup as compressed backupset
incremental level=0
format=’/home/oracle/rmanbak/inc0_%d_%u_%s_%p’
tag=’inc0′
channel=d1
database plus archivelog delete input;
release channel d1;
}
增量备份 1
run{
allocate channel d1 device type disk;
backup as compressed backupset
incremental level=1
format=’/home/oracle/rmanbak/inc1_%d_%u_%s_%p’
tag=’inc1′
channel=d1
database plus archivelog delete input;
release channel d1;
}
表空间
run{
allocate channel d1 device type disk;
backup as compressed backupset
format=’/home/oracle/rmanbak/tbs_%d_%u_%s_%p’
tag=’tbs’
channel=d1
tablespace users;
release channel d1;
}
//
///
crontab
//delete expired copy
//list backup by files;
//umount -l /mnt/rmanbak
//crosscheck backupset
//validate backupset
//delete expixed backupset
//delete backupset of database device type disk completed between ‘sysdate-1’ and ‘sysdate+1
//delete noprompt obsolete recovery window of 0 days
//
set limit channel ” readrate
set limit channel ” kbytes