Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1142467
  • 博文数量: 231
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 2662
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-03 16:35
个人简介

学无止境

文章分类

全部博文(231)

文章存档

2014年(7)

2013年(103)

2011年(11)

2010年(53)

2009年(57)

分类: Oracle

2010-08-31 14:53:12

原平台:windows
数据库版本:10.2.0.4
使用控制文件作为catalog库进行rman备份
 
该平台上只有1个数据库的包含控制文件的全备以及归档备份,以及该数据库的一个初始化参数文件。
如果备份中没有包含控制文件,无法恢复。
 
目标:将此备份恢复到Linux x86平台上
Linux上已经预装好了10.2.0.4的Oracle软件。
 
 
1.将备份集上传到Linux
[oracle@uprac1 rc]$ pwd
/u01/rc
[oracle@uprac1 rc]$ ls -trl
total 673784
-rw-r--r--  1 oracle oinstall 318840832 Aug 29 18:07 DB_ORA10G_26_1
-rw-r--r--  1 oracle oinstall 363061248 Aug 29 18:08 DB_ORA10G_27_1
-rw-r--r--  1 oracle oinstall   7110656 Aug 29 18:08 DB_ORA10G_28_1
-rw-r--r--  1 oracle oinstall    245248 Aug 29 18:08 ARCH_ORA10G_30_1
 
2.修改参数文件
需要将audit_file_dest、background_dump_dest、control_files、core_dump_dest、db_recovery_file_dest、log_archive_dest、user_dump_dest等参数修改。
并且修改的目录有效存在。
[oracle@uprac1 rc]$ pwd
/u01/rc
[oracle@uprac1 rc]$ mkdir admin
[oracle@uprac1 rc]$ mkdir flash_recovery_area
[oracle@uprac1 rc]$ mkdir arch
[oracle@uprac1 rc]$ mkdir oradata
[oracle@uprac1 rc]$ mkdir -p admin/ora10g/adump
[oracle@uprac1 rc]$ mkdir -p admin/ora10g/bdump
[oracle@uprac1 rc]$ mkdir -p admin/ora10g/cdump
[oracle@uprac1 rc]$ mkdir -p admin/ora10g/udump

*.audit_file_dest='/u01/rc/admin/ora10g/adump'
*.background_dump_dest='/u01/rc/admin/ora10g/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/rc/oradata/CONTROL01.CTL'
*.core_dump_dest='/u01/rc/admin/ora10g/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='ora10g'
*.db_recovery_file_dest='/u01/rc/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/u01/rc/arch'
*.log_archive_format='ARC%S_%R.%T'
*.nls_language='SIMPLIFIED CHINESE'
*.nls_territory='CHINA'
*.open_cursors=300
*.pga_aggregate_target=100M
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=300M
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/rc/admin/ora10g/udump'
 

3.启动到nomount状态
设置ORACLE_SID
[oracle@uprac1 rc]$ export ORACLE_SID=ora10g
用新建的init文件启动实例到nomount状态。
SQL> startup nomount pfile='/u01/rc/initORA10G.ora';
ORACLE instance started.
Total System Global Area  314572800 bytes
Fixed Size                  1267236 bytes
Variable Size              96471516 bytes
Database Buffers          213909504 bytes
Redo Buffers                2924544 bytes

4.恢复控制文件
从备份集中恢复控制文件,前提是全备中包含了备份控制文件。通常控制文件存放在最后一个备份集中,也可以从多个备份集中多试几次。
run
{
allocate channel t1 type disk;
restore controlfile from '/u01/rc/DB_ORA10G_28_1';
release channel t1;
}
 
[oracle@uprac1 rc]$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Sun Aug 29 18:37:02 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database: ora10g (not mounted)
RMAN> run
2> {
3> allocate channel t1 type disk;
4> restore controlfile from '/u01/rc/DB_ORA10G_28_1';
5> release channel t1;
6> }
using target database control file instead of recovery catalog
allocated channel: t1
channel t1: sid=159 devtype=DISK
Starting restore at 29-AUG-10
channel t1: restoring control file
channel t1: restore complete, elapsed time: 00:00:02
output filename=/u01/rc/oradata/CONTROL01.CTL
Finished restore at 29-AUG-10
released channel: t1
 

5.将数据库起到mount状态。
RMAN> alter database mount;
 

6.引入备份集
由于是从windows机器复制过来的备份集,linux上没有该备份目录,
从rman的list backup;中看,备份的状态都是EXPIRED。
需要重新引入备份到catalog中:
catalog backuppiece '/u01/rc/DB_ORA10G_26_1';
catalog backuppiece '/u01/rc/DB_ORA10G_27_1';
catalog backuppiece '/u01/rc/DB_ORA10G_28_1';
catalog backuppiece '/u01/rc/ARCH_ORA10G_30_1';
 
 
7.恢复数据文件
开始进行简单的完全恢复,注意恢复时由于原来是windows的路径,要将其中名称转换。由于数据库已经mount了,可以查看其的v$视图:
由于备份中包含datafile,tempfile和redofile可以先不考虑rename的事情。
SQL> select file#,name from v$datafile
     FILE# NAME
---------- ------------------------------------------------------------
         1 E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\SYSTEM01.DBF
         2 E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\UNDOTBS01.DBF
         3 E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\SYSAUX01.DBF
         4 E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\USERS01.DBF
         5 E:\ORACLE\ORADATA\LDY01.DBF
         6 E:\ORACLE\ORADATA\LDY02.DBF
         7 E:\ORACLE\ORADATA\LDY03.DBF
         8 E:\ORACLE\ORADATA\TEST01.DBF
         9 E:\ORACLE\ORADATA\EAGLE01.DBF
        10 E:\ORACLE\ORADATA\TEST02.DBF
 
run
{
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
set newname for datafile  1 to '/u01/rc/oradata/SYSTEM01.DBF';
set newname for datafile  2 to '/u01/rc/oradata/UNDOTBS01.DBF';
set newname for datafile  3 to '/u01/rc/oradata/SYSAUX01.DBF';
set newname for datafile  4 to '/u01/rc/oradata/USERS01.DBF';
set newname for datafile  5 to '/u01/rc/oradata/LDY01.DBF';
set newname for datafile  6 to '/u01/rc/oradata/LDY02.DBF';
set newname for datafile  7 to '/u01/rc/oradata/LDY03.DBF';
set newname for datafile  8 to '/u01/rc/oradata/TEST01.DBF';
set newname for datafile  9 to '/u01/rc/oradata/EAGLE01.DBF';
set newname for datafile 10 to '/u01/rc/oradata/TEST02.DBF';
restore database;
switch datafile all;
recover database;
release channel d1;
release channel d2;
release channel d3;
}
 
8.重命名文件
恢复完成之后修改redolog和temp的位置。
由于路径的问题,可能无法rename这些文件。选择再resetlogs启动之后再删除重建的方式修改。
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\REDO01.LOG
E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\REDO02.LOG
E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\REDO03.LOG
 
alter database rename file 'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\REDO01.LOG' to '/u01/rc/oradata/REDO01.LOG';
alter database rename file 'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\REDO02.LOG' to '/u01/rc/oradata/REDO02.LOG';
alter database rename file 'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\REDO03.LOG' to '/u01/rc/oradata/REDO03.LOG';
 
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\TEMP01.DBF

alter database rename file 'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORA10G\TEMP01.DBF' to '/u01/rc/oradata/TEMP01.DBF';
 
9.打开数据库
resetlogs方式打开
SQL> alter database open resetlogs;

这时遭遇一个严重错误:
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
查看alert log发现是由于需要升级导致的
un Aug 29 20:07:45 2010
Errors in file /u01/rc/admin/ora10g/udump/ora10g_ora_4782.trc:
ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option
Sun Aug 29 20:07:45 2010
Error 704 happened during db open, shutting down database
USER: terminating instance due to error 704
Termination issued to instance processes. Waiting for the processes to exit

10.升级数据库
在linux上启动监听,开始对这个数据库进行升级:
$ sqlplus "/as sysdba"
SQL> STARTUP UPGRADE pfile='/u01/rc/initORA10G.ora';
SQL> SPOOL patch.log
SQL> select comp_name,version,status from dba_registry;
COMP_NAME
--------------------------------------------------------------------------------
VERSION                        STATUS
------------------------------ ----------------------
Oracle Workspace Manager
10.2.0.1.0                     VALID
Oracle Enterprise Manager
10.2.0.1.0                     VALID
Oracle Database Catalog Views
10.2.0.1.0                     VALID

COMP_NAME
--------------------------------------------------------------------------------
VERSION                        STATUS
------------------------------ ----------------------
Oracle Database Packages and Types
10.2.0.1.0                     VALID
SQL> @?/rdbms/admin/catupgrd.sql
SQL> SPOOL OFF
关闭数据库正常启动,编译无效对象。

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP pfile='/u01/rc/initORA10G.ora';
ORACLE instance started.
Total System Global Area  314572800 bytes
Fixed Size                  1267236 bytes
Variable Size              96471516 bytes
Database Buffers          213909504 bytes
Redo Buffers                2924544 bytes
Database mounted.
Database opened.
SQL> @?/rdbms/admin/utlrp.sql
 
11.其他调整
重建redo log
alter database drop logfile group 1;
alter database add logfile group 1 ('/u01/rc/oradata/REDO01.LOG') size 50m;
alter database drop logfile group 2;
alter database add logfile group 2 ('/u01/rc/oradata/REDO02.LOG') size 50m;
alter database drop logfile group 3;
alter database add logfile group 3 ('/u01/rc/oradata/REDO03.LOG') size 50m;
重建temp表空间
删除temp表空间时可能由于它是系统默认临时表空间而无法删除
select * from database_properties where property_name = 'DEFAULT_TEMP_TABLESPACE';
可以新建一个表空间,然后修改系统默认临时表空间
alter database default temporary tablespace temp02;
然后再删除。

至此恢复完成。
阅读(1018) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~