跨平台win->linux数据迁移:
如果是相同数据库版本,停机,直接cp,或者rman备份集,可以直接open
必须是冷备/一致性备份,不能应用归档日志
文件拷贝迁移
1.创建spfile
拷贝spfile到linux环境
create pfile from spfile;
*.audit_file_dest='/opt/oracle/oradata/orcl/'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_files='/opt/oracle/oradata/orcl/control01.ctl'
*.db_block_size=8192
*.db_name='orcl'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.local_listener='LISTENER_ORCL'
*.open_cursors=300
*.pga_aggregate_target=819m
*.processes=320
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=2457m
*.undo_tablespace='UNDOTBS1'
2.创建控制文件
在win环境执行下列语句,生成控制文件生产语句
alter database backup controlfile to trace as 'd:/ct.ctl';
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/opt/oracle/oradata/orcl/REDO01.LOG' SIZE 200M BLOCKSIZE 512,
GROUP 2 '/opt/oracle/oradata/orcl/REDO02.LOG' SIZE 200M BLOCKSIZE 512,
GROUP 3 '/opt/oracle/oradata/orcl/REDO03.LOG' SIZE 200M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/opt/oracle/oradata/orcl/SYSTEM01.DBF',
'/opt/oracle/oradata/orcl/SYSAUX01.DBF',
'/opt/oracle/oradata/orcl/UNDOTBS01.DBF',
'/opt/oracle/oradata/orcl/USERS01.DBF'
CHARACTER SET ZHS16GBK
;
3.打开数据库
ALTER DATABASE OPEN;
4.添加临时文件
alter tablespace temp add tempfile '/opt/oracle/oradata/orcl/temp01.dbf' size 100M reuse autoextend on next 100M maxsize 20G;
rman备份集迁移
1.一致性关闭数据库启动到mount模式下
shutdown immediate;
startup mount;
2.设置备份路径
configure channel device type disk format 'd:\rman\%U';
3.备份数据库
backup database;
4.拷贝备份集到linux下
5..恢复spfile
restore spfile from '/setup/O1_MF_S_1032721052_H4QKHZTX_.BKP';
6.创建并修改pfile,删除spfile
create pfile from spfile;
vi initORCL.ora
orcl.__data_transfer_cache_size=0
orcl.__db_cache_size=2013265920
orcl.__inmemory_ext_roarea=0
orcl.__inmemory_ext_rwarea=0
orcl.__java_pool_size=16777216
orcl.__large_pool_size=33554432
orcl.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=872415232
orcl.__sga_target=2583691264
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=503316480
orcl.__streams_pool_size=0
*.audit_file_dest='/opt/oracle/oradata/orcl/'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_files='/opt/oracle/oradata/orcl/control01.ctl'
*.db_block_size=8192
*.db_name='orcl'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.local_listener='LISTENER_ORCL'
*.open_cursors=300
*.pga_aggregate_target=819m
*.processes=320
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=2457m
*.undo_tablespace='UNDOTBS1'
7.启动数据库到nomount状态
startup nomount;
8.恢复控制文件
restore controlfile from '/setup/O1_MF_S_1032721052_H4QKHZTX_.BKP';
9.修改数据库到mount状态
alter database mount;
9.清楚无用控制文件信息
RMAN> select * from v$dbfile;
crosscheck backup;
delete expired backup ;
10.注册备份集文件
catalog start with '/setup/';
11.查看备份文件信息
report schema;
12.还原数据文件
run {
set newname for datafile 1 to '/opt/oracle/oradata/orcl/SYSTEM01.DBF';
set newname for datafile 3 to '/opt/oracle/oradata/orcl/SYSAUX01.DBF';
set newname for datafile 5 to '/opt/oracle/oradata/orcl/UNDOTBS01.DBF';
set newname for datafile 7 to '/opt/oracle/oradata/orcl/USERS01.DBF';
restore database;
switch datafile all;
}
所有文件统一指定恢复目录
set newname for database to '/opt/oracle/oradata/orcl/%U';
13.resetlogs打开数据库
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?#