ITPub博客

首页 > 数据库 > Oracle > rman_换设备迁移恢复2

rman_换设备迁移恢复2

原创 Oracle 作者:家有ORACLE老公 时间:2020-02-13 19:39:02 0 删除 编辑

这里连接上一个 http://blog.itpub.net/69959246/viewspace-2674348/  主要记录恢复数据文件set newname


1 准备~~~省略

2 数据库启动到nomount

i) nomount是读取的参数文件spfile,由于我们没有spfile文件,要创建可用性的假的pfile文件骗数据库

ORACLE>vi a.txt

db_name=jia

db_block_size=8192

qw

ii) 用a.txt启动

SQL> startup nomount pfile='/home/oracle/rman/a.txt';
用备份集恢复真实spfile

RMAN> restore spfile from '/home/oracle/rman/200213/full_TEST_1031238574_279_1';

--注:全备里最小的是参数文件

iii)关库,再启动,会默认用spfile启动

SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.


这里有个报错。百度了原因,这篇文章大佬还很有帮助 http://blog.itpub.net/20674423/viewspace-711545

a、 Oracle的共享内存段或信号量没有被释放;

b、 Oracle的后台进程(如SMON、PMON、DBWn等)没有被关闭;

c、 用于锁内存的文件lk<sid>和sgadef<sid>.dbf文件没有被删除。


a 不太清楚怎么下手验证ipts -m   b 因为还没有恢复数据,不可能 。c 待验证


因为我为了练习不同设备恢复,dbca删除了数据库,用备份包恢复的,并且我欠欠的把$ORACLE_HOME/dbs 里的文件全部删除,想先从恢复参数数据开始,于是就

[oracle@jcy1 dbs]$ rm -rf *

按照大佬的做法,去查询

[oracle@jcy1 rman]$ cd $ORACLE_HOME/dbs
[oracle@jcy1 dbs]$ fuser -u lkTEST
Cannot stat lkNDMSQA: No such file or directory
[oracle@jcy1 dbs]$ ll
total 8
-rw-rw---- 1 oracle dba 1544 Feb 13 06:35 hc_test.dat
-rw-r----- 1 oracle dba 2560 Feb 13 06:21 spfiletest.ora


dbs里没有lkTEST文件,哎,有查看a共享内存的信息

$ipcs -m

然后它ID号清除共享内存段:

$ipcrm –m 851975

然后我就没有重新尝试shutdown immediate ,就直接进行下面步骤了,真是粗心。不过后来恢复完数据文件后,再关库启库没有遇到问题。


启动到nomount,真正的spfile文件

SQL> startup nomount
ORACLE instance started.

Total System Global Area  221331456 bytes
Fixed Size            2251856 bytes
Variable Size          163578800 bytes
Database Buffers       50331648 bytes
Redo Buffers            5169152 bytes


2 启动到mount状态

mount 读取的是控制文件

RMAN> restore controlfile from '/home/oracle/rman/200213/ctl_TEST_1031238591_283_1';

完成

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1


4 数据库启动到open

恢复数据文件,我这里想恢复到新的路径/cs/test/ 和旧端位置不一样,

set newname for datafile' 旧的备端20路径 'to' 目标端60-新路径 ';

用set newname for 主要是想要改变目标端数据文件的路径,如果用restore database 的话,就必须在目标端60创建跟备端20数据文件一致的路径。

如果采用restore database 详情

http://blog.itpub.net/69959246/viewspace-2675334/


这里我选择下面set newname的方式

RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;   
set newname for datafile'/oradata/test/system01.dbf'to'/home/oracle/cs/test/system01.dbf';
set newname for datafile'/oradata/test/sysaux01.dbf'to'/home/oracle/cs/test/sysaux01.dbf';
set newname for datafile'/oradata/test/undotbs01.dbf'to'/home/oracle/cs/test/undotbs01.dbf';
set newname for datafile'/oradata/test/users01.dbf'to'/home/oracle/cs/test/users01.dbf';
set newname for datafile'/oradata/test/example01.dbf'to'/home/oracle/cs/test/example01.dbf';
restore database;
switch datafile all;
}
recover database;2> 3> 4> 5> 6> 7> 8> 9> 10> 11>

~~~省略


Finished restore at 13-FEB-20

released channel: c1
released channel: c2

RMAN> alter database open;

Starting recover at 13-FEB-20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=15
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=16
channel ORA_DISK_1: reading from backup piece /home/oracle/rman/200213/arch_TEST_1032264541_22_1
channel ORA_DISK_1: piece handle=/home/oracle/rman/200213/arch_TEST_1032264541_22_1 tag=TAG20200213T120859
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/arch/1_15_1032153387.dbf thread=1 sequence=15
archived log file name=/arch/1_16_1032153387.dbf thread=1 sequence=16
unable to find archived log
archived log thread=1 sequence=17
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/13/2020 09:33:19
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 17 and starting SCN of 1029820

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 02/13/2020 09:33:19
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> alter database open RESETLOGS;

database opened

完成


由于上面的遗留问题

SQL> shutdown immediate
ORA-01507: database not mounted                  --后来理解:这是正常的提示,不是报错


我再次尝试关库起库

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  221331456 bytes
Fixed Size            2251856 bytes
Variable Size          163578800 bytes
Database Buffers       50331648 bytes
Redo Buffers            5169152 bytes
Database mounted.
Database opened.


正常,没有再现


附件恢复脚本

rman恢复.txt






来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/69959246/viewspace-2675502/,如需转载,请注明出处,否则将追究法律责任。

上一篇: rman_换磁盘迁移
请登录后发表评论 登录
全部评论

注册时间:2020-01-06

  • 博文量
    26
  • 访问量
    9206