标签:oracle
准备参数文件:
[oracle@erpdev ~]$ cat pfileCWERPDB.ora
CWERPDB.__db_cache_size=8959033344
CWERPDB.__java_pool_size=67108864
CWERPDB.__large_pool_size=100663296
CWERPDB.__oracle_base=‘/home/u01/oracle‘#ORACLE_BASE set from environment
CWERPDB.__pga_aggregate_target=2684354560
CWERPDB.__sga_target=10737418240
CWERPDB.__shared_io_pool_size=0
CWERPDB.__shared_pool_size=1509949440
CWERPDB.__streams_pool_size=33554432
*.audit_file_dest=‘/home/u01/oracle/admin/CWERPDB/adump‘
*.audit_trail=‘db‘
*.compatible=‘11.2.0.4.0‘
*.control_files=‘/home/u01/oracle/oradata/CWERPDB/control01.ctl‘,‘/home/u01/oracle/fast_recovery_area/CWERPDB/control02.ctl‘
*.db_block_size=8192
*.db_domain=‘‘
*.db_name=‘CWERPDB‘
*.db_recovery_file_dest=‘/home/u01/oracle/fast_recovery_area/CWERPDB/‘
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest=‘/home/u01/oracle‘
*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=CWERPDBXDB)‘
*.open_cursors=300
*.pga_aggregate_target=2684354560
*.processes=1000
*.remote_login_passwordfile=‘EXCLUSIVE‘
*.sec_case_sensitive_logon=FALSE
*.sga_max_size=10737418240
*.sga_target=10737418240
*.undo_tablespace=‘UNDOTBS1‘ ;
启动数据库到nomount:
SQL> startup nomount pfile=‘/home/oracle/pfileCWERPDB.ora‘;
ORACLE instance started.
Total System Global Area 1.0689E+10 bytes
Fixed Size 2262656 bytes
Variable Size 2013268352 bytes
Database Buffers 8657043456 bytes
Redo Buffers 16900096 bytes
恢复控制文件:
RMAN> restore controlfile from ‘/home/oracle/level0/data_0uqpkqld_1_1.bak‘;
Starting restore at 24-DEC-15
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/home/u01/oracle/oradata/CWERPDB/control01.ctl
output file name=/home/u01/oracle/fast_recovery_area/CWERPDB/control02.ctl
Finished restore at 24-DEC-15
挂载数据库:
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
注册备份集:
RMAN> catalog start with ‘/home/oracle/level0‘;
Starting implicit crosscheck backup at 24-DEC-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=958 device type=DISK
Crosschecked 19 objects
Finished implicit crosscheck backup at 24-DEC-15
Starting implicit crosscheck copy at 24-DEC-15
using channel ORA_DISK_1
Finished implicit crosscheck copy at 24-DEC-15
searching for all files in the recovery area
cataloging files...
no files cataloged
searching for all files that match the pattern /home/oracle/level0
List of Files Unknown to the Database
=====================================
File Name: /home/oracle/level0/arc_CWERPDBx_20151224_10qpkqok_1_1
File Name: /home/oracle/level0/data_0nqpkqa4_1_1.bak
File Name: /home/oracle/level0/data_0qqpkqak_1_1.bak
File Name: /home/oracle/level0/data_0sqpkqau_1_1.bak
File Name: /home/oracle/level0/data_0vqpkqlf_1_1.bak
File Name: /home/oracle/level0/data_0tqpkqld_1_1.bak
File Name: /home/oracle/level0/data_0uqpkqld_1_1.bak
File Name: /home/oracle/level0/data_0rqpkqar_1_1.bak
File Name: /home/oracle/level0/data_0oqpkqa4_1_1.bak
File Name: /home/oracle/level0/data_0mqpkqa1_1_1.bak
File Name: /home/oracle/level0/data_0pqpkqaj_1_1.bak
File Name: /home/oracle/level0/data_0lqpkqa1_1_1.bak
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /home/oracle/level0/arc_CWERPDBx_20151224_10qpkqok_1_1
File Name: /home/oracle/level0/data_0nqpkqa4_1_1.bak
File Name: /home/oracle/level0/data_0qqpkqak_1_1.bak
File Name: /home/oracle/level0/data_0sqpkqau_1_1.bak
File Name: /home/oracle/level0/data_0vqpkqlf_1_1.bak
File Name: /home/oracle/level0/data_0tqpkqld_1_1.bak
File Name: /home/oracle/level0/data_0uqpkqld_1_1.bak
File Name: /home/oracle/level0/data_0rqpkqar_1_1.bak
File Name: /home/oracle/level0/data_0oqpkqa4_1_1.bak
File Name: /home/oracle/level0/data_0mqpkqa1_1_1.bak
File Name: /home/oracle/level0/data_0pqpkqaj_1_1.bak
File Name: /home/oracle/level0/data_0lqpkqa1_1_1.bak
与原来的库文件路径不一样,用set newname 修改
脚本:
run
{set newname for datafile 4 to "/home/u01/oracle/oradata/CWERPDB/users.259.886161065";
set newname for datafile 3 to "/home/u01/oracle/oradata/CWERPDB/undotbs1.258.886161065";
set newname for datafile 2 to "/home/u01/oracle/oradata/CWERPDB/sysaux.257.886161065";
set newname for datafile 1 to "/home/u01/oracle/oradata/CWERPDB/system.256.886161065";
set newname for datafile 5 to "/home/u01/oracle/oradata/CWERPDB/proframe.dbf";
set newname for datafile 6 to "/home/u01/oracle/oradata/CWERPDB/proframe01.dbf";
set newname for datafile 7 to "/home/u01/oracle/oradata/CWERPDB/cosmos_in01.dbf";
set newname for datafile 8 to "/home/u01/oracle/oradata/CWERPDB/cosmos_in02.dbf";
set newname for datafile 9 to "/home/u01/oracle/oradata/CWERPDB/cosmos_in03.dbf";
set newname for datafile 10 to "/home/u01/oracle/oradata/CWERPDB/cosmos01.dbf";
set newname for datafile 11 to "/home/u01/oracle/oradata/CWERPDB/cosmos02.dbf";
set newname for datafile 12 to "/home/u01/oracle/oradata/CWERPDB/cosmos03.dbf";
set newname for datafile 13 to "/home/u01/oracle/oradata/CWERPDB/APPORACLEORADATAPGSCMEXAMPLE01.DBF";
set newname for datafile 14 to "/home/u01/oracle/oradata/CWERPDB/statlog.dbf";
restore database;
switch datafile all;}
执行过程:
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 CWERPDB 490184294 PARENT 1 24-AUG-13
2 2 CWERPDB 490184294 PARENT 925702 27-JUL-15
3 3 CWERPDB 490184294 ORPHAN 12939483587242 24-DEC-15
4 4 CWERPDB 490184294 CURRENT 12939484174408 29-DEC-15
RMAN> reset database to incarnation 2;
database reset to incarnation 2
run
{set newname for datafile 4 to "/home/u01/oracle/oradata/CWERPDB/users.259.886161065";
set newname for datafile 3 to "/home/u01/oracle/oradata/CWERPDB/undotbs1.258.886161065";
set newname for datafile 2 to "/home/u01/oracle/oradata/CWERPDB/sysaux.257.886161065";
set newname for datafile 1 to "/home/u01/oracle/oradata/CWERPDB/system.256.886161065";
set newname for datafile 5 to "/home/u01/oracle/oradata/CWERPDB/proframe.dbf";
set newname for datafile 6 to "/home/u01/oracle/oradata/CWERPDB/proframe01.dbf";
set newname for datafile 7 to "/home/u01/oracle/oradata/CWERPDB/cosmos_in01.dbf";
set newname for datafile 8 to "/home/u01/oracle/oradata/CWERPDB/cosmos_in02.dbf";
set newname for datafile 9 to "/home/u01/oracle/oradata/CWERPDB/cosmos_in03.dbf";
set newname for datafile 10 to "/home/u01/oracle/oradata/CWERPDB/cosmos01.dbf";
set newname for datafile 11 to "/home/u01/oracle/oradata/CWERPDB/cosmos02.dbf";
set newname for datafile 12 to "/home/u01/oracle/oradata/CWERPDB/cosmos03.dbf";
set newname for datafile 13 to "/home/u01/oracle/oradata/CWERPDB/APPORACLEORADATAPGSCMEXAMPLE01.DBF";
set newname for datafile 14 to "/home/u01/oracle/oradata/CWERPDB/statlog.dbf";
restore database;
17> switch datafile all;}
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 24-DEC-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00008 to /home/u01/oracle/oradata/CWERPDB/cosmos_in02.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/level0/data_0lqpkqa1_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/level0/data_0lqpkqa1_1_1.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:55
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00009 to /home/u01/oracle/oradata/CWERPDB/cosmos_in03.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/level0/data_0mqpkqa1_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/level0/data_0mqpkqa1_1_1.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:56
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00010 to /home/u01/oracle/oradata/CWERPDB/cosmos01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/level0/data_0nqpkqa4_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/level0/data_0nqpkqa4_1_1.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:55
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00011 to /home/u01/oracle/oradata/CWERPDB/cosmos02.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/level0/data_0oqpkqa4_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/level0/data_0oqpkqa4_1_1.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:05
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00012 to /home/u01/oracle/oradata/CWERPDB/cosmos03.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/level0/data_0pqpkqaj_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/level0/data_0pqpkqaj_1_1.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:15
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00007 to /home/u01/oracle/oradata/CWERPDB/cosmos_in01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/level0/data_0rqpkqar_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/level0/data_0rqpkqar_1_1.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:05
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00005 to /home/u01/oracle/oradata/CWERPDB/proframe.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/level0/data_0qqpkqak_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/level0/data_0qqpkqak_1_1.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:06:55
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00006 to /home/u01/oracle/oradata/CWERPDB/proframe01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/level0/data_0sqpkqau_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/level0/data_0sqpkqau_1_1.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:06:15
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /home/u01/oracle/oradata/CWERPDB/system.256.886161065
channel ORA_DISK_1: restoring datafile 00002 to /home/u01/oracle/oradata/CWERPDB/sysaux.257.886161065
channel ORA_DISK_1: restoring datafile 00003 to /home/u01/oracle/oradata/CWERPDB/undotbs1.258.886161065
channel ORA_DISK_1: restoring datafile 00004 to /home/u01/oracle/oradata/CWERPDB/users.259.886161065
channel ORA_DISK_1: restoring datafile 00013 to /home/u01/oracle/oradata/CWERPDB/APPORACLEORADATAPGSCMEXAMPLE01.DBF
channel ORA_DISK_1: restoring datafile 00014 to /home/u01/oracle/oradata/CWERPDB/statlog.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/level0/data_0tqpkqld_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/level0/data_0tqpkqld_1_1.bak tag=DB0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:15
Finished restore at 24-DEC-15
datafile 1 switched to datafile copy
input datafile copy RECID=15 STAMP=899315427 file name=/home/u01/oracle/oradata/CWERPDB/system.256.886161065
datafile 2 switched to datafile copy
input datafile copy RECID=16 STAMP=899315428 file name=/home/u01/oracle/oradata/CWERPDB/sysaux.257.886161065
datafile 3 switched to datafile copy
input datafile copy RECID=17 STAMP=899315428 file name=/home/u01/oracle/oradata/CWERPDB/undotbs1.258.886161065
datafile 4 switched to datafile copy
input datafile copy RECID=18 STAMP=899315428 file name=/home/u01/oracle/oradata/CWERPDB/users.259.886161065
datafile 5 switched to datafile copy
input datafile copy RECID=19 STAMP=899315428 file name=/home/u01/oracle/oradata/CWERPDB/proframe.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=20 STAMP=899315428 file name=/home/u01/oracle/oradata/CWERPDB/proframe01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=21 STAMP=899315428 file name=/home/u01/oracle/oradata/CWERPDB/cosmos_in01.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=22 STAMP=899315429 file name=/home/u01/oracle/oradata/CWERPDB/cosmos_in02.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=23 STAMP=899315429 file name=/home/u01/oracle/oradata/CWERPDB/cosmos_in03.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=24 STAMP=899315429 file name=/home/u01/oracle/oradata/CWERPDB/cosmos01.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=25 STAMP=899315429 file name=/home/u01/oracle/oradata/CWERPDB/cosmos02.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=26 STAMP=899315429 file name=/home/u01/oracle/oradata/CWERPDB/cosmos03.dbf
datafile 13 switched to datafile copy
input datafile copy RECID=27 STAMP=899315430 file name=/home/u01/oracle/oradata/CWERPDB/APPORACLEORADATAPGSCMEXAMPLE01.DBF
datafile 14 switched to datafile copy
input datafile copy RECID=28 STAMP=899315430 file name=/home/u01/oracle/oradata/CWERPDB/statlog.dbf
恢复数据库:
RMAN> recover database;
Starting recover at 24-DEC-15
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=2588
channel ORA_DISK_1: reading from backup piece /home/oracle/level0/arc_CWERPDBx_20151224_10qpkqok_1_1
channel ORA_DISK_1: piece handle=/home/oracle/level0/arc_CWERPDBx_20151224_10qpkqok_1_1 tag=TAG20151224T170004
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/home/u01/oracle/fast_recovery_area/CWERPDB/CWERPDB/archivelog/2015_12_24/o1_mf_1_2588_c7qj4y3y_.arc thread=1 sequence=2588
channel default: deleting archived log(s)
archived log file name=/home/u01/oracle/fast_recovery_area/CWERPDB/CWERPDB/archivelog/2015_12_24/o1_mf_1_2588_c7qj4y3y_.arc RECID=2581 STAMP=899315614
unable to find archived log
archived log thread=1 sequence=2589
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/24/2015 17:53:36
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 2589 and starting SCN of 12939483587241
以不完全方式打开数据:
RMAN> alter database open resetlogs;
database opened
检查日志文件:
SQL> select group#,member from v$logfile;
GROUP# MEMBER
---------- ----------------------------------------------------------------------------------------------------
3 /home/u01/oracle/fast_recovery_area/CWERPDB/CWERPDB/onlinelog/o1_mf_3_c7qj76nt_.log
2 /home/u01/oracle/fast_recovery_area/CWERPDB/CWERPDB/onlinelog/o1_mf_2_c7qj75yt_.log
1 /home/u01/oracle/fast_recovery_area/CWERPDB/CWERPDB/onlinelog/o1_mf_1_c7qj7584_.log
SQL> select group#,bytes/1024/1024,status from v$log;
GROUP# BYTES/1024/1024 STATUS
---------- --------------- ----------------
1 50 CURRENT
2 50 UNUSED
3 50 UNUSED
检查临时表空间:
SQL> select file_id,file_name from dba_temp_files;
select file_id,file_name from dba_temp_files
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: ‘+DATA/cwerpdb/tempfile/temp.264.886161131‘
建立新临时表空间:
SQL> create temporary tablespace temp1 tempfile ‘/home/u01/oracle/oradata/CWERPDB/temp02.dbf‘ size 100M;
Tablespace created.
SQL> alter database default temporary tablespace temp1;
Database altered.
SQL> drop tablespace temp including contents and datafiles;
Tablespace dropped.
====完成-=======
备份脚本:
rman_bk.sh
rman target /<<eof
run
{
allocate channel C1 device type disk;
allocate channel C2 device type disk;
sql ‘alter system switch logfile‘;
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup incremental level=0 tag=‘DB0‘ database format ‘/bak/orabak/erpdb/level0/data_%U.bak‘;
backup current controlfile format ‘/bak/orabak/erpdb/level0/ctl_%U.bak‘;
crosscheck backup;
delete noprompt obsolete;
delete noprompt expired backup;
delete noprompt force archivelog until time ‘sysdate-16‘;
sql ‘alter system archive log current‘;
backup archivelog all format ‘/bak/orabak/erpdb/level0/arc_%n_%T_%U‘;
release channel C1;
release channel C2;}
eof
sqlplus / as sysdba<<eoh
set lines 200 pagesize 1000;
col file_name for a100;
select file_id,file_name from dba_data_files order by 1;
create pfile=‘/bak/orabak/erpdb/pfile.ora‘ from spfile;
exit;
eoh
run_rman.sh
#!/bin/bash
rm -rf /bak/orabak/erpdb/rman_*
current_day=`date +%Y%m%d`
/home/oracle/rman_bk.sh>/bak/orabak/erpdb/rman_$current_day.log
标签:oracle
原文地址:http://7642644.blog.51cto.com/7632644/1730088