windows 环境下 10g 数据库到11g 数据库迁移
一。10g 环境做好迁移准备
在数据库中创建test表,并插入一条数据以便确认迁移是否成功
SQL> create table test(id number,name varchar(20));
SQL> insert into test(id,name) values(1,‘test‘
由于10.2.0.1版本不能直接升级到11gr2,所以需要先将源数据库升级为10.2.0.2
登陆rman
C:\Documentsand Settings\Administrator>rman target /
恢复管理器: Release10.2.0.1.0 - Production on 星期二 4月 14 16:47:24 2015
Copyright(c) 1982, 2005, Oracle. All rightsreserved.
连接到目标数据库: TEST(DBID=2175164748)
修改rman参数
RMAN>configure controlfile autobackup on;
RMAN>configure datafile backup copies for device type disk to ‘d:\backup\%F‘;
RAMN>CONFIGURERETENTION POLICY TO REDUNDANCY 2;
备份数据库以及归档日志文件
$ORACLE_HOME/rdbms/admin下的utlu112i.sql脚本copy到10g的$ORACLE_HOME/rdbms/admin 下,并在10g上执行
备份数据库以及归档日志文件
RMAN> backupdatabase format ‘ /data/backup/2014-04-17-allbackup、full_%d_%T_%s_P.bak‘;
RMAN> backuparchivelog all format /data/backup/2014-04-17-allbackup/arch_%d_%T_%s_%p.bak‘;
将生成备份集全部拷贝到新环境中(要拷贝一份口令文件)
===========================新===========================================
设置oracle-sid ,登录rman
oradim -new -sid test ---创建test实例
C:\Users\Administrator>rmantarget / nocatalogg
exportORACLE_SID=test
恢复spfile到指定目录下
startup nomount;
RMAN>restore spfile to
‘C:\app\Administrator\product\11.2.0\dbhome_1\dbs\spfiletest.ora‘from
‘C:\backup\C-2175164748-20150416-00‘;
创建pfile并修改其中参数,并创建相关文件夹(所有路径需要与当前安装路径匹配)
SQL> create pfilefrom spfile=‘C:\app\Administrator\product\11.2.0\dbhome_1\dbs\
spfiletest.ora‘;
test.__db_cache_size=167772160
test.__java_pool_size=4194304
test.__large_pool_size=4194304
test.__shared_pool_size=109051904
test.__streams_pool_size=0
*.audit_file_dest=‘C:\oracle\product\10.2.0/admin/test/adump‘
*.background_dump_dest=‘C:\oracle\product\10.2.0/admin/test/bdump‘--delete
*.compatible=‘10.2.0.1.0‘ --修改为当前数据库版本
*.control_files=‘C:\oracle\product\10.2.0/oradata/test/\control01.ctl‘,‘C:\oracle\product\10.2.0/oradata/test/\control02.ctl‘,‘C:\oracle\product\10.2.0/oradata/test/\control03.ctl‘
*.core_dump_dest=‘C:\oracle\product\10.2.0/admin/test/cdump‘ --delete
*.db_block_size=8192
*.db_domain=‘‘
*.db_file_multiblock_read_count=16 --delete
*.db_name=‘test‘
*.db_recovery_file_dest=‘C:\oracle\product\10.2.0/flash_recovery_area‘
*.db_recovery_file_dest_size=2147483648
*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=testXDB)‘
*.job_queue_processes=10
*.log_archive_format=‘ARC%S_%R.%T‘
*.nls_language=‘SIMPLIFIED CHINESE‘
*.nls_territory=‘CHINA‘
*.open_cursors=300
*.pga_aggregate_target=96468992
*.processes=150
*.remote_login_passwordfile=‘EXCLUSIVE‘
*.sga_target=290455552
*.undo_management=‘AUTO‘
*.undo_tablespace=‘UNDOTBS1‘
*.user_dump_dest=‘C:\oracle\product\10.2.0/admin/test/udump‘ --delete
恢复控制文件
RMAN>restorecontrolfile from ‘C:\backup\C-2175164748-20150416-00‘;
需要把扩展名从.ora 改成.ctl
启动到mount状态,恢复数据文件
alter database mount;
重置数据文件路径,并恢复数据库
run{
set newname for datafile 1 to‘C:\app\Administrator\oradata\test\SYSTEM01.DBF‘;
set newname for datafile 2 to‘C:\app\Administrator\oradata\test\UNDOTBS01.DBF‘;
set newname for datafile 3 to‘C:\app\Administrator\oradata\test\SYSAUX01.DBF‘;
set newname for datafile 4 to‘C:\app\Administrator\oradata\test\USERS01.DBF‘;
restore database;
SWITCH DATAFILE ALL;
SWITCH TEMPFILE ALL;
}
修复数据库
recover database;
重命名重做日志,并以resetlogs方式打开数据库
alter database rename file‘C:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\REDO03.LOG‘ to
‘C:\app\Administrator\oradata\test\redo03.log‘;
alter database renamefile ‘C:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\REDO02.LOG‘ to‘C:\app\Administrator\oradata\test\redo02.log‘;
alter database renamefile ‘C:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST\REDO01.LOG‘ to‘C:\app\Administrator\oradata\test\redo01.log‘;
- 以upgrade方式打开数据库
sqlplus / as sysdba
startup upgrade
- 执行升级脚本
SQL>@?/RDBMS/ADMIN/utlu112i.sql
SQL>@?/rdbms/admin/catupgrd.sql
SQL> @?/rdbms/admin/catuppst.sql