Oracle RMAN测试

1.catalog DB,建立恢复目录<可选>:
恢复目录就是rman备份信息的索引,恢复数据库的依据,当然这些信息也可以放在control文件中,control文件存储的信息有限,可以在pfile里面设置CONTROL_FILE_RECORD_KEEP_TIME来指定control文件的保存日期,专门的catalog将会保存比较长的备份信息。
SQLPlus指令:
create tablespace USER_TOOLS datafile '/oracle/oradata/compard/user_tools.dbf' size 20M;
create user rman identified by rman default tablespace USER_TOOLS temporary tablespace temp
quota unlimited on USER_TOOLS;
grant recovery_catalog_owner to rman;
grant connect, resource to rman ;
rman指令:
rman catalog rman/rman;
create catalog tablespace USER_TOOLS;
2.target DB,注册/注销target DB.
先配置一个tnsname,名字叫rman_catalog,指向步骤1的catalog DB。
rman指令:
rman catalog rman/rman@rman_catalog
connect target /
register database;
如果目标数据库的control文件有变化,则需要
resync catalog;
/*************unregister DB*********************/
先取得db_id,db_id在rman登陆的时候会显示,或者在target DB的v$database中查寻.
用SQLPlus登陆rman DB,
使用select * from rman.db得到db_key,然后执行下列procedure注销:
execute dbms_rcvcat.unregisterdatabase(<DB_KEY>,<DB_ID>);

SQL> select dbid from v$database;

      DBID
----------
2732836240
/*************unregister DB*********************/
如果无catalog,则rman nocatalog
connect target /

3.开始备份

B1.全备份脚本,备份到硬盘上/backup/bckdb/下面:
rman target / catalog rman/rman@rman_catalog
run {
 configure controlfile autobackup off;
 allocate channel  ch00 TYPE disk;
 allocate channel  ch01 TYPE disk;
 backup full database  tag full_db_backup
 format '/backup/bckdb/dbfile_t%t_s%s_p%p';
  sql 'alter system archive log current';
 backup filesperset 3 archivelog all delete input;
 backup current controlfile format  '/backup/bckdb/ctlfile_t%t_s%s_p%p';
 release channel ch00;
 release channel ch01;
 }

R1:对应的恢复脚本,(比如全部文件丢失,包括control,redo,datafile)
如果是不同的机器恢复:需要配置环境,拷贝RDBMS部分的文件,修改pfile,listener.ora,符合新的环境,指令都差不多。

SQLPlus指令:
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup nomount
SQL> create spfile from pfile;

File created.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  562036736 bytes
Fixed Size                  2074384 bytes
Variable Size             163580144 bytes
Database Buffers          390070272 bytes
Redo Buffers                6311936 bytes
SQL>

RMAN指令:
rman target / catalog rman/rman@rman_catalog
如果RMAN备份了多个数据库并且在异机恢复,需要修改dbid这个变量,让它等于需要恢复的数据库ID。
run{
   allocate channel  ch00 TYPE disk;
   restore controlfile;
   restore database;
   sql "alter database mount";
   recover database;   
   release channel ch00;  
}
SQLPlus指令:
alter database open resetlogs;

4.Q&A
Q1:
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00132: syntax error or unresolved network name 'LISTENER_TEST'
A1:删除spfile中的*.local_listener='LISTENER_TEST'
Q2:
RMAN-06004: ORACLE error from recovery catalog database:
RMAN-20011: target database incarnation is not current in recovery catalog
A2:在rman中执行了alter database open resetlogs; 这条指令会把修改incarnation,这个值修改后,以前的对应关系会消失,需要reset database一下。如果在sqlplus下面执行就不会出现这个错误了,还有一种办法是,注销重新注册,不推荐。
Q3:恢复时报错
ORA-19870: error reading backup piece /backup/bckdb/dbfile_t669483833_s20_p1
ORA-19504: failed to create file "/disk1/oradata/COMPARD/control01.ctl"
ORA-27040: file create error, unable to create file
IBM AIX RISC System/6000 Error: 2: No such file or directory
A3:恢复的时候,恢复目录要事先建立好,否则会出这个错误
Q4:
RMAN-06026: some targets not found - aborting restore
RMAN-06024: no backup or copy of the control file found to restore
A4:如果是控制文件没有备份,那就把源库的拷贝过来,mount后继续。如果在rman中作过resetlogs,参考Q2.
Q5:Error listening on: (ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROCTEST))
TNS-12555: TNS:permission denied
 TNS-12560: TNS:protocol adapter error
  TNS-00525: Insufficient privilege for operation
A5:chmod -R 0777 .oracle
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值