ORACLE RMAN异机异目录恢复
来源:互联网 发布:7k7k皮卡堂盗号软件 编辑:程序博客网 时间:2024/05/29 04:45
1. 环境: 原机: 192.168.102.156
目标机: 192.168.102.157
2. 需求: 将原机所在的控制文件,数据文件, REDOLOG恢复到/home/oracle/oradata/datafile下
3. 参数文件准备
3.1 在原库生成PFILE文件。
SQL> create pfile='/home/oracle/initgg1.ora' from spfile;File created.
3.2 奖参数文件移至目标库。
[oracle@GOLDENGATE1 ~]$ scp initgg1.ora oracle@192.168.102.157:/home/oracleoracle@192.168.102.157's password: initgg1.ora 100% 1051 1.0KB/s 00:00
4. 将目标库启动至NOMOUN状态。
4.1 修改参数文件:
*.control_files='/home/oracle/oradata/datafile/control01.ctl','/home/oracle/oradata/datafile/control02.ctl','/home/oracle/oradata/datafile/control03.ctl'*.core_dump_dest='/home/oracle/admin/gg1/cdump'
4.2 创建PFILE所需要的目录。
[oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/adump[oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/cdump[oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/bdump[oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/udump[oracle@GOLDENGATE2 ~]$ mkdir oradata/datafile
4.3 将目标库启动到NOMOUNT状态。
[oracle@GOLDENGATE2 ~]$ export ORACLE_SID=gg1[oracle@GOLDENGATE2 ~]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on Fri Sep 21 03:48:06 2012Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to an idle instance.SQL> startup nomount pfile='/home/oracle/initgg1.ora';ORACLE instance started.Total System Global Area 167772160 bytesFixed Size 1218292 bytesVariable Size 83888396 bytesDatabase Buffers 75497472 bytesRedo Buffers 7168000 bytes
5. 备份文件准备。
5.1 备份原库。
[oracle@GOLDENGATE1 ~]$ rman target /Recovery Manager: Release 10.2.0.1.0 - Production on Fri Sep 21 02:08:38 2012Copyright (c) 1982, 2005, Oracle. All rights reserved.connected to target database: GG1 (DBID=1620494887)RMAN> backup format='/home/oracle/rman/full_%d_%T_%s' database include current controlfile plus archivelog;Starting backup at 21-SEP-12current log archivedusing target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: sid=141 devtype=DISKchannel ORA_DISK_1: starting archive log backupsetchannel ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1 sequence=4 recid=1 stamp=794527523input archive log thread=1 sequence=5 recid=2 stamp=794538401input archive log thread=1 sequence=6 recid=3 stamp=794539337input archive log thread=1 sequence=7 recid=4 stamp=794539385input archive log thread=1 sequence=8 recid=5 stamp=794539992input archive log thread=1 sequence=9 recid=6 stamp=794542152channel ORA_DISK_1: starting piece 1 at 21-SEP-12channel ORA_DISK_1: finished piece 1 at 21-SEP-12piece handle=/home/oracle/rman/full_GG1_20120921_17 tag=TAG20120921T020913 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:04Finished backup at 21-SEP-12Starting backup at 21-SEP-12using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetinput datafile fno=00006 name=/home/oracle/oradata/gg1/gg01.dbfinput datafile fno=00001 name=/home/oracle/oradata/gg1/system01.dbfinput datafile fno=00003 name=/home/oracle/oradata/gg1/sysaux01.dbfinput datafile fno=00005 name=/home/oracle/oradata/gg1/example01.dbfinput datafile fno=00002 name=/home/oracle/oradata/gg1/undotbs01.dbfinput datafile fno=00004 name=/home/oracle/oradata/gg1/users01.dbfchannel ORA_DISK_1: starting piece 1 at 21-SEP-12channel ORA_DISK_1: finished piece 1 at 21-SEP-12piece handle=/home/oracle/rman/full_GG1_20120921_18 tag=TAG20120921T020917 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:56channel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetincluding current control file in backupsetincluding current SPFILE in backupsetchannel ORA_DISK_1: starting piece 1 at 21-SEP-12channel ORA_DISK_1: finished piece 1 at 21-SEP-12piece handle=/home/oracle/rman/full_GG1_20120921_19 tag=TAG20120921T020917 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:02Finished backup at 21-SEP-12Starting backup at 21-SEP-12current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting archive log backupsetchannel ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1 sequence=10 recid=7 stamp=794542215channel ORA_DISK_1: starting piece 1 at 21-SEP-12channel ORA_DISK_1: finished piece 1 at 21-SEP-12piece handle=/home/oracle/rman/full_GG1_20120921_20 tag=TAG20120921T021016 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:02Finished backup at 21-SEP-12RMAN>
5.2 将备份移至目标机:
[oracle@GOLDENGATE1 rman]$ scp * 192.168.102.157:/home/oracle/rmanoracle@192.168.102.157's password: full_GG1_20120921_17 100% 40MB 19.9MB/s 00:02 full_GG1_20120921_18 100% 594MB 10.4MB/s 00:57 full_GG1_20120921_19 100% 6976KB 6.8MB/s 00:01 full_GG1_20120921_20 100% 12KB 12.0KB/s 00:00 [oracle@GOLDENGATE1 rman]$
6. 在目标机上面恢复控制文件, 并将数据库启动到MOUNT状态。
[oracle@GOLDENGATE2 ~]$ rman target /Recovery Manager: Release 10.2.0.1.0 - Production on Fri Sep 21 03:50:44 2012Copyright (c) 1982, 2005, Oracle. All rights reserved.connected to target database: gg1 (not mounted)RMAN> restore controlfile from '/home/oracle/rman/full_GG1_20120921_19';Starting restore at 21-SEP-12using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: sid=156 devtype=DISKchannel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:02output filename=/home/oracle/oradata/datafile/control01.ctloutput filename=/home/oracle/oradata/datafile/control02.ctloutput filename=/home/oracle/oradata/datafile/control03.ctlFinished restore at 21-SEP-12RMAN> alter database mount;database mountedreleased channel: ORA_DISK_1
7. 恢复数据文件。
RMAN> run{ set newname for datafile 1 to '/home/oracle/oradata/datafile/system01.dbf';set newname for datafile 2 to '/home/oracle/oradata/datafile/undotbs01.dbf';set newname for datafile 3 to '/home/oracle/oradata/datafile/sysaux01.dbf';set newname for datafile 4 to '/home/oracle/oradata/datafile/users01.dbf';set newname for datafile 5 to '/home/oracle/oradata/datafile/example01.dbf';set newname for datafile 6 to '/home/oracle/oradata/datafile/gg01.dbf';restore database;switch datafile all;}2> 3> 4> 5> 6> 7> 8> 9> 10> executing command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting restore at 21-SEP-12Starting implicit crosscheck backup at 21-SEP-12allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=156 devtype=DISKCrosschecked 2 objectsFinished implicit crosscheck backup at 21-SEP-12Starting implicit crosscheck copy at 21-SEP-12using channel ORA_DISK_1Finished implicit crosscheck copy at 21-SEP-12searching for all files in the recovery areacataloging files...no files catalogedusing channel ORA_DISK_1channel ORA_DISK_1: starting datafile backupset restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setrestoring datafile 00001 to /home/oracle/oradata/datafile/system01.dbfrestoring datafile 00002 to /home/oracle/oradata/datafile/undotbs01.dbfrestoring datafile 00003 to /home/oracle/oradata/datafile/sysaux01.dbfrestoring datafile 00004 to /home/oracle/oradata/datafile/users01.dbfrestoring datafile 00005 to /home/oracle/oradata/datafile/example01.dbfrestoring datafile 00006 to /home/oracle/oradata/datafile/gg01.dbfchannel ORA_DISK_1: reading from backup piece /home/oracle/rman/full_GG1_20120921_18channel ORA_DISK_1: restored backup piece 1piece handle=/home/oracle/rman/full_GG1_20120921_18 tag=TAG20120921T020917channel ORA_DISK_1: restore complete, elapsed time: 00:00:46Finished restore at 21-SEP-12datafile 1 switched to datafile copyinput datafile copy recid=8 stamp=794548607 filename=/home/oracle/oradata/datafile/system01.dbfdatafile 2 switched to datafile copyinput datafile copy recid=9 stamp=794548607 filename=/home/oracle/oradata/datafile/undotbs01.dbfdatafile 3 switched to datafile copyinput datafile copy recid=10 stamp=794548607 filename=/home/oracle/oradata/datafile/sysaux01.dbfdatafile 4 switched to datafile copyinput datafile copy recid=11 stamp=794548607 filename=/home/oracle/oradata/datafile/users01.dbfdatafile 5 switched to datafile copyinput datafile copy recid=12 stamp=794548607 filename=/home/oracle/oradata/datafile/example01.dbfdatafile 6 switched to datafile copyinput datafile copy recid=13 stamp=794548607 filename=/home/oracle/oradata/datafile/gg01.dbfRMAN>
8. 恢复数据库应用日志。
SQL> recover adtabase using backup controlfile until cancel;ORA-00905: missing keywordSQL> recover database using backup controlfile until cancel;ORA-00279: change 531086 generated at 09/21/2012 02:09:18 needed for thread 1ORA-00289: suggestion : /home/oracle/archivelog/1_10_794474474.dbfORA-00280: change 531086 for thread 1 is in sequence #10Specify log: {<RET>=suggested | filename | AUTO | CANCEL}cancelMedia recovery cancelled.SQL> alter database open resetlogs;alter database open resetlogs*ERROR at line 1:ORA-00344: unable to re-create online log '/home/oracle/oradata/gg1/redo01.log'ORA-27040: file create error, unable to create fileLinux Error: 2: No such file or directory
这里在打开数据库时出现错误, 原因是因为在打开数据库时, ORACLE 会根据控制文件来创建,这里控制文件记录的位置,目标机上并没有, 所以我们在打开数据库时创建这个目录。
[oracle@GOLDENGATE2 oradata]$ mkdir gg1[oracle@GOLDENGATE2 oradata]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on Fri Sep 21 04:03:20 2012Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsSQL> alter database open resetlogs;Database altered.
在这里会自动创建REDO和临时表空间数据文件。
9. 将日志文件重创建到/home/oracle/oradata/datafile下。
SQL> select group#,bytes/1024/1024||'M',status from v$log; GROUP# BYTES/1024/1024||'M' STATUS---------- ----------------------------------------- ---------------- 1 50M UNUSED 2 50M UNUSED 3 50M CURRENTSQL> alter database drop logfile group 1;Database altered.SQL> alter database add logfile group 1('/home/oracle/oradata/datafile/redo01.log') size 50m;Database altered.SQL> alter database drop logfile group 2;Database altered.SQL> alter database add logfile group 2('/home/oracle/oradata/datafile/redo02.log') size 50m;Database altered.SQL> alter system switch logfile;System altered.SQL> alter system switch logfile;System altered.SQL> select group#,bytes/1024/1024||'M',status from v$log; GROUP# BYTES/1024/1024||'M' STATUS---------- ----------------------------------------- ---------------- 1 50M ACTIVE 2 50M CURRENT 3 50M INACTIVESQL> alter database drop logfile group 3;Database altered.SQL> alter database add logfile group 3('/home/oracle/oradata/datafile/redo03.log') size 50m;Database altered.SQL> select member from v$logfile;MEMBER--------------------------------------------------------------------------------/home/oracle/oradata/datafile/redo03.log/home/oracle/oradata/datafile/redo02.log/home/oracle/oradata/datafile/redo01.log
10. 处理临时表空间文件。
查询临时文件:
SQL> select name from v$tempfile;NAME--------------------------------------------------------------------------------/home/oracle/oradata/gg1/temp01.dbf
将临时表空间置为OFFLINE状态:
SQL> alter database tempfile '/home/oracle/oradata/gg1/temp01.dbf' offline;Database altered.
主机移动文件位置:
SQL> !mv /home/oracle/oradata/gg1/temp01.dbf /home/oracle/oradata/datafile/temp01.dbf
在控制文件中修改临时文件位置:
SQL> alter database rename file '/home/oracle/oradata/gg1/temp01.dbf' to '/home/oracle/oradata/datafile/temp01.dbf';Database altered.
置临时表空间为ONLINE:
SQL> alter database tempfile '/home/oracle/oradata/datafile/temp01.dbf' online;Database altered.
查询临时表空间文件:
SQL> select name from v$tempfile;NAME--------------------------------------------------------------------------------/home/oracle/oradata/datafile/temp01.dbf
11. 关闭数据库,创建SPFILE文件,启动数据库
SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> create spfile from pfile='/home/oracle/initgg1.ora';File created.SQL> startupORACLE instance started.Total System Global Area 167772160 bytesFixed Size 1218292 bytesVariable Size 83888396 bytesDatabase Buffers 75497472 bytesRedo Buffers 7168000 bytesDatabase mounted.Database opened.SQL>
- ORACLE RMAN异机异目录恢复
- ORACLE RMAN异机异目录恢复
- rman恢复oracle data目录
- window Oracle 10g RMAN异机异目录恢复
- Oracle DB 使用RMAN恢复目录
- Oracle DB 使用RMAN恢复目录
- rman catalog (rman 恢复目录)
- RMAN 恢复目录管理
- RMAN 创建恢复目录
- RMAN catalog恢复目录
- 使用RMAN恢复目录
- rman恢复目录
- oracle rman 恢复脚本
- rman恢复Oracle数据库
- ORACLE rman 部分恢复
- Oracle RMAN -不完全恢复
- 建立rman恢复目录步骤
- rman 恢复目录的使用
- [opencv]有关矩阵以及iplimage
- Redis云存储服务
- [MTK] [LCM]ili9806c和ili9805c开启ESD机制使用过程概率性出现上方闪线
- 使用openssl库EVP编程计算md5值
- Android BroadcastReceiver
- ORACLE RMAN异机异目录恢复
- IOS之支持高分辨率的显示屏(译文)
- 特殊dllcom组件调用方法
- linux命令1
- POJ题目分类
- CodeFirst进行数据迁移之添加字段
- jquery ajax 向后台传递数组
- jQueryDom操作之外部插入节点
- hdu 4089 Activation