RMAN 备份脚本 -->注意格式的写法\IPShared_folder ( 试验有问题)
run{ allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
backup database format='F: man_bkpTE02PRDfull_%d_%U' tag='full_bak';
sql "alter system archive log current";
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup archivelog all format='F: man_bkpTE02PRDlog_%d_%U' delete input tag='log_bak';
backup current controlfile format ='F: man_bkpTE02PRD\%d_controlfile%s.dbf' tag='controlfile_bak';
release channel ch1;
release channel ch2;
}
run{
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
backup database format='F: man_bkpTE02SAPfull_%d_%U' tag='full_bak';
sql "alter system archive log current";
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup archivelog all format='F: man_bkpTE02SAPlog_%d_%U' delete input tag='log_bak';
backup current controlfile format='F: man_bkpTE02SAP\%d_controlfile%s.dbf' tag='controlfile_bak';
release channel ch1;
release channel ch2;
}
--------------------------STEPS--------------------------------
first of all, use dbca to create an instance(safe) set ORACLE_HOME=D:oracleproduct12.1.0dbhome_1
DBCA: NLS_CHARACTERSET AR8ISO8859P6
NLS_LANGUAGE AMERICAN
1. 拷贝一个pfile过来 需要修改的路径修改下
2. 使用这个pfile启动数据库
startup nomount pfile='F: man_bkpTE02prdpfilenew.ora';
create spfile from pfile='F: man_bkpTE02prdpfilenew.ora';
3. 还原控制文件
list backup of controlfile;
--restore controlfile from 'F: man_bkpTE02PRDTE02PRD_535.DBF';
--restore controlfile from 'F: man_bkpTE02PRDTE02PRD_CONTROLFILE536.DBF';
restore controlfile from 'D:Oracleproduct12.1.0dbhome_1databaseTE02PRD_CONTROLFILE536.DBF';
restore controlfile from 'D:Oracleproduct12.1.0dbhome_1databaseTE02PRD_CONTROLFILE558.DBF';
alter database mount;
RMAN-12010: automatic channel allocation initialization failed
RMAN-06189: current DBID 1442122161 does not match target mounted database (1318669939)
shutdown abort;
startup nomount;
set dbid=1318669939
4.restore database
--catalog start with '\PEPWDR00522 man_bkpTE02PRD';
--catalog start with 'F: man_bkpTE02PRD';
catalog start with 'D:Oracleproduct12.1.0dbhome_1database';
run{ set newname for datafile 1 to 'F:ORACLEORADATATE02PRDSYSTEM01.DBF';
set newname for datafile 2 to 'F:ORACLEORADATATE02PRDSYSAUX01.DBF';
set newname for datafile 3 to 'F:ORACLEORADATATE02PRDUNDOTBS01.DBF';
set newname for datafile 4 to 'F:ORACLEORADATATE02PRDUSERS01.DBF';
set newname for datafile 5 to 'F:ORACLEORADATATE02PRDTEMP01.DBF';
set newname for datafile 6 to 'F:ORACLEORADATATE02PRDCWMLITE01.DBF';
set newname for datafile 7 to 'F:ORACLEORADATATE02PRDRED04.DBF';
set newname for datafile 8 to 'F:ORACLEORADATATE02PRDDRSYS01.DBF';
set newname for datafile 9 to 'F:ORACLEORADATATE02PRDPSD_TMP01.DBF';
set newname for datafile 10 to 'F:ORACLEORADATATE02PRDEXAMPLE01.DBF';
set newname for datafile 11 to 'F:ORACLEORADATATE02PRDRED05.DBF';
set newname for datafile 12 to 'F:ORACLEORADATATE02PRDRED06.DBF';
set newname for datafile 13 to 'F:ORACLEORADATATE02PRDINDX01.DBF';
set newname for datafile 14 to 'F:ORACLEORADATATE02PRDODM01.DBF';
set newname for datafile 15 to 'F:ORACLEORADATATE02PRDAUE_AUDIT01.DBF';
set newname for datafile 16 to 'F:ORACLEORADATATE02PRDPSD_DATA01.DBF';
set newname for datafile 17 to 'F:ORACLEORADATATE02PRDPSD_DATA02.DBF';
set newname for datafile 18 to 'F:ORACLEORADATATE02PRDPSD_DATA03.DBF';
set newname for datafile 19 to 'F:ORACLEORADATATE02PRDPSD_DATA04.DBF';
set newname for datafile 20 to 'F:ORACLEORADATATE02PRDPSD_DATA05.DBF';
set newname for datafile 21 to 'F:ORACLEORADATATE02PRDPSD_DATA06.DBF';
set newname for datafile 22 to 'F:ORACLEORADATATE02PRDPSD_INDX01.DBF';
set newname for datafile 23 to 'F:ORACLEORADATATE02PRDPSD_INDX02.DBF';
set newname for datafile 24 to 'F:ORACLEORADATATE02PRDPSD_INDX03.DBF';
set newname for datafile 25 to 'F:ORACLEORADATATE02PRDPSD_INDX04.DBF';
set newname for datafile 26 to 'F:ORACLEORADATATE02PRDPSD_INDX05.DBF';
set newname for datafile 27 to 'F:ORACLEORADATATE02PRDPSD_INDX06.DBF';
set newname for datafile 28 to 'F:ORACLEORADATATE02PRDPSD_INDX07.DBF';
set newname for datafile 29 to 'F:ORACLEORADATATE02PRDPSD_INDX08.DBF';
set newname for datafile 30 to 'F:ORACLEORADATATE02PRDTOOLS01.DBF';
set newname for datafile 31 to 'F:ORACLEORADATATE02PRDXDB01.DBF';
set newname for datafile 32 to 'F:ORACLEORADATATE02PRDAUDIT_01.DBF';
restore database;
switch datafile all;
}
5.recover database
recover database until scn 7976153251; --RMAN-06054 select open_mode from v$database;
alter database open resetlogs;
---modify service path sc config dhcp start= demand sc create baidujingyan binPath= "C:WINDOWSSystem32 otepad.exe" start= auto sc delete baidujingyan sc config OracleOraDB12Home1TNSListener binPath= "D:Oracleproduct12.1.0dbhome_1BINTNSLSNR" start= auto OR 注册表regedit 根据路径HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices,找到你想改路径的服务, 也可以利用注册表自带的搜索功能,查找你想要修改的路径 在目录下有一键名是“ImagePath”的就是可执行路径,将其数值数据改为新的可执行路径即可
----TE02SAP STEPS ------------------------------------------
set ORACLE_SID=TE02SAP
rman target /
select open_mode from v$database;
shutdown immediate;
startup nomount pfile='F: man_bkpTE02sappfilenew.ora';
create spfile from pfile='F: man_bkpTE02sappfilenew.ora';
restore controlfile from 'D:Oracleproduct12.1.0dbhome_1databaseTE02SAP_CONTROLFILE515.DBF';
alter database mount;
catalog start with 'D:Oracleproduct12.1.0dbhome_1database'; --yes
(RMAN-03002: ▌╘ط ├ع╤ catalog ┌غ╧ 03/10/2017 09:15:40 RMAN-06189: ط╟ و╩╪╟╚▐ DBID 3696784347 ╟ط═╟طو ع┌ ف╧▌ ▐╟┌╧╔ ╟ط╚و╟غ╟╩ ╟ط╩و ╩ع ╩µ╒وطف╟ (3693633199) shutdown immediate; startup nomount; set dbid=3693633199 --nomount set alter database mount; )
restore database;
switch datafile all;
recover database until scn 7976154761;
alter database open resetlogs;
----------------------------------------------------------
recover database using backup controlfile until cancel;
run{ set until time "to_date('2017/03/10 07:00:00','yyyy/mm/dd hh24:mi:ss')"; recover database ; } RMAN> run{ ALLOCATE CHANNEL t1 TYPE disk; sql 'alter session set NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"'; sql 'alter session set NLS_LANGUAGE=American'; set until time='2017-03-10 07:00:00'; recover database; release channel t1; } ----------recreate controlfile sometimes need------------------------- SQL> alter database backup controlfile to trace;
Database altered.
确认追踪文件的路径:
SQL> select value from v$diag_info 2 where name='Default Trace File';
------------------------------------------------------
database (file://server1/database)
RMAN> show all;
run{ allocate channel ch1 type disk;
delete noprompt obsolete;
restore database;
recover database;
release channel ch1; }
RMAN> backup current controlfile;
Starting backup at 09-MAR-17 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current control file in backup set channel ORA_DISK_1: starting piece 1 at 09-MAR-17 channel ORA_DISK_1: finished piece 1 at 09-MAR-17 piece handle=D:ORACLEPRODUCT12.1.0DBHOME_1DATABASEFPRUNC1K_1_1 tag=TAG2017 0309T170908 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03 Finished backup at 09-MAR-17
http://blog.csdn.net/msdnchina/article/details/49443693
----
F: man_bkp>oradim -delete -sid TE02SAP
create spfile from pfile='F: man_bkpinitTE02SAP.ora';
---------------源库信息 D:oracleproduct12.1.0dbhome_1database
C:Usersalley_li>oradim -new -sid oratest Enter password for Oracle service user: DIM-00019: create service error O/S-Error: (OS 5) Access is denied.
set ORACLE_BASE=D:oracleproduct12.1.0
set ORACLE_HOME=D:oracleproduct12.1.0dbhome_1
DBCA: NLS_CHARACTERSET AR8ISO8859P6 NLS_LANGUAGE AMERICAN
ORACLE_SID=TE02PRD
C:Windowssystem32>set ORACLE_SID=TE02PRD
C:Windowssystem32>sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Mar 9 19:
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2. With the Partitioning, OLAP, Advanced Analytics and Real ions
SQL> select file_name from dba_Data_files;
FILE_NAME
--------------------------------------------------------
D:ORACLEORADATATE02PRDSYSTEM01.DBF
D:ORACLEORADATATE02PRDSYSAUX01.DBF
D:ORACLEORADATATE02PRDUNDOTBS01.DBF
D:ORACLEORADATATE02PRDUSERS01.DBF
F:ORACLEORADATATE02PRDCWMLITE01.DBF
F:ORACLEORADATATE02PRDTEMP01.DBF
F:ORACLEORADATATE02PRDPSD_TMP01.DBF
F:ORACLEORADATATE02PRDDRSYS01.DBF
F:ORACLEORADATATE02PRDRED04.DBF
F:ORACLEORADATATE02PRDRED05.DBF
F:ORACLEORADATATE02PRDEXAMPLE01.DBF
FILE_NAME
--------------------------------------------------------
F:ORACLEORADATATE02PRDINDX01.DBF
F:ORACLEORADATATE02PRDRED06.DBF
F:ORACLEORADATATE02PRDODM01.DBF
F:ORACLEORADATATE02PRDAUE_AUDIT01.DBF
F:ORACLEORADATATE02PRDPSD_DATA06.DBF
F:ORACLEORADATATE02PRDPSD_DATA05.DBF
F:ORACLEORADATATE02PRDPSD_DATA04.DBF
F:ORACLEORADATATE02PRDPSD_DATA03.DBF
F:ORACLEORADATATE02PRDPSD_DATA02.DBF
F:ORACLEORADATATE02PRDPSD_DATA01.DBF
F:ORACLEORADATATE02PRDPSD_INDX08.DBF
FILE_NAME
--------------------------------------------------------
F:ORACLEORADATATE02PRDPSD_INDX07.DBF
F:ORACLEORADATATE02PRDPSD_INDX06.DBF
F:ORACLEORADATATE02PRDPSD_INDX05.DBF
F:ORACLEORADATATE02PRDPSD_INDX04.DBF
F:ORACLEORADATATE02PRDPSD_INDX03.DBF
F:ORACLEORADATATE02PRDPSD_INDX02.DBF
F:ORACLEORADATATE02PRDPSD_INDX01.DBF
F:ORACLEORADATATE02PRDTOOLS01.DBF
F:ORACLEORADATATE02PRDXDB01.DBF
F:ORACLEORADATATE02PRDAUDIT_01.DBF
32 rows selected.
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------
F:ORACLEORADATATE02PRDREDO03A.LOG
D:ORACLEORADATATE02PRDREDO03B.LOG
F:ORACLEORADATATE02PRDREDO02A.LOG
D:ORACLEORADATATE02PRDREDO02B.LOG
F:ORACLEORADATATE02PRDREDO01A.LOG
D:ORACLEORADATATE02PRDREDO01B.LOG
6 rows selected.
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------
F:ORACLEORADATATE02PRDCONTROL01.CTL
F:ORACLEORADATATE02PRDCONTROL02.CTL
F:ORACLEORADATATE02PRDCONTROL03.CTL
SQL>
set ORACLE_SID=TE02SAP
sqlplus / as sysdba
SQL> select file_name from dba_Data_files;
FILE_NAME
--------------------------------------------------------
F:ORACLEORADATATE02SAPSYSTEM01.DBF
F:ORACLEORADATATE02SAPSYSAUX01.DBF
F:ORACLEORADATATE02SAPUNDOTBS01.DBF
F:ORACLEORADATATE02SAPUSERS01.DBF
F:ORACLEORADATATE02SAPPSD_INDX01.DBF
F:ORACLEORADATATE02SAPPSD_INDX02.DBF
F:ORACLEORADATATE02SAPPSD_DATA01.DBF
F:ORACLEORADATATE02SAPPSD_DATA02.DBF
F:ORACLEORADATATE02SAPPSD_DATA03.DBF
F:ORACLEORADATATE02SAPPSD_DATA04.DBF
F:ORACLEORADATATE02SAPPSD_DATA05.DBF
FILE_NAME
--------------------------------------------------------
F:ORACLEORADATATE02SAPPSD_AUDIT01.DBF
12 rows selected.
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------
F:ORACLEORADATATE02SAPREDO03A.LOG
D:ORACLEORADATATE02SAPREDO03B.LOG
F:ORACLEORADATATE02SAPREDO02B.LOG
D:ORACLEORADATATE02SAPREDO02B.LOG
F:ORACLEORADATATE02SAPREDO01A.LOG
D:ORACLEORADATATE02SAPREDO01B.LOG
6 rows selected.
SQL> select name from v$controlfile;
NAME --------------------------------------------------------
F:ORACLEORADATATE02SAPCONTROL01.CTL
D:ORACLEFAST_RECOVERY_AREATE02SAPCONTROL02.CTL
SQL>