Chinaunix首页 | 论坛 | 博客
  • 博客访问: 294665
  • 博文数量: 60
  • 博客积分: 1437
  • 博客等级: 中尉
  • 技术积分: 632
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-10 14:12
文章存档

2012年(7)

2011年(53)

分类: Oracle

2011-02-13 00:25:03

安装相应的数据库软件,创建好相应的目录结构
---------------------
1.创建参数文件
2.创建密码文件
3.startup nomount pfile='/home/oracle/pfile.ora'
4.rman target /
RMAN>restore controlfile from '/data/backup/controlfilebackupc-807437998-20080221-01'

[oracle@pgtest ~]$ /u01/app/oracle/product/10.2.0/db_1/bin/rman target /
 
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Feb 27 16:21:55 2008
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
connected to target database: pgrac (not mounted)
 
RMAN> restore controlfile from '/backup/controlfilebackupc-807437998-20080221-01';
 
Starting restore at 27-FEB-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1641 devtype=DISK
 
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:05
output filename=/data/pgrac/controlfile/current.260.629979631
Finished restore at 27-FEB-08
 
RMAN>
    
5.alter database mount


6.


     FILE# NAME
---------- --------------------------------------------------
         1 +DISKA/pgrac/datafile/
         2 +DISKA/pgrac/datafile/
         3 +DISKA/pgrac/datafile/
         4 +DISKA/pgrac/datafile/
         5 +DISKA/pgrac/datafile/
         6 +DISKA/pgrac/datafile/
         7 +DISKA/pgrac/datafile/
         8 +DISKA/pgrac/datafile/
         9 +DISKA/pgrac/datafile/
        10 +DISKA/pgrac/datafile/
        11 +DISKA/pgrac/datafile/
        12 +DISKA/pgrac/datafile/
        13 +DISKA/pgrac/datafile/
        14 +DISKA/pgrac/datafile/
        
        
        
run {
set newname for datafile 1   to '/data/pgrac/datafile/system.256.629979563';
set newname for datafile 2   to '/data/pgrac/datafile/undotbs1.258.629979563';
set newname for datafile 3   to '/data/pgrac/datafile/sysaux.257.629979563';
set newname for datafile 4   to '/data/pgrac/datafile/msngt.259.631465133';
set newname for datafile 5   to '/data/pgrac/datafile/undotbs2.264.629979659';
set newname for datafile 6   to '/data/pgrac/datafile/prodtbs.269.631463191';
set newname for datafile 7   to '/data/pgrac/datafile/ts_test1.328.631466649';
set newname for datafile 8   to '/data/pgrac/datafile/undotbs12.dbf';
set newname for datafile 9   to '/data/pgrac/datafile/undotbs22.dbf';
set newname for datafile 10  to '/data/pgrac/datafile/msngt.435.640462133';
set newname for datafile 11  to '/data/pgrac/datafile/msngt.362.640537171';
set newname for datafile 12  to '/data/pgrac/datafile/msngt.315.644005675';
set newname for datafile 13  to '/data/pgrac/datafile/msngt.722.645630575';
set newname for datafile 14  to '/data/pgrac/datafile/msngt.425.645630797';
restore database;
switch datafile all;
recover database;
}  

select a.group#,a.member,b.thread#,b.bytes
from v$logfile a,v$log b
where a.group#=b.group#;

    GROUP# MEMBER
---------- -----------------------------------------------
         1 +DISKA/pgrac/onlinelog/group_1.261.631211967
         1 +DISKA/pgrac/onlinelog/group_1.298.631211967
         2 +DISKA/pgrac/onlinelog/group_2.296.631211799
         2 +DISKA/pgrac/onlinelog/group_2.262.631211797
         3 +DISKA/pgrac/onlinelog/group_3.265.631212299
         3 +DISKA/pgrac/onlinelog/group_3.301.631212299
         4 +DISKA/pgrac/onlinelog/group_4.302.631212495
         4 +DISKA/pgrac/onlinelog/group_4.266.631212495
         5 +DISKA/pgrac/onlinelog/group_5.277.631211359
         5 +DISKA/pgrac/onlinelog/group_5.287.631211359
         6 +DISKA/pgrac/onlinelog/group_6.286.631211285
         6 +DISKA/pgrac/onlinelog/group_6.278.631211285
         7 +DISKA/pgrac/onlinelog/group_7.279.631211885
         7 +DISKA/pgrac/onlinelog/group_7.297.631211885
         8 +DISKA/pgrac/onlinelog/group_8.288.631211449
         8 +DISKA/pgrac/onlinelog/group_8.280.631211447
         9 +DISKA/pgrac/onlinelog/group_9.282.631209643
         9 +DISKA/pgrac/onlinelog/group_9.281.631209643
        10 +DISKA/pgrac/onlinelog/group_10.285.631210757
        10 +DISKA/pgrac/onlinelog/group_10.284.631210757
 
20 rows selected.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_1.261.631211967' to '/data/pgrac/datafile/redo11.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_1.298.631211967' to '/data/pgrac/datafile/redo12.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_2.296.631211799' to '/data/pgrac/datafile/redo21.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_2.262.631211797' to '/data/pgrac/datafile/redo22.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_3.265.631212299'  to '/data/pgrac/datafile/redo31.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_3.301.631212299'  to '/data/pgrac/datafile/redo32.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_4.302.631212495'  to '/data/pgrac/datafile/redo41.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_4.266.631212495'  to '/data/pgrac/datafile/redo42.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_5.277.631211359'  to '/data/pgrac/datafile/redo51.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_5.287.631211359'  to '/data/pgrac/datafile/redo52.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_6.286.631211285'  to '/data/pgrac/datafile/redo61.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_6.278.631211285'  to '/data/pgrac/datafile/redo62.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_7.279.631211885'  to '/data/pgrac/datafile/redo71.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_7.297.631211885'  to '/data/pgrac/datafile/redo72.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_8.288.631211449'  to '/data/pgrac/datafile/redo81.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_8.280.631211447'  to '/data/pgrac/datafile/redo82.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_9.282.631209643'  to '/data/pgrac/datafile/redo91.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_9.281.631209643'  to '/data/pgrac/datafile/redo92.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_10.285.631210757' to '/data/pgrac/datafile/redo1001.log';
 
Database altered.
 
SQL> alter database rename file '+DISKA/pgrac/onlinelog/group_10.284.631210757' to '/data/pgrac/datafile/redo1002.log';
 
Database altered.
 
SQL> alter database open resetlogs;
 
Database altered.
 
SQL> alter database drop logfile group xx --把属于thread 2的日志组统统删除

                         
RMAN> run {
2> set newname for datafile 1   to '/data/pgrac/datafile/system.256.629979563';
3> set newname for datafile 2   to '/data/pgrac/datafile/undotbs1.258.629979563';
4> set newname for datafile 3   to '/data/pgrac/datafile/sysaux.257.629979563';
5> set newname for datafile 4   to '/data/pgrac/datafile/msngt.259.631465133';
6> set newname for datafile 5   to '/data/pgrac/datafile/undotbs2.264.629979659';
7> set newname for datafile 6   to '/data/pgrac/datafile/prodtbs.269.631463191';
8> set newname for datafile 7   to '/data/pgrac/datafile/ts_test1.328.631466649';
9> set newname for datafile 8   to '/data/pgrac/datafile/undotbs12.dbf';
10> set newname for datafile 9   to '/data/pgrac/datafile/undotbs22.dbf';
11> set newname for datafile 10  to '/data/pgrac/datafile/msngt.435.640462133';
12> set newname for datafile 11  to '/data/pgrac/datafile/msngt.362.640537171';
13> set newname for datafile 12  to '/data/pgrac/datafile/msngt.315.644005675';
14> set newname for datafile 13  to '/data/pgrac/datafile/msngt.722.645630575';
15> set newname for datafile 14  to '/data/pgrac/datafile/msngt.425.645630797';
16> restore database;
17> switch datafile all;
18> recover database;
19> }
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
Starting restore at 27-FEB-08
Starting implicit crosscheck backup at 27-FEB-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1641 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=1639 devtype=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: sid=1638 devtype=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: sid=1637 devtype=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: sid=1636 devtype=DISK
allocated channel: ORA_DISK_6
channel ORA_DISK_6: sid=1635 devtype=DISK
allocated channel: ORA_DISK_7
channel ORA_DISK_7: sid=1634 devtype=DISK
allocated channel: ORA_DISK_8
channel ORA_DISK_8: sid=1633 devtype=DISK
Crosschecked 22 objects
Crosschecked 443 objects
Finished implicit crosscheck backup at 27-FEB-08
 
Starting implicit crosscheck copy at 27-FEB-08
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
using channel ORA_DISK_7
using channel ORA_DISK_8
Crosschecked 1 objects
Finished implicit crosscheck copy at 27-FEB-08
 
searching for all files in the recovery area
cataloging files...
no files cataloged
 
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
using channel ORA_DISK_7
using channel ORA_DISK_8
 
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /data/pgrac/datafile/sysaux.257.629979563
restoring datafile 00006 to /data/pgrac/datafile/prodtbs.269.631463191
channel ORA_DISK_1: reading from backup piece /backup/db_PGRAC_2283_7bj98vql.bak
channel ORA_DISK_2: starting datafile backupset restore
channel ORA_DISK_2: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /data/pgrac/datafile/msngt.259.631465133
restoring datafile 00007 to /data/pgrac/datafile/ts_test1.328.631466649
channel ORA_DISK_2: reading from backup piece /backup/db_PGRAC_2282_7aj98vql.bak
channel ORA_DISK_3: starting datafile backupset restore
channel ORA_DISK_3: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /data/pgrac/datafile/undotbs1.258.629979563
restoring datafile 00009 to /data/pgrac/datafile/undotbs22.dbf
channel ORA_DISK_3: reading from backup piece /backup/db_PGRAC_2285_7dj98vqm.bak
channel ORA_DISK_4: starting datafile backupset restore
channel ORA_DISK_4: specifying datafile(s) to restore from backup set
restoring datafile 00005 to /data/pgrac/datafile/undotbs2.264.629979659
restoring datafile 00010 to /data/pgrac/datafile/msngt.435.640462133
channel ORA_DISK_4: reading from backup piece /backup/db_PGRAC_2286_7ej98vqm.bak
channel ORA_DISK_5: starting datafile backupset restore
channel ORA_DISK_5: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /data/pgrac/datafile/system.256.629979563
restoring datafile 00008 to /data/pgrac/datafile/undotbs12.dbf
channel ORA_DISK_5: reading from backup piece /backup/db_PGRAC_2284_7cj98vql.bak
channel ORA_DISK_6: starting datafile backupset restore
channel ORA_DISK_6: specifying datafile(s) to restore from backup set
restoring datafile 00011 to /data/pgrac/datafile/msngt.362.640537171
restoring datafile 00012 to /data/pgrac/datafile/msngt.315.644005675
channel ORA_DISK_6: reading from backup piece /backup/db_PGRAC_2281_79j98vql.bak
channel ORA_DISK_7: starting datafile backupset restore
channel ORA_DISK_7: specifying datafile(s) to restore from backup set
restoring datafile 00013 to /data/pgrac/datafile/msngt.722.645630575
restoring datafile 00014 to /data/pgrac/datafile/msngt.425.645630797
channel ORA_DISK_7: reading from backup piece /backup/db_PGRAC_2280_78j98vqi.bak
channel ORA_DISK_7: restored backup piece 1
piece handle=/backup/db_PGRAC_2280_78j98vqi.bak tag=TAG20080221T120849
channel ORA_DISK_7: restore complete, elapsed time: 00:06:10
channel ORA_DISK_1: restored backup piece 1
piece handle=/backup/db_PGRAC_2283_7bj98vql.bak tag=TAG20080221T120849
channel ORA_DISK_1: restore complete, elapsed time: 00:12:18
channel ORA_DISK_3: restored backup piece 1
piece handle=/backup/db_PGRAC_2285_7dj98vqm.bak tag=TAG20080221T120849
channel ORA_DISK_3: restore complete, elapsed time: 00:13:23
channel ORA_DISK_2: restored backup piece 1
piece handle=/backup/db_PGRAC_2282_7aj98vql.bak tag=TAG20080221T120849
channel ORA_DISK_2: restore complete, elapsed time: 00:14:38
channel ORA_DISK_4: restored backup piece 1
piece handle=/backup/db_PGRAC_2286_7ej98vqm.bak tag=TAG20080221T120849
channel ORA_DISK_4: restore complete, elapsed time: 00:14:38
channel ORA_DISK_5: restored backup piece 1
piece handle=/backup/db_PGRAC_2284_7cj98vql.bak tag=TAG20080221T120849
channel ORA_DISK_5: restore complete, elapsed time: 00:16:43
channel ORA_DISK_6: restored backup piece 1
piece handle=/backup/db_PGRAC_2281_79j98vql.bak tag=TAG20080221T120849
channel ORA_DISK_6: restore complete, elapsed time: 00:17:08
Finished restore at 27-FEB-08
 
datafile 1 switched to datafile copy
input datafile copy recid=25 stamp=647801694 filename=/data/pgrac/datafile/system.256.629979563
datafile 2 switched to datafile copy
input datafile copy recid=26 stamp=647801694 filename=/data/pgrac/datafile/undotbs1.258.629979563
datafile 3 switched to datafile copy
input datafile copy recid=27 stamp=647801694 filename=/data/pgrac/datafile/sysaux.257.629979563
datafile 4 switched to datafile copy
input datafile copy recid=28 stamp=647801694 filename=/data/pgrac/datafile/msngt.259.631465133
datafile 5 switched to datafile copy
input datafile copy recid=29 stamp=647801694 filename=/data/pgrac/datafile/undotbs2.264.629979659
datafile 6 switched to datafile copy
input datafile copy recid=30 stamp=647801694 filename=/data/pgrac/datafile/prodtbs.269.631463191
datafile 7 switched to datafile copy
input datafile copy recid=31 stamp=647801694 filename=/data/pgrac/datafile/ts_test1.328.631466649
datafile 8 switched to datafile copy
input datafile copy recid=32 stamp=647801694 filename=/data/pgrac/datafile/undotbs12.dbf
datafile 9 switched to datafile copy
input datafile copy recid=33 stamp=647801694 filename=/data/pgrac/datafile/undotbs22.dbf
datafile 10 switched to datafile copy
input datafile copy recid=34 stamp=647801694 filename=/data/pgrac/datafile/msngt.435.640462133
datafile 11 switched to datafile copy
input datafile copy recid=35 stamp=647801694 filename=/data/pgrac/datafile/msngt.362.640537171
datafile 12 switched to datafile copy
input datafile copy recid=36 stamp=647801694 filename=/data/pgrac/datafile/msngt.315.644005675
datafile 13 switched to datafile copy
input datafile copy recid=37 stamp=647801694 filename=/data/pgrac/datafile/msngt.722.645630575
datafile 14 switched to datafile copy
input datafile copy recid=38 stamp=647801694 filename=/data/pgrac/datafile/msngt.425.645630797
 
Starting recover at 27-FEB-08
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
using channel ORA_DISK_5
using channel ORA_DISK_6
using channel ORA_DISK_7
using channel ORA_DISK_8
 
starting media recovery
 
channel ORA_DISK_2: starting archive log restore to default destination
channel ORA_DISK_3: starting archive log restore to default destination
channel ORA_DISK_4: starting archive log restore to default destination
channel ORA_DISK_5: starting archive log restore to default destination
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_2: restoring archive log
archive log thread=1 sequence=13353
channel ORA_DISK_3: restoring archive log
archive log thread=1 sequence=13348
channel ORA_DISK_3: reading from backup piece /backup/dbPGRAC22897hj9906d.arc
channel ORA_DISK_4: restoring archive log
archive log thread=1 sequence=13351
channel ORA_DISK_5: restoring archive log
archive log thread=1 sequence=13349
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=16024
channel ORA_DISK_2: restoring archive log
archive log thread=2 sequence=16023
channel ORA_DISK_2: reading from backup piece /backup/dbPGRAC22907ij9906d.arc
channel ORA_DISK_4: restoring archive log
archive log thread=1 sequence=13352
channel ORA_DISK_4: reading from backup piece /backup/dbPGRAC22887gj9906d.arc
channel ORA_DISK_5: restoring archive log
archive log thread=1 sequence=13350
channel ORA_DISK_5: reading from backup piece /backup/dbPGRAC22877fj9906d.arc
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=16025
channel ORA_DISK_1: reading from backup piece /backup/dbPGRAC22917jj9906d.arc
channel ORA_DISK_1: restored backup piece 1
piece handle=/backup/dbPGRAC22917jj9906d.arc tag=TAG20080221T121509
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_DISK_2: restored backup piece 1
piece handle=/backup/dbPGRAC22907ij9906d.arc tag=TAG20080221T121509
channel ORA_DISK_2: restore complete, elapsed time: 00:00:38
archive log filename=/backup/2_16023_629979632.dbf thread=2 sequence=16023
channel ORA_DISK_3: restored backup piece 1
piece handle=/backup/dbPGRAC22897hj9906d.arc tag=TAG20080221T121509
channel ORA_DISK_3: restore complete, elapsed time: 00:00:38
archive log filename=/backup/1_13348_629979632.dbf thread=1 sequence=13348
archive log filename=/backup/2_16024_629979632.dbf thread=2 sequence=16024
channel ORA_DISK_4: restored backup piece 1
piece handle=/backup/dbPGRAC22887gj9906d.arc tag=TAG20080221T121509
channel ORA_DISK_4: restore complete, elapsed time: 00:00:56
channel ORA_DISK_5: restored backup piece 1
piece handle=/backup/dbPGRAC22877fj9906d.arc tag=TAG20080221T121509
channel ORA_DISK_5: restore complete, elapsed time: 00:00:56
archive log filename=/backup/1_13349_629979632.dbf thread=1 sequence=13349
archive log filename=/backup/1_13350_629979632.dbf thread=1 sequence=13350
archive log filename=/backup/1_13351_629979632.dbf thread=1 sequence=13351
archive log filename=/backup/2_16025_629979632.dbf thread=2 sequence=16025
archive log filename=/backup/1_13352_629979632.dbf thread=1 sequence=13352
archive log filename=/backup/1_13353_629979632.dbf thread=1 sequence=13353
unable to find archive log
archive log thread=2 sequence=16026
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/27/2008 16:57:02
RMAN-06054: media recovery requesting unknown log: thread 2 seq 16026 lowscn 1176653565
 
RMAN> exit
 
 
Recovery Manager complete.

注意:第二次测试的时候,首先要:

RMAN>list incarnation;

Found the incarnation

RMAN>reset database to incarnation 1


阅读(1531) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~