Oracle数据泵expdp和impdp之parallel参数

0    421    2

Tags:

👉 本文共约2179个字,系统预计阅读时间或需9分钟。

简介

EXPDP命令的PARALLEL和FILESIZE参数联合使用在“某些情况下”可以提高备份的效率。
这种方法可以完成并行的逻辑备份。

expdp

EXPDP命令的PARALLEL和FILESIZE参数联合使用在“某些情况下”可以提高备份的效率。这种方法可以完成并行的逻辑备份。

PARALLEL工作原理:控制执行任务的最大线程数。当指定参数值为1时,表示最多只启动一个线程处理数据,设置为3时,表示最多启动三个线程并行处理数据,由于同一时间一个DUMP文件只允许一个线程处理,所以输出的文件若只有一个,即使PARALLEL=10,也只有1个线程进行数据输出,其他9个空闲。所以PARALLEL需要与FILESIZE参数一起使用,指定每个DUMP文件的大小。

在expdp中,parallel参数值应小于等于dump文件数。如果prarallel值设置过高,则有可能报ORA-39095 error。ORA-39095: Dump file space has been exhausted: Unable to allocate 8192 bytes

对于导出来说,由于dump文件只能由一个线程进行操作(包括I/O处理),因此如果输出的DUMP文件只有一个,即使你指定再多的并行,实际工作仍然是一个,而且还会触发ORA-39095错误。因此,建议设置该参数小于或等于生成的DUMP文件数量。那么,如何控制生成的DUMP文件数量呢?
EXPDP 命令提供了一个FILESIZE参数,用来指定单个DUMP文件的最大容量,要有效的利用parallel参数,filesize参数必不可少。
举 例:某用户对象占用了4G左右的空间,实际导出后的DUMP文件约为3G,我们尝试在导出该用户时指定并行度为4,设置单个文件不超过500M,则语法如下:

impdp

IMPDP有所不同,会先启动一个WOKER进程进行METADATA导入,然后启动多个WORKER进程导入,所以在前期只会看到1个WOKER在导入METADATA,而且IMPDP如果PARALLE=4也需要>=4个DMP文件,也可以使用%U来进行导入。而对于impdp来说,对单个文件添加parallel也可以实现并行导入。

Parallel在impdp中的参数与expdp中有所不同。

摘抄官方文档一句话:If the source of the import is a dump file set consisting of files, then multiple processes can read from the same file, but performance may be limited by I/O contention.

该意为:在impdp中,parallel参数可以在一个文件或者多个文件中均可以使用,但是parallel参数不是越大越好,同样会受到I/O的限制。

对于导入来说,使用parallel参数则要简单的多,导入更能体现parallel参数的优势。 参数设置为几,则认为同时将几张表的内容导入到库中。

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!

举例:某dmp文件中包含了200张表,我们尝试在导入该DMP文件时指定并行度为10,则语法如下:

查询CPU个数: cat /proc/cpuinfo |grep "processor"|wc -l

rac

在11gR2 rac后,EXPDP 和 IMPDP的WORKER进程会在多个INSTANCE启动,所以DIRECTORY必须在共享磁盘上,如果没有设置共享磁盘,那么必须指定CLUSTER=N参数来防止报错。

导出和导入都需要加入CLUSTER=N参数。

导出导入示例

重要描述

For Data Pump Export, the value that is specified for the parallel parameter should be less than or equal to the number of files in the dump file set. Each worker or Parallel Execution Process requires exclusive access to the dump file, so having fewer dump files than the degree of parallelism will mean that some workers or PX processes will be unable to write the information they are exporting. If this occurs, the worker processes go into an idle state and will not be doing any work until more files are added to the job. See the explanation of the DUMPFILE parameter in the Database Utilities guide for details on how to specify multiple dump files for a Data Pump export job.
For Data Pump Import, the workers and PX processes can all read from the same files. However, if there are not enough dump files, the performance may not be optimal because multiple threads of execution will be trying to access the same dump file. The performance impact of multiple processes sharing the dump files depends on the I/O subsystem containing the dump files. For this reason, Data Pump Import should not have a value for the PARALLEL parameter that is significantly larger than the number of files in the dump file set.

In a typical export that includes both data and metadata, the first worker process will unload the metadata: tablespaces, schemas, grants, roles, tables, indexes, and so on. This single worker unloads the metadata, and all the rest unload the data, all at the same time. If the metadata worker finishes and there are still data objects to unload, it will start unloading the data too. The examples in this document assume that there is always one worker busy unloading metadata while the rest of the workers are busy unloading table data objects.

If the external tables method is chosen, Data Pump will determine the maximum number of PX processes that can work on a table data object. It does this by dividing the estimated size of the table data object by 250 MB and rounding the result down. If the result is zero or one, then PX processes are not used to unload the table

The PARALLEL parameter works a bit differently in Import than Export. Because there are various dependencies that exist when creating objects during import, everything must be done in order. For Import, no data loading can occur until the tables are created because data cannot be loaded into tables that do not yet exist

总结

1、数据泵的expdp使用PARALLEL需要与FILESIZEdumpfile=orcl_%U.dmp 参数一起使用才能真正实现并发;而对于impdp来说,对单个文件添加parallel也可以实现并行导入,而无论该文件是否是并行导出的文件。

2、EXPDP会使用一个WORKER进程导出METADATA

3、若是rac环境,且导出或导入文件存放在本地,那么需要添加CLUSTER=N参数,注意:导出和导入都需要添加该参数。

4、如果导出文件数量少于并发数时,多于并发将不会工作。

5、是否真实使用了并行,我们可以通过如下命令进入会话,输入status命令,查看多个进程的State状态即可:

该导入其实只有1个进程在运行。

6、impdp和network_link、PARALLEL配合,可以直接并行导出,但是,我通过实验看到单个schem似乎并没有并行

network_link可以参考:https://www.xmmup.com/dbbao59-kongjianbuzuzenmebanbiepashujubengzhinetwork_linklaibang.html

标签:

头像

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复

嘿,我是小麦,需要帮助随时找我哦
  • 18509239930
  • 个人微信

  • 麦老师QQ聊天
  • 个人邮箱
  • 点击加入QQ群
  • 个人微店

  • 回到顶部
返回顶部