win->linux
1.单机到单机迁移(尽量减少停机时间)

主库/win 备库/linux
ip 192.168.5.104 192.168.5.150
监听 动态/静态 静态
omf 启用 启用
db_recovery 启用 启用
db_name orcl orcl
db_unique_name orcl orcl
数据库版本 19c 19c
system windows linux

准备工作

目标库windows 11G

1.设置数据库归档

  1. shutdown immediate;
  2. startup mount;
  3. alter database archivelog ;
  4. alter database open;
  5. SQL> archive log list
  6. 数据库日志模式 存档模式
  7. 自动存档 启用
  8. 存档终点 USE_DB_RECOVERY_FILE_DEST
  9. 最早的联机日志序列 6
  10. 下一个存档日志序列 8
  11. 当前日志序列 8
  12. SQL>

2.设置初始化参数

—注意windows路径需要大写

  1. alter system set db_file_name_convert='/opt/oracle/oradata/orcl','D:\APP\ADMINISTRATOR\ORADATA\ORCL' scope=spfile;
  2. alter system set log_file_name_convert='/opt/oracle/oradata/orcl','D:\APP\ADMINISTRATOR\ORADATA\ORCL','/opt/oracle/fast_recovery_area/ORCL/onlinelog','D:\APP\ADMINISTRATOR\ORADATA\ORCL\ONLINELOG' scope=spfile;

备库配置

1.设置初始化参数

  1. *.audit_file_dest='/opt/oracle/admin/ORCL/adump' *.compatible='12.2.0'
  2. *.control_files='/opt/oracle/oradata/ORCL/controlfile/control01.ctl','/opt/oracle/fast_recovery_area/ORCL/controlfile/control02.ctl'#Restore Controlfile
  3. *.db_name='ORCL'
  4. *.db_recovery_file_dest='/opt/oracle/fast_recovery_area/'
  5. *.db_recovery_file_dest_size=20g
  6. *.db_unique_name='ORCL'
  7. *.pga_aggregate_target=850m
  8. *.remote_login_passwordfile='EXCLUSIVE'
  9. *.sga_target=2600m

2.检查目录

  1. mkdir -p /opt/oracle/admin/ORCL/adump

3.创建spfile

  1. create spfile from pfile;
  2. startup nomount;

备份集迁移恢复

1.windows 创建备份集

  1. RMAN> backup database include current controlfil format 'd:\backup\%U' ;

scp 到 linux

2.恢复控制文件

  1. restore controlfile from '/home/oracle/backup/09VMM5Q6_1_1';

3.启动数据库到mount

  1. shutdown immediate;
  2. startup mount;

4.注册备份集

  1. catalog start with '/home/oracle/backup/';

5.恢复数据文件

  1. RMAN>
  2. run{
  3. set newname for database to '/home/oracle/oradata/ORCL/%U';
  4. restore database;
  5. switch datafile all;
  6. }
  7. executing command: SET NEWNAME
  8. Starting restore at 08-FEB-21
  9. using channel ORA_DISK_1
  10. channel ORA_DISK_1: starting datafile backup set restore
  11. channel ORA_DISK_1: specifying datafile(s) to restore from backup set
  12. channel ORA_DISK_1: restoring datafile 00001 to /home/oracle/oradata/ORCL/data_D-ORCL_TS-SYSTEM_FNO-1
  13. channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/oradata/ORCL/data_D-ORCL_TS-SYSAUX_FNO-2
  14. channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/oradata/ORCL/data_D-ORCL_TS-UNDOTBS1_FNO-3
  15. channel ORA_DISK_1: restoring datafile 00004 to /home/oracle/oradata/ORCL/data_D-ORCL_TS-USERS_FNO-4
  16. channel ORA_DISK_1: restoring datafile 00005 to /home/oracle/oradata/ORCL/data_D-ORCL_TS-EXAMPLE_FNO-5
  17. channel ORA_DISK_1: reading from backup piece /home/oracle/backup/06VMM2L0_1_1
  18. channel ORA_DISK_1: piece handle=/home/oracle/backup/06VMM2L0_1_1 tag=TAG20210208T135440
  19. channel ORA_DISK_1: restored backup piece 1
  20. channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
  21. Finished restore at 08-FEB-21
  22. datafile 1 switched to datafile copy
  23. input datafile copy RECID=7 STAMP=1063981009 file name=/home/oracle/oradata/ORCL/data_D-ORCL_TS-SYSTEM_FNO-1
  24. datafile 2 switched to datafile copy
  25. input datafile copy RECID=8 STAMP=1063981009 file name=/home/oracle/oradata/ORCL/data_D-ORCL_TS-SYSAUX_FNO-2
  26. datafile 3 switched to datafile copy
  27. input datafile copy RECID=9 STAMP=1063981009 file name=/home/oracle/oradata/ORCL/data_D-ORCL_TS-UNDOTBS1_FNO-3
  28. datafile 4 switched to datafile copy
  29. input datafile copy RECID=10 STAMP=1063981009 file name=/home/oracle/oradata/ORCL/data_D-ORCL_TS-USERS_FNO-4
  30. datafile 5 switched to datafile copy
  31. input datafile copy RECID=11 STAMP=1063981009 file name=/home/oracle/oradata/ORCL/data_D-ORCL_TS-EXAMPLE_FNO-5
  32. RMAN>

6.打开数据库

  1. alter database open