1 说明
利用数据泵进行数据迁移已经不新鲜了,在数据库升级中也经常使用。很多步骤都是大同小异,这个实验就是讲oracle11g R2数据库迁移到12cR2的PDB中。
相关参考文档:
http://docs.oracle.com/database/121/UPGRD/preup.htm#UPGRD12371
http://docs.oracle.com/database/121/UPGRD/expimp.htm#UPGRD12565
2 前提条件
安装好12c数据库软件并创建数据库(dbca).
略...
参考:12c R2安装http://www.cndba.cn/Expect-le/article/1746
通过数据泵进行迁移有两种方法:
1. Expdp/impdp
2. Impdp dblink 语法:IMPDP import_user NETWORK_LINK=db_link FULL=Y;
好处:节省源库的存储空间,占带宽。
3 开始
3.1 环境说明
源库:
目标库:
3.2 源库创建一个测试表
为了验证数据是否正确导入
3.3 源库全库导出
Data Pump can be used to migrate all or any portion of a database between different releases of the database software. The Data Pump Export VERSION parameter is typically used to do this. This will generate a Data Pump dump file set compatible with the specified version.
The default value for VERSION is COMPATIBLE, indicating that exported database object definitions will be compatible with the release specified for the COMPATIBLE initialization parameter.
In an upgrade situation, when the target release of a Data Pump-based migration is higher than the source, the VERSION parameter typically does not have to be specified because all objects in the source database will be compatible with the higher target release. An exception is when an entire Oracle Database 11g (release 11.2.0.3 or higher) is exported in preparation for importing into Oracle Database 12c Release 1 (12.1.0.1) or later. In this case, explicitly specify VERSION=12 in conjunction with FULL=YES in order to include a complete set of Oracle internal component metadata.
In a downgrade situation, when the target release of a Data Pump-based migration is lower than the source, the VERSION parameter should be explicitly specified to be the same version as the target. An exception is when the target release version is the same as the value of the COMPATIBLE initialization parameter on the source system; then VERSION does not need to be specified. In general however, Data Pump import cannot read dump file sets created by an Oracle release that is newer than the current release unless the VERSION parameter is explicitly specified.
从上面可以看出11.2.0.3及以上导入到12.1.0.1及以上,需要在导出时加version=12
导出完成!
3.4 拷贝导出文件到目标库(如果同一台机器上,略)
3.5 目标库导入
--检查导入文件
--执行导入,导入LEI1中
注意:导入的时候,虽然会自动创建表空间和相关数据文件,但是要确保源库的数据文件所在的目录,目标库也要存在相应的目录,要不就会报错。
如:
ORA-39082: Object type FUNCTION:"SYSMAN"."ENCRYPTBYTES" created with compilation warnings
ORA-39082: Object type FUNCTION:"SYSMAN"."DECRYPTBYTES" created with compilation warnings
ORA-39082: Object type FUNCTION:"SYSMAN"."ENCRYPT" created with compilation warnings
ORA-39082: Object type FUNCTION:"SYSMAN"."DECRYPT" created with compilation warnings
ORA-39082: Object type PROCEDURE:"APEX_030200"."F" created with compilation warnings
ORA-39082: Object type PROCEDURE:"APEX_030200"."APEX_ADMIN" created with compilation warnings
ORA-39082: Object type PROCEDURE:"APEX_030200"."HTMLDB_ADMIN" created with compilation warnings
ORA-39082: Object type PROCEDURE:"SCOTT"."TEST_JOBPROCE" created with compilation warnings
ORA-39082: Object type VIEW:"SYSMAN"."AQ$MGMT_NOTIFY_QTABLE" created with compilation warnings
ORA-39082: Object type VIEW:"SYSMAN"."AQ$MGMT_LOADER_QTABLE" created with compilation warnings
ORA-39082: Object type TRIGGER:"APEX_030200"."WWV_BIU_FLOW_SESSIONS" created with compilation warnings
ORA-39082: Object type TRIGGER:"SYSMAN"."MGMT_CREDS_INS_UPD" created with compilation warnings
--如果有无效对象,运行?/rdbms/admin/utlrp.sql重新编译,切换到相应的PDB下运行。非SYS,SYSTEM的无效对象,需要手动进行处理。
3.6 简单验证一下
表的数据量一致。
从目前来看,已经顺利的将11g迁移到12c R2中。