跨平台win->linux数据迁移:
如果是相同数据库版本,停机,直接cp,或者rman备份集,可以直接open
必须是冷备/一致性备份,不能应用归档日志

文件拷贝迁移

1.创建spfile

拷贝spfile到linux环境

  1. create pfile from spfile;
  1. *.audit_file_dest='/opt/oracle/oradata/orcl/'
  2. *.audit_trail='db'
  3. *.compatible='12.2.0'
  4. *.control_files='/opt/oracle/oradata/orcl/control01.ctl'
  5. *.db_block_size=8192
  6. *.db_name='orcl'
  7. *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
  8. *.local_listener='LISTENER_ORCL'
  9. *.open_cursors=300
  10. *.pga_aggregate_target=819m
  11. *.processes=320
  12. *.remote_login_passwordfile='EXCLUSIVE'
  13. *.sga_target=2457m
  14. *.undo_tablespace='UNDOTBS1'

2.创建控制文件

在win环境执行下列语句,生成控制文件生产语句

  1. alter database backup controlfile to trace as 'd:/ct.ctl';
  1. STARTUP NOMOUNT
  2. CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS NOARCHIVELOG
  3. MAXLOGFILES 16
  4. MAXLOGMEMBERS 3
  5. MAXDATAFILES 100
  6. MAXINSTANCES 8
  7. MAXLOGHISTORY 292
  8. LOGFILE
  9. GROUP 1 '/opt/oracle/oradata/orcl/REDO01.LOG' SIZE 200M BLOCKSIZE 512,
  10. GROUP 2 '/opt/oracle/oradata/orcl/REDO02.LOG' SIZE 200M BLOCKSIZE 512,
  11. GROUP 3 '/opt/oracle/oradata/orcl/REDO03.LOG' SIZE 200M BLOCKSIZE 512
  12. -- STANDBY LOGFILE
  13. DATAFILE
  14. '/opt/oracle/oradata/orcl/SYSTEM01.DBF',
  15. '/opt/oracle/oradata/orcl/SYSAUX01.DBF',
  16. '/opt/oracle/oradata/orcl/UNDOTBS01.DBF',
  17. '/opt/oracle/oradata/orcl/USERS01.DBF'
  18. CHARACTER SET ZHS16GBK
  19. ;

3.打开数据库

  1. ALTER DATABASE OPEN;

4.添加临时文件

  1. alter tablespace temp add tempfile '/opt/oracle/oradata/orcl/temp01.dbf' size 100M reuse autoextend on next 100M maxsize 20G;

rman备份集迁移

1.一致性关闭数据库启动到mount模式下

  1. shutdown immediate;
  2. startup mount;

2.设置备份路径

  1. configure channel device type disk format 'd:\rman\%U';

3.备份数据库

  1. backup database;

4.拷贝备份集到linux下

5..恢复spfile

  1. restore spfile from '/setup/O1_MF_S_1032721052_H4QKHZTX_.BKP';

6.创建并修改pfile,删除spfile

  1. create pfile from spfile;
  2. vi initORCL.ora
  3. orcl.__data_transfer_cache_size=0
  4. orcl.__db_cache_size=2013265920
  5. orcl.__inmemory_ext_roarea=0
  6. orcl.__inmemory_ext_rwarea=0
  7. orcl.__java_pool_size=16777216
  8. orcl.__large_pool_size=33554432
  9. orcl.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment
  10. orcl.__pga_aggregate_target=872415232
  11. orcl.__sga_target=2583691264
  12. orcl.__shared_io_pool_size=0
  13. orcl.__shared_pool_size=503316480
  14. orcl.__streams_pool_size=0
  15. *.audit_file_dest='/opt/oracle/oradata/orcl/'
  16. *.audit_trail='db'
  17. *.compatible='12.2.0'
  18. *.control_files='/opt/oracle/oradata/orcl/control01.ctl'
  19. *.db_block_size=8192
  20. *.db_name='orcl'
  21. *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
  22. *.local_listener='LISTENER_ORCL'
  23. *.open_cursors=300
  24. *.pga_aggregate_target=819m
  25. *.processes=320
  26. *.remote_login_passwordfile='EXCLUSIVE'
  27. *.sga_target=2457m
  28. *.undo_tablespace='UNDOTBS1'

7.启动数据库到nomount状态

  1. startup nomount;

8.恢复控制文件

  1. restore controlfile from '/setup/O1_MF_S_1032721052_H4QKHZTX_.BKP';

9.修改数据库到mount状态

  1. alter database mount;

9.清楚无用控制文件信息

  1. RMAN> select * from v$dbfile;
  2. crosscheck backup;
  3. delete expired backup ;

10.注册备份集文件

  1. catalog start with '/setup/';

11.查看备份文件信息

  1. report schema;

12.还原数据文件

  1. run {
  2. set newname for datafile 1 to '/opt/oracle/oradata/orcl/SYSTEM01.DBF';
  3. set newname for datafile 3 to '/opt/oracle/oradata/orcl/SYSAUX01.DBF';
  4. set newname for datafile 5 to '/opt/oracle/oradata/orcl/UNDOTBS01.DBF';
  5. set newname for datafile 7 to '/opt/oracle/oradata/orcl/USERS01.DBF';
  6. restore database;
  7. switch datafile all;
  8. }
  9. 所有文件统一指定恢复目录
  10. set newname for database to '/opt/oracle/oradata/orcl/%U';

13.resetlogs打开数据库

  1. alter database open resetlogs ;

14.修改联机日志文件和临时文件

所有联机日志文件和临时文件都在/opt/oracle/product/12.2.0/dbhome_1/dbs/文件下

修改联机日志文件https://www.yuque.com/docs/share/d00587e4-6b71-44e6-b283-ccf8c2acf342?#

修改临时文件
https://www.yuque.com/yongle-okrsc/kb/yi2gib#TP6T7