分类目录归档:逻辑备份/恢复

impdp TRANSFORM参数

在impdp的参数中有一个transform参数,用来实现在创建对象的时候对一些存储参数进行修改,官方关于这个参数说明:

TRANSFORM
要应用于适用对象的元数据转换。
有效的关键字为: OID, PCTSPACE, SEGMENT_ATTRIBUTES 和 STORAGE。

对主要的SEGMENT_ATTRIBUTES和STORAGE参数进行测试

SQL> create user xff identified by oracle default tablespace users;

用户已创建。

SQL> grant dba to xff;

授权成功。

SQL> create table xff.t_1 as select * from dba_objects;

表已创建。

SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开

C:\Users\XFF>expdp xff/oracle tables=t_1 dumpfile=t_1.dmp

Export: Release 11.2.0.4.0 - Production on 星期四 12月 16 20:56:50 2021

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
启动 "XFF"."SYS_EXPORT_TABLE_01":  xff/******** tables=t_1 dumpfile=t_1.dmp
正在使用 BLOCKS 方法进行估计...
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的总估计: 11 MB
处理对象类型 TABLE_EXPORT/TABLE/TABLE
. . 导出了 "XFF"."T_1"                                 8.709 MB   89959 行
已成功加载/卸载了主表 "XFF"."SYS_EXPORT_TABLE_01"
******************************************************************************
XFF.SYS_EXPORT_TABLE_01 的转储文件集为:
  C:\APP\XFF\ADMIN\ORCL\DPDUMP\T_1.DMP
作业 "XFF"."SYS_EXPORT_TABLE_01" 已于 星期四 12月 16 20:56:53 2021 elapsed 0 00:00:02 成功完成

不使用TRANSFORM参数导入效果

C:\Users\XFF>impdp xff/oracle sqlfile=t_2.sql full=y dumpfile=t_1.dmp

Import: Release 11.2.0.4.0 - Production on 星期四 12月 16 21:00:12 2021

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功加载/卸载了主表 "XFF"."SYS_SQL_FILE_FULL_01"
启动 "XFF"."SYS_SQL_FILE_FULL_01":  xff/******** sqlfile=t_2.sql full=y dumpfile=t_1.dmp
处理对象类型 TABLE_EXPORT/TABLE/TABLE
作业 "XFF"."SYS_SQL_FILE_FULL_01" 已于 星期四 12月 16 21:00:12 2021 elapsed 0 00:00:00 成功完成

对应的t_2.sql文件内容
20211216211113


transform=storage:n参数导入效果

C:\Users\XFF>impdp xff/oracle sqlfile=t_1.sql full=y dumpfile=t_1.dmp transform=storage:n

Import: Release 11.2.0.4.0 - Production on 星期四 12月 16 20:58:04 2021

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功加载/卸载了主表 "XFF"."SYS_SQL_FILE_FULL_01"
启动 "XFF"."SYS_SQL_FILE_FULL_01":  xff/******** sqlfile=t_1.sql full=y dumpfile=t_1.dmp transform=storage:n
处理对象类型 TABLE_EXPORT/TABLE/TABLE
作业 "XFF"."SYS_SQL_FILE_FULL_01" 已于 星期四 12月 16 20:58:04 2021 elapsed 0 00:00:00 成功完成

对应的t_1.sql文件内容
20211216211352


transform=segment_attributes:n参数导入效果

C:\Users\XFF>impdp xff/oracle sqlfile=t_3.sql full=y dumpfile=t_1.dmp  transform=segment_attributes:n

Import: Release 11.2.0.4.0 - Production on 星期四 12月 16 21:00:36 2021

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功加载/卸载了主表 "XFF"."SYS_SQL_FILE_FULL_01"
启动 "XFF"."SYS_SQL_FILE_FULL_01":  xff/******** sqlfile=t_3.sql full=y dumpfile=t_1.dmp transform=segment_attributes:n 
处理对象类型 TABLE_EXPORT/TABLE/TABLE
作业 "XFF"."SYS_SQL_FILE_FULL_01" 已于 星期四 12月 16 21:00:36 2021 elapsed 0 00:00:00 成功完成

对应的t_3.sql文件内容
20211216211523


transform=segment_attributes:n除掉了所有存储相关信息,对象数据直接导入到用户默认表空间中
transform=storage:n导入的时候除掉了STORAGE部分,表空间信息依旧存在(也就是说导入到表原始表空间中)

发表在 逻辑备份/恢复 | 标签为 | 评论关闭

expdp 并行导出单表数据

在某些情况下,需要使用并行的方法使用 datapump 对单个对象并行导出,导入加快数据迁移的数据
expdp导出操作

#!/bin/bash
chunk=10
for ((i=0;i<chunk;i++));
do
  expdp USERNAME/Password@DB_NAME TABLES=LOB_TEST QUERY=LOB_TEST:\"where mod\(dbms_rowid.rowid_block_number\(rowid\)\, 
>${chunk}\) = ${i}\" directory=DMP dumpfile=lob_test_${i}.dmp logfile= log_test_${i}.log &
  echo $i
done 

impdp导入操作

#!/bin/bash
chunk=10
for ((i=0;i<chunk;i++));
do
 impdp USERNAME/Password@DB_NAME  directory=DMP REMAP_TABLE=LOB_TEST:LOB_TEST  remap_schema=source:target 
>dumpfile= lob_test_${i}.dmp logfile=TABLE_imp_log_test_${i}.log  DATA_OPTIONS=DISABLE_APPEND_HINT  CONTENT=DATA_ONLY &
 echo $i
done

在12c版本开始impdp可能会启用ENABLE_PARALLEL_DML特性,需要注意
参考:Optimising LOB Export and Import Performance via Oracle DataPump

发表在 逻辑备份/恢复 | 评论关闭

datapump network_link遭遇ORA-12899错误

在给一个客户使用expdp+network_link导出数据,然后通过impdp导入数据的过程中遇到ORA-12899问题.
20210608215836


对原库和现在库进行分析
20210608215825
20210608215817

原库和目标库表结构一致,原库该表存储数据实际长度确实为1,但是在impdp导入的时候提示需要长度为3.通过分析,确认原库的nls_length_semantics参数设置为char了,直接使用impdp+network_link不落地方式导入该表数据成功
20210608215845

根据上述情况,查询相关文档,确认类似记录为:
ORA-12899 When Using IMPDP Over Network Link (Doc ID 414901.1)
ORA-26059 During Impdp Using Export Dump Taken With NETWORK_LINK Option (Doc ID 2266956.1)
虽然都不是完全匹配该问题,但是基本上可以确认expdp的network_link和nls_length_semantics参数是引起该问题的根本原因,在后续的迁移中,尽量保持nls_length_semantics参数一致.

发表在 逻辑备份/恢复 | 标签为 , , | 评论关闭