测试 当时是只安装了一个数据库的软件 没有安装数据库
从同坐上cp 了 一个压缩的全备份
1、删除$ORACLE_HOME/dbs 下所有的文件
su - oracle
mkdir bk
mkdir arc
cp ..... /home/oracle/bk
[oracle@dba bk]$ ls -al
total 235472
drwxr-xr-x 2 oracle oinstall 4096 Jun 14 05:32 .
drwx------ 6 oracle oinstall 4096 Jun 14 05:46 ..
-rwxr-xr-x 1 root root 108838912 Jun 14 2012 0vndgof5
-rwxr-xr-x 1 root root 1114112 Jun 14 2012 10ndgogi
-rwxr-xr-x 1 root root 119054336 Jun 14 2012 11ndgolv
-rwxr-xr-x 1 root root 11853824 Jun 14 2012 datafile4
这个时候需要改这些文件的权限
[root@dba ~]# chown -R oracle:oinstall /home/oracle/bk/
[root@dba ~]# chmod -R 755 /home/oracle/bk/
[root@dba ~]# su - oracle
[oracle@dba ~]$ cd bk/
[oracle@dba bk]$ ls -al
total 235472
drwxr-xr-x 2 oracle oinstall 4096 Jun 14 05:32 .
drwx------ 6 oracle oinstall 4096 Jun 14 06:42 ..
-rwxr-xr-x 1 oracle oinstall 108838912 Jun 14 2012 0vndgof5
-rwxr-xr-x 1 oracle oinstall 1114112 Jun 14 2012 10ndgogi
-rwxr-xr-x 1 oracle oinstall 119054336 Jun 14 2012 11ndgolv
-rwxr-xr-x 1 oracle oinstall 11853824 Jun 14 2012 datafile4
用rman无配置启动数据库
[oracle@dba ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jun 14 06:32:15 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/oracle/product/10.2.0/dbs/initora10g.ora'
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 06/14/2012 06:32:22
ORA-00205: error in identifying control file, check alert log for more info
用sqlplus 验证这些位置
[oracle@dba bk]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 14 06:07:46 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string DUMMY
db_unique_name string DUMMY
global_names boolean FALSE
instance_name string ora10g
lock_name_space string
log_file_name_convert string
service_names string DUMMY
SQL> show parameter control
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /u01/oracle/product/10.2.0/dbs
/cntrlora10g.dbf
SQL> show parameter dump
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
background_core_dump string partial
background_dump_dest string /u01/oracle/product/10.2.0/rdb
ms/log
core_dump_dest string /u01/oracle/product/10.2.0/dbs
max_dump_file_size string UNLIMITED
shadow_core_dump string partial
user_dump_dest string /u01/oracle/product/10.2.0/rdb
ms/log
rman 恢复控制文件和spfile文件
RMAN> restore controlfile from '/home/oracle/bk/10ndgogi';
Starting restore at 14-JUN-12
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/u01/oracle/product/10.2.0/dbs/cntrlora10g.dbf
Finished restore at 14-JUN-12
RMAN> restore spfile from '/home/oracle/bk/10ndgogi';
Starting restore at 14-JUN-12
using channel ORA_DISK_1
channel ORA_DISK_1: autobackup found: /home/oracle/bk/10ndgogi
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 14-JUN-12
创建
[oracle@dba ~]$ mkdir db120
在sqlplus / as sysdba
create pfile from spfile;
cd v$ORACLE_HOME/dbs
vi initora10g.ora
修改control_files=/home/oracle/db120/control01.ctl
保存
这个时候 rm -f spfileora10g.ora
在sqlplus 里面
create spfile from pfile;
10、复制恢复出来的控制文件到/db38/control01.ctl
[oracle@dba dbs]$ ls
cntrlora10g.dbf initora10g.ora lkDUMMY spfileora10g.ora
[oracle@dba dbs]$ mv cntrlora10g.dbf /home/oracle/db120/
[oracle@dba dbs]$ cd /home/oracle/db120/
[oracle@dba db120]$ ls
cntrlora10g.dbf
[oracle@dba db120]$ mv cntrlora10g.dbf control01.ctl
[oracle@dba db120]$ ls
control01.ctl
[oracle@dba dbs]$ mkdir -p /u01/oracle/admin/ora10g
[oracle@dba dbs]$ cd /u01/oracle/admin/ora10g
[oracle@dba ora10g]$ ls
[oracle@dba ora10g]$ mkdir {u,a,b,c}dump
[oracle@dba ora10g]$ ls
adump bdump cdump udump
[oracle@dba ora10g]$ cd $ORACLE_HOME/dbs
[oracle@dba dbs]$ ls
hc_ora10g.dat initora10g.ora lkDUMMY spfileora10g.ora
[oracle@dba dbs]$ vi initora10g.ora
[oracle@dba dbs]$ rm -f spfileora10g.ora
[oracle@dba dbs]$ vi initora10g.ora
这个时候 rm -f spfileora10g.ora
在sqlplus 里面
create spfile from pfile;
sqlplus 里面去启动到mount状态
alter database mount;
RMAN> report schema;
using target database control file instead of recovery catalog
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 0 SYSTEM *** /stu221/system01.dbf
2 0 UNDOTBS1 *** /stu221/undotbs01.dbf
3 0 SYSAUX *** /stu221/sysaux01.dbf
4 0 USERS *** /stu221/users01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 0 TEMP 0 /stu221/temp01.dbf
RMAN> crosscheck copy;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
validation failed for datafile copy
datafile copy filename=/home/oracle/users01.qq recid=15 stamp=785931049
validation failed for datafile copy
datafile copy filename=/home/oracle/datafile4 recid=4 stamp=785415787
validation failed for archived log
archive log filename=/home/oracle/arc/1_12_785252502.arc recid=98 stamp=785668962
validation failed for archived log
archive log filename=/home/oracle/arc/1_13_785252502.arc recid=99 stamp=785693397
validation failed for archived log
archive log filename=/home/oracle/arc/1_14_785252502.arc recid=100 stamp=785694179
validation failed for archived log
archive log filename=/home/oracle/arc/1_15_785252502.arc recid=101 stamp=785925487
validation failed for archived log
archive log filename=/home/oracle/arc/1_16_785252502.arc recid=102 stamp=785927603
validation failed for archived log
archive log filename=/home/oracle/arc/1_17_785252502.arc recid=103 stamp=785927605
validation failed for archived log
archive log filename=/home/oracle/arc/1_18_785252502.arc recid=104 stamp=785927609
validation failed for archived log
archive log filename=/home/oracle/arc/1_19_785252502.arc recid=105 stamp=785927615
validation failed for archived log
archive log filename=/home/oracle/arc/1_20_785252502.arc recid=106 stamp=785927621
Crosschecked 11 objects
RMAN> crosscheck backup;
using channel ORA_DISK_1
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/home/oracle/han recid=32 stamp=785421213
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/home/oracle/rman_bak/datafile4 recid=35 stamp=785927543
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/home/oracle/rman_bak/0vndgof5 recid=36 stamp=785932773
Crosschecked 3 objects
RMAN> delete noprompt EXPIRED backup;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
32 19 1 1 EXPIRED DISK /home/oracle/han
35 22 1 1 EXPIRED DISK /home/oracle/rman_bak/datafile4
36 23 1 1 EXPIRED DISK /home/oracle/rman_bak/0vndgof5
deleted backup piece
backup piece handle=/home/oracle/han recid=32 stamp=785421213
deleted backup piece
backup piece handle=/home/oracle/rman_bak/datafile4 recid=35 stamp=785927543
deleted backup piece
backup piece handle=/home/oracle/rman_bak/0vndgof5 recid=36 stamp=785932773
Deleted 3 EXPIRED objects
RMAN> delete noprompt EXPIRED copy;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
15 4 X 14-JUN-12 1553019 14-JUN-12 /home/oracle/users01.qq
4 4 X 08-JUN-12 1385047 08-JUN-12 /home/oracle/datafile4
List of Archived Log Copies
Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
98 1 12 X 08-JUN-12 /home/oracle/arc/1_12_785252502.arc
99 1 13 X 11-JUN-12 /home/oracle/arc/1_13_785252502.arc
100 1 14 X 11-JUN-12 /home/oracle/arc/1_14_785252502.arc
101 1 15 X 11-JUN-12 /home/oracle/arc/1_15_785252502.arc
102 1 16 X 14-JUN-12 /home/oracle/arc/1_16_785252502.arc
103 1 17 X 14-JUN-12 /home/oracle/arc/1_17_785252502.arc
104 1 18 X 14-JUN-12 /home/oracle/arc/1_18_785252502.arc
105 1 19 X 14-JUN-12 /home/oracle/arc/1_19_785252502.arc
106 1 20 X 14-JUN-12 /home/oracle/arc/1_20_785252502.arc
deleted datafile copy
datafile copy filename=/home/oracle/users01.qq recid=15 stamp=785931049
deleted datafile copy
datafile copy filename=/home/oracle/datafile4 recid=4 stamp=785415787
deleted archive log
archive log filename=/home/oracle/arc/1_12_785252502.arc recid=98 stamp=785668962
deleted archive log
archive log filename=/home/oracle/arc/1_13_785252502.arc recid=99 stamp=785693397
deleted archive log
archive log filename=/home/oracle/arc/1_14_785252502.arc recid=100 stamp=785694179
deleted archive log
archive log filename=/home/oracle/arc/1_15_785252502.arc recid=101 stamp=785925487
deleted archive log
archive log filename=/home/oracle/arc/1_16_785252502.arc recid=102 stamp=785927603
deleted archive log
archive log filename=/home/oracle/arc/1_17_785252502.arc recid=103 stamp=785927605
deleted archive log
archive log filename=/home/oracle/arc/1_18_785252502.arc recid=104 stamp=785927609
deleted archive log
archive log filename=/home/oracle/arc/1_19_785252502.arc recid=105 stamp=785927615
deleted archive log
archive log filename=/home/oracle/arc/1_20_785252502.arc recid=106 stamp=785927621
Deleted 11 EXPIRED objects
RMAN> catalog start with '/home/oracle/bk/';
searching for all files that match the pattern /home/oracle/bk/
List of Files Unknown to the Database
=====================================
File Name: /home/oracle/bk/10ndgogi
File Name: /home/oracle/bk/11ndgolv
File Name: /home/oracle/bk/0vndgof5
File Name: /home/oracle/bk/datafile4
Do you really want to catalog the above files (enter YES or NO)? y
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /home/oracle/bk/10ndgogi
File Name: /home/oracle/bk/11ndgolv
File Name: /home/oracle/bk/0vndgof5
File Name: /home/oracle/bk/datafile4
写脚本 在sqlplus 里
SQL> select 'SET NEWNAME FOR DATAFILE '||file#||' TO ''/home/oracle/db120'||substr(name,8)||'.dbf'';'from v$datafile order by 1;
'SETNEWNAMEFORDATAFILE'||FILE#||'TO''/HOME/ORACLE/DB120'||SUBSTR(NAME,8)||'.DBF'
--------------------------------------------------------------------------------
SET NEWNAME FOR DATAFILE 1 TO '/home/oracle/db120/system01.dbf.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/home/oracle/db120/undotbs01.dbf.dbf';
SET NEWNAME FOR DATAFILE 3 TO '/home/oracle/db120/sysaux01.dbf.dbf';
SET NEWNAME FOR DATAFILE 4 TO '/home/oracle/db120/users01.dbf.dbf';
RMAN> run{
SET NEWNAME FOR DATAFILE 1 TO '/home/oracle/db120/system01.dbf.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/home/oracle/db120/undotbs01.dbf.dbf';
SET NEWNAME FOR DATAFILE 3 TO '/home/oracle/db120/sysaux01.dbf.dbf';
SET NEWNAME FOR DATAFILE 4 TO '/home/oracle/db120/users01.dbf.dbf';
restore database;
switch datafile all;
recover database;
}2> 3> 4> 5> 6> 7> 8> 9>
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 14-JUN-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /home/oracle/db120/system01.dbf.dbf
restoring datafile 00002 to /home/oracle/db120/undotbs01.dbf.dbf
restoring datafile 00003 to /home/oracle/db120/sysaux01.dbf.dbf
restoring datafile 00004 to /home/oracle/db120/users01.dbf.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/bk/0vndgof5
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/bk/0vndgof5 tag=TAG20120614T103933
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 14-JUN-12
datafile 1 switched to datafile copy
input datafile copy recid=20 stamp=785924721 filename=/home/oracle/db120/system01.dbf.dbf
datafile 2 switched to datafile copy
input datafile copy recid=21 stamp=785924721 filename=/home/oracle/db120/undotbs01.dbf.dbf
datafile 3 switched to datafile copy
input datafile copy recid=22 stamp=785924721 filename=/home/oracle/db120/sysaux01.dbf.dbf
datafile 4 switched to datafile copy
input datafile copy recid=23 stamp=785924721 filename=/home/oracle/db120/users01.dbf.dbf
Starting recover at 14-JUN-12
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=21
channel ORA_DISK_1: reading from backup piece /home/oracle/bk/11ndgolv
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/bk/11ndgolv tag=TAG20120614T104310
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archive log filename=/home/oracle/arc/1_21_785252502.arc thread=1 sequence=21
unable to find archive log
archive log thread=1 sequence=22
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/14/2012 08:25:24
RMAN-06054: media recovery requesting unknown log: thread 1 seq 22 lowscn 1554658
在SQLPLUS里
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/stu221/redo03.log
/stu221/redo02.log
/stu221/redo01.log
SQL> alter database rename file '/stu221/redo03.log' to '/home/oracle/db120/redo03.log';
Database altered.
SQL> alter database rename file '/stu221/redo02.log' to '/home/oracle/db120/redo02.log';
Database altered.
SQL> alter database rename file '/stu221/redo01.log' to '/home/oracle/db120/redo01.log';
Database altered.
SQL> alter database open resetlogs;
Database altered.
处理临时文件
SQL> select * from v$tempfile;
FILE# CREATION_CHANGE# CREATION_ TS# RFILE# STATUS ENABLED
---------- ---------------- --------- ---------- ---------- ------- ----------
BYTES BLOCKS CREATE_BYTES BLOCK_SIZE
---------- ---------- ------------ ----------
NAME
--------------------------------------------------------------------------------
1 929752 29-MAY-12 3 1 ONLINE READ WRITE
0 0 10485760 8192
/stu221/temp01.dbf
SQL> create temporary tablespace temp02 tempfile '/home/oracle/db120/temp02.dbf'size 10m autoextend on;
Tablespace created.
SQL> alter database default temporary tablespace temp02 ;
Database altered.
SQL> drop tablespace temp including CONTENTS and datafiles;
Tablespace dropped.
Rman 恢复数据库
最新推荐文章于 2026-03-01 01:42:14 发布

242

被折叠的 条评论
为什么被折叠?



