ITPub博客

首页 > 数据库 > Oracle > 记一次简单的异机恢复操作

记一次简单的异机恢复操作

Oracle 作者:desert_xu 时间:2015-12-16 11:53:01 0 删除 编辑
客户的主机出现磁盘损坏,导致无法启动。主机工程师将机器拉起来后,检查数据库还正常。这时客户提出要求需要保留数据库数据,然后更换磁盘重新安装操作系统。因此使用rman对数据库进行了全备,备份了控制文件和参数文件。

环境:RHEL5.6 64bit
数据库:oracle10g 10.2.0.5 单机

下面来简单的介绍一下恢复的过程。软件的安装请参看我的这篇博客《 使用静默方式安装11g数据库》或者 《OCM实验-测试环境的搭建 

1)使用备份的参数文件并修改参数文件中的文件路径
[oracle@icsts dbs]$ cat pfile.ora
*.audit_file_dest='/u01/app/oracle/admin/ICSTEST/adump'
*.background_dump_dest='/u01/app/oracle/admin/ICSTEST/bdump'
*.compatible='10.2.0.5.0'
*.control_files='/u01/app/oracle/datafile/ICSTEST/control01.ctl','/u01/app/oracle/datafile/ICSTEST/control02.ctl','/u01/app/oracle/datafile/ICSTEST/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/ICSTEST/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='ICSTEST'
*.dispatchers=''
*.job_queue_processes=10
*.nls_language='SIMPLIFIED CHINESE'
*.nls_territory='CHINA'
*.open_cursors=300
*.pga_aggregate_target=1202716672
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1610612736
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/ICSTEST/udump'
2)创建参数文件中需要的路径
mkdir -p /u01/app/oracle/admin/ICSTEST/adump
mkdir -p /u01/app/oracle/admin/ICSTEST/bdump
mkdir -p /u01/app/oracle/admin/ICSTEST/cdump
mkdir -p /u01/app/oracle/admin/ICSTEST/udump
mkdir -p /u01/app/oracle/datafile/ICSTEST
3)使用新建的参数文件启动并创建spfile文件
SQL> startup nomount pfile=/u01/app/oracle/product/10.2.0/db_1/dbs/pfile.ora
ORACLE instance started.
Total System Global Area 1610612736 bytes
Fixed Size                  2096632 bytes
Variable Size             385876488 bytes
Database Buffers         1207959552 bytes
Redo Buffers               14680064 bytes
SQL> 
SQL> create spfile from pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/pfile.ora';
File created.

重启,使用spfile文件
SQL> shutdown abort
ORACLE instance shut down.
SQL> 
SQL> startup nomount
ORACLE instance started.
Total System Global Area 1610612736 bytes
Fixed Size                  2096632 bytes
Variable Size             385876488 bytes
Database Buffers         1207959552 bytes
Redo Buffers               14680064 bytes
SQL>

4)恢复控制文件
RMAN> restore controlfile from '/u01/backup/control_06osrlpi_1_1';
Starting restore at 07-JAN-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/u01/app/oracle/datafile/ICSTEST/control01.ctl
output filename=/u01/app/oracle/datafile/ICSTEST/control02.ctl
output filename=/u01/app/oracle/datafile/ICSTEST/control03.ctl
Finished restore at 07-JAN-14

将数据库启动到mount状态
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1

5)修改redo日志文件
检查现在的redolog文件
SQL> select member from v$logfile;
MEMBER
----------------------------------------
/data/redolog/ICSTEST/redo03.log
/data/redolog/ICSTEST/redo02.log
/data/redolog/ICSTEST/redo01.log
这些文件是不存在的。更改redolog文件
SQL> alter database rename file '/data/redolog/ICSTEST/redo01.log' to '/u01/app/oracle/datafile/ICSTEST/redo01.log';
Database altered.
SQL> alter database rename file '/data/redolog/ICSTEST/redo02.log' to '/u01/app/oracle/datafile/ICSTEST/redo02.log';
Database altered.
SQL> alter database rename file '/data/redolog/ICSTEST/redo03.log' to '/u01/app/oracle/datafile/ICSTEST/redo03.log';
Database altered.
更改后检查
MEMBER
--------------------------------------------------
/u01/app/oracle/datafile/ICSTEST/redo03.log
/u01/app/oracle/datafile/ICSTEST/redo02.log
/u01/app/oracle/datafile/ICSTEST/redo01.log

6)注册备份信息,由于我们是异机恢复,重做系统也相当于异机了。
RMAN> catalog start with '/u01/backup';
searching for all files that match the pattern /u01/backup
List of Files Unknown to the Database
=====================================
File Name: /u01/backup/control_06osrlpi_1_1
File Name: /u01/backup/pfile.ora
File Name: /u01/backup/database_full_05osrlof_1_1
File Name: /u01/backup/database_full_04osrlhe_1_1
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/backup/control_06osrlpi_1_1
File Name: /u01/backup/database_full_05osrlof_1_1
File Name: /u01/backup/database_full_04osrlhe_1_1
List of Files Which Where Not Cataloged
=======================================
File Name: /u01/backup/pfile.ora
  RMAN-07517: Reason: The file header is corrupted
RMAN>

7)恢复数据文件,我这里的恢复时数据文件路径已经同原来的不一致了。因此多出来很多set netname for datafile file# to 'newname';语句来。
run{
allocate channel ch1 type disk;
allocate channel ch2 type disk;
set newname for datafile  1 to '/u01/app/oracle/datafile/ICSTEST/system01.dbf';
set newname for datafile  2 to '/u01/app/oracle/datafile/ICSTEST/undotbs01.dbf';
set newname for datafile  3 to '/u01/app/oracle/datafile/ICSTEST/sysaux01.dbf';
set newname for datafile  4 to '/u01/app/oracle/datafile/ICSTEST/users01.dbf';
set newname for datafile  5 to '/u01/app/oracle/datafile/ICSTEST/ics_data01.dbf';
set newname for datafile  6 to '/u01/app/oracle/datafile/ICSTEST/ism_data01.dbf';
set newname for datafile  7 to '/u01/app/oracle/datafile/ICSTEST/CWMLITE01.dbf';
set newname for datafile  8 to '/u01/app/oracle/datafile/ICSTEST/DRSYS01.dbf';
set newname for datafile  9 to '/u01/app/oracle/datafile/ICSTEST/EXAMPLE01.dbf';
set newname for datafile 10 to '/u01/app/oracle/datafile/ICSTEST/INDX01.dbf';
set newname for datafile 11 to '/u01/app/oracle/datafile/ICSTEST/ODM01.dbf';
set newname for datafile 12 to '/u01/app/oracle/datafile/ICSTEST/SYSTEM02.dbf';
set newname for datafile 13 to '/u01/app/oracle/datafile/ICSTEST/TBS_BSS01.dbf';
set newname for datafile 14 to '/u01/app/oracle/datafile/ICSTEST/TBS_BSS02.dbf';
set newname for datafile 15 to '/u01/app/oracle/datafile/ICSTEST/TOOLS01.dbf';
set newname for datafile 16 to '/u01/app/oracle/datafile/ICSTEST/TS_IDS01.dbf';
set newname for datafile 17 to '/u01/app/oracle/datafile/ICSTEST/TS_IDS02.dbf';
set newname for datafile 18 to '/u01/app/oracle/datafile/ICSTEST/TS_IDS03.dbf';
set newname for datafile 19 to '/u01/app/oracle/datafile/ICSTEST/TS_IDS04.dbf';
set newname for datafile 20 to '/u01/app/oracle/datafile/ICSTEST/TS_IDS05.dbf';
set newname for datafile 21 to '/u01/app/oracle/datafile/ICSTEST/TS_IDS06.dbf';
set newname for datafile 22 to '/u01/app/oracle/datafile/ICSTEST/TS_IDS07.dbf';
set newname for datafile 23 to '/u01/app/oracle/datafile/ICSTEST/TS_IDS08.dbf';
set newname for datafile 24 to '/u01/app/oracle/datafile/ICSTEST/TS_ISM01.dbf';
set newname for datafile 25 to '/u01/app/oracle/datafile/ICSTEST/TS_SM01.dbf';
set newname for datafile 26 to '/u01/app/oracle/datafile/ICSTEST/TS_TIF01.dbf';
set newname for datafile 27 to '/u01/app/oracle/datafile/ICSTEST/UNDOTBS102.dbf';
set newname for datafile 28 to '/u01/app/oracle/datafile/ICSTEST/UNDOTBS103.dbf';
set newname for datafile 29 to '/u01/app/oracle/datafile/ICSTEST/UNDOTBS104.dbf';
set newname for datafile 30 to '/u01/app/oracle/datafile/ICSTEST/XDB01.dbf';
set newname for datafile 31 to '/u01/app/oracle/datafile/ICSTEST/USERS02.dbf';
restore database;
switch datafile all;
release channel ch1;
release channel ch2;
}
数据文件恢复后,可以将数据库启动到open状态了。这里要说明一下,源库是noarchivelog模式,所以不存在归档日志,不需要做recover操作了。
RMAN> alter database open resetlogs;
database opened

8)修改temporary tablespace 
SQL> create temporary tablespace temptbs tempfile '/u01/app/oracle/datafile/ICSTEST/temptbs01.dbf' size 200M;
Tablespace created.
SQL> alter database default temporary tablespace temptbs;
Database altered.
SQL> drop tablespace temp; #删除原来的temp表空间
Tablespace dropped.
SQL> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/datafile/ICSTEST/temptbs01.dbf

到这里呢,恢复基本完成了,后续可能还有一些监听的配置等小操作了。

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

下一篇: rman 建立catalog库
请登录后发表评论 登录
全部评论

注册时间:2013-10-23

  • 博文量
    79
  • 访问量
    247124