networker对mysql备份_Networker备份异机恢复oracle测试

1.编辑qintest.ora如下

*.audit_file_dest='/u01/app/oracle/admin/qintest/adump'

*.audit_trail='db'

*.compatible='11.2.0.4.0'

*.db_block_size=8192

*.db_domain=''

*.control_files='/data/oradata/qintest/control01.ctl','/data/oradata/qintest/control02.ctl'#Restore

Controlfile

*.db_name='qintest'

*.db_recovery_file_dest='/data/fra'

*.db_recovery_file_dest_size=536870912000

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=qintestXDB)'

*.memory_target=32G

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_tablespace='UNDOTBS1'

2.启动数据库到nomount模式

SQL> create spfile from

pfile='/export/home/oracle/qintest.ora';

SQL> startup nomount;

3.查出源数据库的DBID,然后将目标数据库的DBID设置和源数据库的DBID一样

oracle@histest:~$ rman target /

RMAN> set dbid=2019031823

4.运行rman脚本恢复控制文件

run

{

allocate channel c1 type sbt_tape;

send

'NSR_ENV=(NSR_CLIENT=qintest,NSR_SERVER=networker)';

--send

'NSR_ENV=(NSR_CLIENT=qintest,NSR_SERVER=networker,NSR_DATA_VOLUME_POOL=DB)';

restore controlfile from autobackup;

--restore controlfile from

'c-2666832443-20190318-01';

release channel c1;

}

5.挂载数据库

RMAN> sql 'alter database mount';

6.运行rman脚本还原数据库

run

{

allocate channel c1 type sbt_tape;

allocate channel c2 type sbt_tape;

allocate channel c3 type sbt_tape;

allocate channel c4 type sbt_tape;

send

'NSR_ENV=(NSR_CLIENT=qintest,NSR_SERVER=networker)';

--set until time "to_date('2019-03-18 00:00:00','yyyy-mm-dd

hh21:mi:ss')"

set newname for database to '/data/oradata/qintest/%b';

set newname for datafile

'+DATA/qsg/datafile/system.324.960137469' to

'/data/oradata/qintest/system.dbf';

set newname for datafile

'+DATA/qsg/datafile/sysaux.350.960137469' to

'/data/oradata/qintest/sysaux.dbf';

set newname for datafile

'+DATA/qsg/datafile/undotbs1.332.960137469' to

'/data/oradata/qintest/undotbs1.dbf';

set newname for datafile

'+DATA/qsg/datafile/users.325.960137469' to

'/data/oradata/qintest/users.dbf';

set newname for datafile

'+DATA/qsg/datafile/undotbs2.336.960137789' to

'/data/oradata/qintest/undotbs2.dbf';

restore database;

switch datafile all;

recover database;

release channel c1;

release channel c2;

release channel c3;

release channel c4;

}

7.在recover脚本中添加until sequence 1314,再次使用RMAN脚本recover数据库

run

{

allocate channel c1 type sbt_tape;

send

'NSR_ENV=(NSR_CLIENT=qintest,NSR_SERVER=networker)';

recover database until sequence 1314;

release channel c1;

}

8.打开数据库

RMAN> alter database open resetlogs;

附:

在做数据恢复时,偶尔会碰到需要对数据文件位置调整的案例,在这种情况下,可以在RMAN中使用SETNEWNAME命令。在Oracle

11g之前,RMAN只支持SET NEWNAME FOR DATAFILE,在Oracle 11g中增加了SET NEWNAME

FOR TEMPFILE/SET NEWNAME FOR TABLESPACE/SET NEWNAME FOR

DATABASE的命令。

优先顺序如下:

1.SET NEWNAME FOR DATAFILE and SET NEWNAME FOR TEMPFILE

2.SET NEWNAME FOR TABLESPACE

3.SET NEWNAME FOR DATABASE

当使用SET NEWNAME FOR DATAFILE/TEMPFILE的时候,可以使用下面的SQL生成所有的SET

NEWNAME命令:

select 'set newname for datafile ''' || name || ''' to ''/'

||substr(name, instr(name, '/', -1) + 1) || ''';'from v$datafile

order by file#;

--显示为

set newname for datafile

'/u01/oracle/oradata/ora11g/system01.dbf' to '/system01.dbf';

当使用FOR TABLESPACE/DATABASE命令的时候,可以指定下面的变量格式:

%b Specifies the file name stripped of directory

paths.对应的文件名称

%f Specifies the absolute file number of the data file for

which the new name is generated. 数据文件的绝对文件号

%U Specifies the following format:

data-D-%d_id-%I_TS-%N_FNO-%f

%I Specifies the DBID 对应的DBID

%N Specifies the tablespace name 对应的表空间名称

eg:

1:SET NEWNAME FOR TABLESPACE

RMAN> sql 'alter tablespace users offline';

RMAN> run {

2> set newname for tablespace users to

'/arch/bentest/oradata/newloc/%b';

3> restore tablespace users;

4> switch datafile all;

5> }

set newname for datafile '/u01/oracle/oradata/ora11g/tt1.dbf'

to '/tt1.dbf';

2:SET NEWNAME FOR DATABASE

RMAN> startup mount

RMAN> run {

2> set newname for database to

'/arch/bentest/oradata/newloc/%b';

3> restore database;

4> switch datafile all;

5> recover database;

6> }

http://blog.itpub.net/29154652/viewspace-773654/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值