Windows Server 2012 64bit RMAN异机不完全恢复(迁移)
RMAN 备份脚本 -->注意格式的写法\\IP\Shared_folder\ ( 试验有问题)
run{ allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
backup database format='F:\rman_bkp\TE02PRD\full_%d_%U' tag='full_bak';
sql "alter system archive log current";
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup archivelog all format='F:\rman_bkp\TE02PRD\log_%d_%U' delete input tag='log_bak';
backup current controlfile format ='F:\rman_bkp\TE02PRD\%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:\rman_bkp\TE02SAP\full_%d_%U' tag='full_bak';
sql "alter system archive log current";
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup archivelog all format='F:\rman_bkp\TE02SAP\log_%d_%U' delete input tag='log_bak';
backup current controlfile format='F:\rman_bkp\TE02SAP\%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:\oracle\product\12.1.0\dbhome_1
DBCA: NLS_CHARACTERSET AR8ISO8859P6
NLS_LANGUAGE AMERICAN
1. 拷贝一个pfile过来 需要修改的路径修改下
2. 使用这个pfile启动数据库
startup nomount pfile='F:\rman_bkp\TE02prdpfilenew.ora';
create spfile from pfile='F:\rman_bkp\TE02prdpfilenew.ora';
3. 还原控制文件
list backup of controlfile;
--restore controlfile from 'F:\rman_bkp\TE02PRD\TE02PRD_535.DBF';
--restore controlfile from 'F:\rman_bkp\TE02PRD\TE02PRD_CONTROLFILE536.DBF';
restore controlfile from 'D:\Oracle\product\12.1.0\dbhome_1\database\TE02PRD_CONTROLFILE536.DBF';
restore controlfile from 'D:\Oracle\product\12.1.0\dbhome_1\database\TE02PRD_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\rman_bkp\TE02PRD';
--catalog start with 'F:\rman_bkp\TE02PRD';
catalog start with 'D:\Oracle\product\12.1.0\dbhome_1\database';
run{ set newname for datafile 1 to 'F:\ORACLE\ORADATA\TE02PRD\SYSTEM01.DBF';
set newname for datafile 2 to 'F:\ORACLE\ORADATA\TE02PRD\SYSAUX01.DBF';
set newname for datafile 3 to 'F:\ORACLE\ORADATA\TE02PRD\UNDOTBS01.DBF';
set newname for datafile 4 to 'F:\ORACLE\ORADATA\TE02PRD\USERS01.DBF';
set newname for datafile 5 to 'F:\ORACLE\ORADATA\TE02PRD\TEMP01.DBF';
set newname for datafile 6 to 'F:\ORACLE\ORADATA\TE02PRD\CWMLITE01.DBF';
set newname for datafile 7 to 'F:\ORACLE\ORADATA\TE02PRD\RED04.DBF';
set newname for datafile 8 to 'F:\ORACLE\ORADATA\TE02PRD\DRSYS01.DBF';
set newname for datafile 9 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_TMP01.DBF';
set newname for datafile 10 to 'F:\ORACLE\ORADATA\TE02PRD\EXAMPLE01.DBF';
set newname for datafile 11 to 'F:\ORACLE\ORADATA\TE02PRD\RED05.DBF';
set newname for datafile 12 to 'F:\ORACLE\ORADATA\TE02PRD\RED06.DBF';
set newname for datafile 13 to 'F:\ORACLE\ORADATA\TE02PRD\INDX01.DBF';
set newname for datafile 14 to 'F:\ORACLE\ORADATA\TE02PRD\ODM01.DBF';
set newname for datafile 15 to 'F:\ORACLE\ORADATA\TE02PRD\AUE_AUDIT01.DBF';
set newname for datafile 16 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_DATA01.DBF';
set newname for datafile 17 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_DATA02.DBF';
set newname for datafile 18 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_DATA03.DBF';
set newname for datafile 19 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_DATA04.DBF';
set newname for datafile 20 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_DATA05.DBF';
set newname for datafile 21 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_DATA06.DBF';
set newname for datafile 22 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_INDX01.DBF';
set newname for datafile 23 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_INDX02.DBF';
set newname for datafile 24 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_INDX03.DBF';
set newname for datafile 25 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_INDX04.DBF';
set newname for datafile 26 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_INDX05.DBF';
set newname for datafile 27 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_INDX06.DBF';
set newname for datafile 28 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_INDX07.DBF';
set newname for datafile 29 to 'F:\ORACLE\ORADATA\TE02PRD\PSD_INDX08.DBF';
set newname for datafile 30 to 'F:\ORACLE\ORADATA\TE02PRD\TOOLS01.DBF';
set newname for datafile 31 to 'F:\ORACLE\ORADATA\TE02PRD\XDB01.DBF';
set newname for datafile 32 to 'F:\ORACLE\ORADATA\TE02PRD\AUDIT_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:\WINDOWS\System32\notepad.exe" start= auto sc delete baidujingyan sc config OracleOraDB12Home1TNSListener binPath= "D:\Oracle\product\12.1.0\dbhome_1\BIN\TNSLSNR" start= auto OR 注册表regedit 根据路径HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\,找到你想改路径的服务, 也可以利用注册表自带的搜索功能,查找你想要修改的路径 在目录下有一键名是“ImagePath”的就是可执行路径,将其数值数据改为新的可执行路径即可
----TE02SAP STEPS ------------------------------------------
set ORACLE_SID=TE02SAP
rman target /
select open_mode from v$database;
shutdown immediate;
startup nomount pfile='F:\rman_bkp\TE02sappfilenew.ora';
create spfile from pfile='F:\rman_bkp\TE02sappfilenew.ora';
restore controlfile from 'D:\Oracle\product\12.1.0\dbhome_1\database\TE02SAP_CONTROLFILE515.DBF';
alter database mount;
catalog start with 'D:\Oracle\product\12.1.0\dbhome_1\database'; --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:\ORACLE\PRODUCT\12.1.0\DBHOME_1\DATABASE\FPRUNC1K_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:\rman_bkp>oradim -delete -sid TE02SAP
create spfile from pfile='F:\rman_bkp\initTE02SAP.ora';
---------------源库信息 D:\oracle\product\12.1.0\dbhome_1\database
C:\Users\alley_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:\oracle\product\12.1.0
set ORACLE_HOME=D:\oracle\product\12.1.0\dbhome_1
DBCA: NLS_CHARACTERSET AR8ISO8859P6 NLS_LANGUAGE AMERICAN
ORACLE_SID=TE02PRD
C:\Windows\system32>set ORACLE_SID=TE02PRD
C:\Windows\system32>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:\ORACLE\ORADATA\TE02PRD\SYSTEM01.DBF
D:\ORACLE\ORADATA\TE02PRD\SYSAUX01.DBF
D:\ORACLE\ORADATA\TE02PRD\UNDOTBS01.DBF
D:\ORACLE\ORADATA\TE02PRD\USERS01.DBF
F:\ORACLE\ORADATA\TE02PRD\CWMLITE01.DBF
F:\ORACLE\ORADATA\TE02PRD\TEMP01.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_TMP01.DBF
F:\ORACLE\ORADATA\TE02PRD\DRSYS01.DBF
F:\ORACLE\ORADATA\TE02PRD\RED04.DBF
F:\ORACLE\ORADATA\TE02PRD\RED05.DBF
F:\ORACLE\ORADATA\TE02PRD\EXAMPLE01.DBF
FILE_NAME
--------------------------------------------------------
F:\ORACLE\ORADATA\TE02PRD\INDX01.DBF
F:\ORACLE\ORADATA\TE02PRD\RED06.DBF
F:\ORACLE\ORADATA\TE02PRD\ODM01.DBF
F:\ORACLE\ORADATA\TE02PRD\AUE_AUDIT01.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_DATA06.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_DATA05.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_DATA04.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_DATA03.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_DATA02.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_DATA01.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_INDX08.DBF
FILE_NAME
--------------------------------------------------------
F:\ORACLE\ORADATA\TE02PRD\PSD_INDX07.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_INDX06.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_INDX05.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_INDX04.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_INDX03.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_INDX02.DBF
F:\ORACLE\ORADATA\TE02PRD\PSD_INDX01.DBF
F:\ORACLE\ORADATA\TE02PRD\TOOLS01.DBF
F:\ORACLE\ORADATA\TE02PRD\XDB01.DBF
F:\ORACLE\ORADATA\TE02PRD\AUDIT_01.DBF
32 rows selected.
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------
F:\ORACLE\ORADATA\TE02PRD\REDO03A.LOG
D:\ORACLE\ORADATA\TE02PRD\REDO03B.LOG
F:\ORACLE\ORADATA\TE02PRD\REDO02A.LOG
D:\ORACLE\ORADATA\TE02PRD\REDO02B.LOG
F:\ORACLE\ORADATA\TE02PRD\REDO01A.LOG
D:\ORACLE\ORADATA\TE02PRD\REDO01B.LOG
6 rows selected.
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------
F:\ORACLE\ORADATA\TE02PRD\CONTROL01.CTL
F:\ORACLE\ORADATA\TE02PRD\CONTROL02.CTL
F:\ORACLE\ORADATA\TE02PRD\CONTROL03.CTL
SQL>
set ORACLE_SID=TE02SAP
sqlplus / as sysdba
SQL> select file_name from dba_Data_files;
FILE_NAME
--------------------------------------------------------
F:\ORACLE\ORADATA\TE02SAP\SYSTEM01.DBF
F:\ORACLE\ORADATA\TE02SAP\SYSAUX01.DBF
F:\ORACLE\ORADATA\TE02SAP\UNDOTBS01.DBF
F:\ORACLE\ORADATA\TE02SAP\USERS01.DBF
F:\ORACLE\ORADATA\TE02SAP\PSD_INDX01.DBF
F:\ORACLE\ORADATA\TE02SAP\PSD_INDX02.DBF
F:\ORACLE\ORADATA\TE02SAP\PSD_DATA01.DBF
F:\ORACLE\ORADATA\TE02SAP\PSD_DATA02.DBF
F:\ORACLE\ORADATA\TE02SAP\PSD_DATA03.DBF
F:\ORACLE\ORADATA\TE02SAP\PSD_DATA04.DBF
F:\ORACLE\ORADATA\TE02SAP\PSD_DATA05.DBF
FILE_NAME
--------------------------------------------------------
F:\ORACLE\ORADATA\TE02SAP\PSD_AUDIT01.DBF
12 rows selected.
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------
F:\ORACLE\ORADATA\TE02SAP\REDO03A.LOG
D:\ORACLE\ORADATA\TE02SAP\REDO03B.LOG
F:\ORACLE\ORADATA\TE02SAP\REDO02B.LOG
D:\ORACLE\ORADATA\TE02SAP\REDO02B.LOG
F:\ORACLE\ORADATA\TE02SAP\REDO01A.LOG
D:\ORACLE\ORADATA\TE02SAP\REDO01B.LOG
6 rows selected.
SQL> select name from v$controlfile;
NAME --------------------------------------------------------
F:\ORACLE\ORADATA\TE02SAP\CONTROL01.CTL
D:\ORACLE\FAST_RECOVERY_AREA\TE02SAP\CONTROL02.CTL
SQL>