两边数据数据库版本一致-RMAN异构迁移

听很多大佬说RMAN是不支持异构迁移的....,但是还是操作了一波,可以成功!

源库:创建源库的pfile文件

shutdown immediate

startup mount

create pfile='D:\oracle\oradata\protect\pfile0413.ora' from spfile;

源库:备份数据库

这里数据库比较大,有1T的数据量。

这里备份是在数据库mount模式下进行备份(冷备份)的

run{

allocate channel d1 type disk;

allocate channel d2 type disk;

allocate channel d3 type disk;

allocate channel d4 type disk;

allocate channel d5 type disk;

allocate channel d6 type disk;

allocate channel d7 type disk;

allocate channel d8 type disk;

backup as compressed backupset filesperset 4 database format 'E:\dlpdata\%d_%T_%U_1.bak';

backup current controlfile format 'E:\dlpdata\ctl_%d_%T_%t_%s_%p';

release channel d1;

release channel d2;

release channel d3;

release channel d4;

release channel d5;

release channel d6;

release channel d7;

release channel d8;

}

共享备份目录到Linux系统

/dlp是通过NFS从Windows共享过来的目录,里面主要是数据库RMAN的备份文件,具体操作过程就不再赘述。

07da266a3b9979950d6442f99986c331.png

给备份文件赋权

chown -R oracle:oinstall /dlp

chmod -R 777 /dlp

修改pfile文件

主要是修改一系列目录,从Windows转移到Linux

[oracle@dlporacle dlp]$ cat pfile0413.ora

protect.__data_transfer_cache_size=0

protect.__db_cache_size=1778384896

protect.__java_pool_size=33554432

protect.__large_pool_size=83886080

#protect.__oracle_base='D:\oracle'#ORACLE_BASE set from environment

protect.__oracle_base='/u01/app/oracle'

protect.__pga_aggregate_target=805306368

protect.__sga_target=2415919104

protect.__shared_io_pool_size=0

protect.__shared_pool_size=503316480

protect.__streams_pool_size=0

*.aq_tm_processes=1

*.compatible='12.1.0.2.0'

#*.control_files='D:\oracle\oradata\protect\CONTROL01.CTL','D:\oracle\oradata\protect\CONTROL02.CTL','D:\oracle\oradata\protect\CONTROL03.CTL'

*.control_files='/u01/app/oracle/oradata/protect/control01.ctl','/u01/app/oracle/fast_recovery_area/protect/control02.ctl'

*.db_block_size=8192

*.db_domain=''

*.db_name='protect'

#*.db_recovery_file_dest='C:\ora_fast'

*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'

*.db_recovery_file_dest_size=32212254720

*.disk_asynch_io=FALSE

*.fast_start_mttr_target=0

*.job_queue_processes=10

*.log_archive_config='dg_config=(protect,protect_dg)'

*.log_archive_dest_2='SERVICE=protect_dg COMPRESSION=ENABLE LGWR ASYNC AFFIRM VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=protect_dg'

*.log_archive_dest_state_2='ENABLE'

*.nls_language='SIMPLIFIED CHINESE'

*.nls_territory='CHINA'

*.open_cursors=1000

*.pga_aggregate_limit=0

*.pga_aggregate_target=768m

*.processes=1000

*.query_rewrite_enabled='FALSE'

*.remote_login_passwordfile='EXCLUSIVE'

*.session_max_open_files=20

*.sessions=1500

*.sga_target=2304m

*.star_transformation_enabled='FALSE'

*.timed_statistics=TRUE

*.undo_management='AUTO'

*.undo_retention=10800

*.undo_tablespace='UNDOTBS1'

catalog备份文件

startup nomount pfile='/dlp/pflie0413.ora'

restore controlfile from '/dlp/CTL_PROTECT_20200414_1037668370_67_1';

sql 'alter database mount';

crosscheck backup;

delete expired backup;

catalog start with '/dlp/';

还原数据库

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

allocate channel c4 type disk;

allocate channel c5 type disk;

allocate channel c6 type disk;

allocate channel c7 type disk;

allocate channel c8 type disk;

set   newname for   datafile 1 to '/dlpdata/SYSTEM01.DBF';

set   newname for   datafile 2 to '/dlpdata/SYSAUX01.DBF';

set   newname for   datafile 3 to '/dlpdata/UNDOTBS01.DBF';

set   newname for   datafile 4 to '/dlpdata/DRSYS01.DBF';

set   newname for   datafile 5 to '/dlpdata/LOB01.DBF';

set   newname for   datafile 6 to '/dlpdata/LOB02.DBF';

set   newname for   datafile 7 to '/dlpdata/LOB03.DBF';

set   newname for   datafile 8 to '/dlpdata/USERS01.DBF';

set   newname for   datafile 9 to '/dlpdata/USERS02.DBF';

set   newname for   datafile 10 to '/dlpdata/USERS03.DBF';

set   newname for   datafile 11 to '/dlpdata/USERS04.DBF';

set   newname for   datafile 12 to '/dlpdata/LOB04.DBF';

set   newname for   datafile 13 to '/dlpdata/LOB05.DBF';

set   newname for   datafile 14 to '/dlpdata/LOB06.DBF';

set   newname for   datafile 15 to '/dlpdata/LOB07.DBF';

set   newname for   datafile 16 to '/dlpdata/LOB08.DBF';

set   newname for   datafile 17 to '/dlpdata/USERS05.DBF';

set   newname for   datafile 18 to '/dlpdata/LOB09.DBF';

set   newname for   datafile 19 to '/dlpdata/LOB10.DBF';

set   newname for   datafile 20 to '/dlpdata/LOB11.DBF';

set   newname for   datafile 21 to '/dlpdata/LOB12.DBF';

set   newname for   datafile 22 to '/dlpdata/LOB13.DBF';

set   newname for   datafile 23 to '/dlpdata/LOB14.DBF';

set   newname for   datafile 24 to '/dlpdata/LOB15.DBF';

set   newname for   datafile 25 to '/dlpdata/LOB16.DBF';

set   newname for   datafile 26 to '/dlpdata/LOB17.DBF';

set   newname for   datafile 27 to '/dlpdata/LOB18.DBF';

set   newname for   datafile 28 to '/dlpdata/LOB19.DBF';

set   newname for   datafile 29 to '/dlpdata/LOB20.DBF';

set   newname for   datafile 30 to '/dlpdata/LOB21.DBF';

set   newname for   datafile 31 to '/dlpdata/LOB22.DBF';

set   newname for   datafile 32 to '/dlpdata/LOB23.DBF';

set   newname for   datafile 33 to '/dlpdata/LOB24.DBF';

set   newname for   datafile 34 to '/dlpdata/LOB25.DBF';

set   newname for   datafile 35 to '/dlpdata/LOB26.DBF';

set   newname for   datafile 36 to '/dlpdata/LOB27.DBF';

set   newname for   datafile 37 to '/dlpdata/LOB29.DBF';

set   newname for   datafile 38 to '/dlpdata/LOB30.DBF';

set   newname for   datafile 39 to '/dlpdata/SYSTEM02.DBF';

restore database;

switch datafile all;

release channel c1;

release channel c2;

release channel c3;

release channel c4;

release channel c5;

release channel c6;

release channel c7;

release channel c8;

}

数据还原后的调整

alter database open resetlogs upgrade;

Database altered.

show parameter pfile;

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string

根据pfile生成spfile

create spfile from pfile='/dlp/pfile0413.ora';

File created.

编译无效对象

@?/rdbms/admin/utlrp.sql

重做TEMP表空间

col name for a50;

select file#, ts#, name, status from v$tempfile;

FILE#        TS# NAME                                               STATUS

---------- ---------- -------------------------------------------------- -------

1          3 D:\ORACLE\ORADATA\PROTECT\TEMP01.DBF               ONLINE

alter database tempfile 'D:\ORACLE\ORADATA\PROTECT\TEMP01.DBF' drop;

Database altered.

直接删除,会提示不能删除默认临时表空间:

drop tablespace temp;

drop tablespace temp

*

ERROR at line 1:

ORA-12906: ????????????

解决方案:新建一个临时表空间,将其设置为默认临时表空间,再删除原本的临时表空间

CREATE TEMPORARY TABLESPACE temp2 TEMPFILE '/dlpdata/TEMP2.DBF' SIZE 200m AUTOEXTEND ON;

Tablespace created.

alter database default temporary tablespace temp2;

Database altered.

drop tablespace temp;

Tablespace dropped.

CREATE TEMPORARY TABLESPACE temp TEMPFILE '/dlpdata/TEMP01.DBF' SIZE 1G REUSE AUTOEXTEND ON NEXT 200M  MAXSIZE 30G;

Tablespace created.

alter database default temporary tablespace temp;

Database altered.

shutdown immediate

startup

drop tablespace temp2 including contents and datafiles;

select file#, ts#, name, status from v$tempfile;

FILE#        TS# NAME                                               STATUS

---------- ---------- -------------------------------------------------- -------

2          3 /dlpdata/TEMP01.DBF                                ONLINE

再次重新编译无效对象

@?/rdbms/admin/utlrp.sql

以上,数据库迁移成功。

更多推荐