数据泵impdp导入时间特别久及导入中断后继续导入案例分享

        欢迎关注“数据库运维之道”公众号,一起学习数据库技术! 本期将为大家分享“数据泵impdp导入时间特别久及导入中断后继续导入”的性能优化案例。

        关键词:Streams AQ: enqueue blocked on low memory、Impdp Hang、Datapump Export/Import、STREAMS_POOL_SIZE、shrink_phase_knlasg

        客户反馈在Oracle 12.1 环境下执行impdp导入数据的速度特别慢,18点下班发起导入,次日8点还未导入完成。通过临时手段先关闭stream pool 内存池空间收缩,接着修改数据库streams_pool_size参数值,重启数据库过程导入出现中断报错,打开数据库后继续从中断点导入,并且速度很快。

导入命令:impdp system/password dumpfile=expdat.dmp directory=dmp cluster=no logfile=impdp.log

        首先,查看下数据库的alert告警日志,确认是否报错信息,例如表空间不足或磁盘不足。同时也检查下导出任务的状态信息,记住任务名从上述的导入日志中提取。

col owner_name for a20
col job_name for a20
col state for a20
set linesize 1000
col operation for a20
col job_mode for a20
select * from dba_datapump_jobs where job_name = 'SYS_IMPORT_FULL_01';

        其次,检查数据库内存参数,是否开启内存自动管理模式。同时检查是否存在stream pool 内存池空间收缩情况。

show parameter sga_target
show parameter memory_target
show parameter shared_pool_sizeselect shrink_phase_knlasg from X$KNLASG;

        接着,检查导入期间数据库的相关等待事件以及会话信息。方法一:查询dba_hist_active_sess_history视图;方法二:提取导入期间某一个小时的AWR性能的报告;方法三:开启10046事件跟踪。任意选取一种方法,都可以看到数据库存在大量的“Streams AQ: enqueue blocked on low memory”等待事件。

方法一:查询dba_hist_active_sess_history视图
(1)创建一个临时表
SQL> conn / as sysdba
SQL> create table system.m_ash as select * from dba_hist_active_sess_history
where SAMPLE_TIME between TO_TIMESTAMP ('2024-02-25 18:00:00', 'YYYY-MM-DD HH24:MI:SS') 
and TO_TIMESTAMP ('2024-02-26 08:00:00', 'YYYY-MM-DD HH24:MI:SS');
(2)基于临时表进行快速查询
select event,count(*) from m_ash group by event order by 2 asc
EVENT COUNT(*)
---------------------------------------------------------------- ----------
db file scattered read 17158
KSV master wait 46015
Streams AQ: enqueue blocked on low memory 84427
(3)查看“Streams AQ: enqueue blocked on low memory”等待事件对应的会话信息
select session_id,count(*) from m_ash where event='Streams AQ: enqueue blocked on low memory' 
group by session_id order by 2;
SESSION_ID COUNT(*)
---------- ----------
384 4147
4088 4165
99 4242
3144 5172
3519 5233
576 7726
4374 8690
3 36834
(4)检查这些会话都是与"Data Pump Worker"相关。方法二:提取导入期间某一个小时的AWR性能的报告
@?/rdbms/admin/awrrpt.sql方法三:开启10046事件进行SQL跟踪。
开:ALTER SYSTEM SET events '10046 trace name context forever, level 12';-- run import关:ALTER SYSTEM SET events '10046 trace name context off';The Data Pump Master and Worker trace file were analyzed with:$ tkprof <DW_TRACE_FILE>.trc <DW_OUTPUT_FILE>.out waits=y sort=exeela

        最后,基于“Streams AQ: enqueue blocked on low memory”等待事件关键词,翻阅MOS相关文档。很多知识库都描述了在AMM/ASMM模式下buffer cache内存空间不足时,会进行streams pool内存收缩导致enquene阻塞导出时间变长。这个等待事件出现一次延迟1分钟,官方建议调大streams_pool_size参数值。

文档 ID 1596645.1
Buffered messages memory is not freed quickly which can result in enqueue blocked on low memeory.
If the size of the streams_pool is being modified, then this can result in excessive waits 
for 'Streams AQ: enqueue blocked on low memory'.
Every occurrence for this event causes a 1 minutes delay.文档 ID 2386566.1
A load in the buffer cache and streams pool memory is being moved to buffer cache.

        1、我们可以通过两种方法来提升导入速度。

        方法一:手动强制完成stream pool 内存池空间收缩,临时规避该问题;

connect / as sysdba
select shrink_phase_knlasg from X$KNLASG;
“1”。该值表示 streams pool 处于收缩阶段。当 streams pool 完成收缩时,该值应返回”0”,alter system set events 'immediate trace name mman_create_def_request level 6';

        方法二:调整streams_pool_size静态参数值为300M,关闭自动调整内存参数,并重启数据库;

CONNECT / as sysdba
ALTER SYSTEM SET streams_pool_size=300m SCOPE=spfile;
ALTER SYSTEM SET "_disable_streams_pool_auto_tuning"=TRUE SCOPE=spfile;
SHUTDOWN IMMEDIATE
STARTUP

        2、在重启数据库过程中,数据库导入会出现中断错误。

Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "PETER"."OBJ2" 163.5 MB 1236887 rows
. . imported "PETER"."OBJ1" 153.8 MB 1164128 rows 《〈〈〈〈〈〈这里数据库重起
----数据库重启
UDI-01089: operation generated ORACLE error 1089
ORA-01089: immediate shutdown or close in progress - no operations are permitted
ORA-06512: at "SYS.DBMS_AQ", line 1127
ORA-06512: at "SYS.KUPC$QUE_INT", line 556
ORA-06512: at "SYS.KUPC$QUE_INT", line 1703
ORA-06512: at line 1
Process ID: 9138
Session ID: 73 Serial number: 27898

        3、当数据库重启后,我们可以从之前中断的时间点继续导入数据。

当impdp的 job中断之后,可以通过impdp attache=JOBName    ===>   continue_client的形式重新运行。
impdp system/oracle job_name=SYSTEM.SYS_IMPORT_FULL_01 我们看到,继续运行导入
Import> continue_client <<<<<<<<<<<<continue_client
Job SYS_IMPORT_FULL_01 has been reopened at Wed Jul 4
Restarting "SYSTEM"."SYS_IMPORT_FULL_01": system/******** dumpfile=expdat.dmp directory=dmp
. . imported "PETER"."TEST1" 76.91 MB 581776 rows
. . imported "PETER"."TEST" 9.616 MB 72641 rows
. . imported "PETER"."M_ASH" 35.54 MB 84313 rows
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Job "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed

        此次数据导入效率很快了。

        下面推荐大家做下模拟实验,数据导出导入过程出现中断,该如何处理。

        1、创建模拟环境,包括用户、测试表、测试数据。

connect / as sysdba
create or replace directory tmp as '/tmp';
create tablespace test_tbs datafile '/tmp/test_tbs_01.dbf' size 100m autoextend on;
create user test_usr identified by test_usr default tablespace test_tbs temporary tablespace temp;
grant connect, resource to test_usr;
alter user test_usr quota unlimited on test_usr;connect test_usr/test_usr
-- create one partitioned table with 5 partitions
create table parttab001
(col001 number,col002 varchar2(1000)
) partition by range (col001)
(partition p001 values less than (1000001),partition p002 values less than (2000001),partition p003 values less than (3000001),partition p004 values less than (4000001),partition p005 values less than (5000001)
);-- populate table, 1000000 rows per partition
declarestmt varchar2(2000);
beginfor j in 1..3000000 loopstmt := 'insert into parttab001 values ('||to_char (j)||', lpad (to_char ('||to_char (j)||'), 1000, '||'''0'''||'))';execute immediate stmt;-- commit after every 100000 rowsif mod (j, 100000) = 0 thencommit;end if;end loop;commit;
end;
/

        2、模拟数据导出中断并继续导出操作。

#> expdp system/<password> directory=tmp dumpfile=parttab001_%u.dmp logfile=expdp_parttab001.log 
tables=test_usr.parttab001 job_name=test_usr parallel=2connect / as sysdba
col owner_name for a20
col job_name for a20
col state for a20
set linesize 1000
col operation for a20
col job_mode for a20
select * from dba_datapump_jobs where job_name = 'TEST_USR';
查询执行状态为:EXECUTINGctrl-c中断导出进入以下窗口:
Export> stop_job
查询执行状态为:STOP PENDING,立即中止导出:
Export> STOP_JOB=IMMEDIATE
查询执行状态为:NOT RUNNING继续中断导出:
#> expdp system/<password> attach=test_usr
Export> continue_client

        3、模拟数据导入中断并继续导入操作。

impdp system/<password> job_name=test_usr directory=tmp dumpfile=parttab001_%u.dmp tables=test_usr.parttab001 logfile=impdp_parttab001.log parallel=2ctrl-c中断导入进入以下窗口:
Import> stop_job=immediate
Are you sure you wish to stop this job ([yes]/no): y继续中断导入:
#> impdp system/<password> attach=test_usr
Import> continue_client
SQL> connect test_usr/test_user
SQL> select count (*) from parttab001 partition (p001);
COUNT(*)
----------1000000SQL> select count (*) from parttab001 partition (p002);
COUNT(*)
----------1000000SQL> select count (*) from parttab001 partition (p003);
COUNT(*)
----------1000000

        4、数据库导出命令加上参数LOGTIME,可以看到导入每个环节具体的操作时间。

参数LOGTIME=ALL,控制台和日志记录都有时间戳
$ expdp test/test DIRECTORY=dpump_dir1 DUMPFILE=expdat.dmp logfile=expdat.log SCHEMAS=test LOGTIME=ALL

  • EXPDP And IMPDP Slow Performance In 11gR2 and 12cR1 And Waits On Streams AQ: Enqueue Blocked On Low Memory (Doc ID 1596645.1)
  • Datapump Expdp Or Impdp Slowdown Due To Frequent Waits On ”Streams AQ: Enqueue Blocked On Low Memory" (Doc ID 2386566.1)
  • How To Break And Restart A DataPump Export Or Import Job (Doc ID 1400974.1)
  • Expdp Is Very Slow After Upgrade From 11.2.0.3 To 11.2.0.4 With Wait On AQ: enqueue blocked on low memory (Doc ID 1990633.1)
  • Bug 17365043 - Session hangs on "Streams AQ: enqueue blocked on low memory" (Doc ID 17365043.8)
  • Bug 21286665 - "Streams AQ: enqueue blocked on low memory" waits with fix 18828868 - superseded (Doc ID 21286665.8)
  • Bug 27634991 - Datapump Frequently Waits On 'Streams AQ: enqueue blocked on low memory' (Doc ID 27634991.8)
  • Checklist For Slow Performance Of DataPump Export (expdp) And Import (impdp) (Doc ID 453895.1)
  • DataPump Import (IMPDP) Performance Known Problems (Doc ID 1948188.1)
  • How To Break And Restart A DataPump Export Or Import Job (Doc ID 1400974.1)

        以上就是本期关于”数据泵impdp导入时间特别久及导入中断后继续导入”的性能优化案例分享。希望能给大家带来帮助。

        欢迎关注“数据库运维之道”公众号,一起学习数据库技术!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/570713.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

QT数据类型和容器用法

Qt库提供了基于通用模板的容器类, 这些类可用于存储指定类型的数据项&#xff0c;Qt中这些容器类的设计比STL容器更轻&#xff0c;更安全且更易于使用。容器类也都是隐式共的&#xff0c;它们是可重入的&#xff0c;并且已针对速度/低内存消耗和最小的内联代码扩展进行了优化&a…

数据平台“国产替代”掣肘在迁移?奇点云的工业制造实践解读

系列导读 如《“数据要素”三年行动计划&#xff08;2024—2026年&#xff09;》指出&#xff0c;工业制造是“数据要素”的关键领域之一。如何发挥海量数据资源、丰富应用场景等多重优势&#xff0c;以数据流引领技术流、资金流、人才流、物资流&#xff0c;对于制造企业而言是…

【Functional Affordances】如何确认可抓取的区域?(前传)

文章目录 1. 【Meta AI】Emerging Properties in Self-Supervised Vision Transformers2. 【Meta AI】DINOv2: Learning Robust Visual Features without Supervision3. 【NeurIPS 2023】Diffusion Hyperfeatures: Searching Through Time and Space for Semantic Corresponden…

机器学习——神经网络简单了解

一、神经网络基本概念 神经网络可以分为生物神经网络和人工神经网络 (1)生物神经网络,指的是生物脑内的神经元、突触等构成的神经网络&#xff0c;可以使生物体产生意识&#xff0c;并协助生物体思考、行动和管理各机体活动。 (2)人工神经网络,是目前热门的深度学习的研究…

rust中常用cfg属性和cfg!宏的使用说明,实现不同系统的条件编译

cfg有两种使用方式&#xff0c;一种是属性&#xff1a; #[cfg()]&#xff0c;一种是宏&#xff1a;cfg! &#xff0c;这两个都是非常常用的功能。 #[cfg()]是 Rust 中的一个属性 用于根据配置条件来选择性地包含或排除代码。cfg 是 "configuration" 的缩写&#xf…

jupyter lab使用虚拟环境

python -m ipykernel install --name 虚拟环境名 --display-name 虚拟环境名然后再启动jupyter lab就行了

项目设计方案:市交通视频监控平台项目设计方案(二)

目录 1 前言 1.1 目的 1.2 适用范围 1.3 术语表 2 现状分析 2.1 业务现状 2.2 组织机构现状 2.3 存在的问题 2.4 项目成果预期 3 系统建设原则 4 项目需求 4.1 项目需求 4.1.1 业务需求主要分为三部分&#xff1a; 4.1.2 技术需求主要分为四部分&#xff1a; 4.…

SpringBoot可以同时处理多少请求

SpringBoot默认的内嵌容器是Tomcat&#xff0c;即看Tomcat可以处理多少请求 默认配置 server:tomcat:threads:min-spare: 10 # 最小工作线程数max: 200 # 最大线程数max-connections: 8192 # 接受和处理的最大连接数&#xff0c;超过8192的请求就会被放入到等待队列中ac…

52个AIGC视频生成算法模型介绍

基于Diffusion模型的AIGC生成算法日益火热&#xff0c;其中文生图&#xff0c;图生图等图像生成技术普遍成熟&#xff0c;很多算法从业者开始从事视频生成算法的研究和开发&#xff0c;原因是视频生成领域相对空白。 AIGC视频算法发展现状 从2023年开始&#xff0c;AIGC视频的新…

安全漏洞周报(2024.03.18-2024.03.25)

漏洞速览 ■ Atlassian Confluence 路径遍历漏洞(CVE-2024-21677) ■用友U8cloud SQL注入漏洞 漏洞详情 1.Atlassian Confluence 路径遍历漏洞(CVE-2024-21677) 影响组件&#xff1a; Atlassian Confluence Data Center是面向大型企业和组织的高可用性、可扩展性和高性能版本…

IDEA编辑国际化.properties文件没有Resource Bundle怎么办?

问题描述 最近在做SpringBoot国际化&#xff0c;IDEA添加了messages.properties、messages_en_US.properties、messages_zh_CN.properties国际化文件后&#xff0c;在编辑页面底部没有Resource Bundle&#xff0c;这使得我在写keyvalue的时候在每个properties文件都要拷贝一次…

微信小程序使用Vant组件库流程

目前 Vant 官方提供了 Vue 2 版本、Vue 3 版本和微信小程序版本&#xff0c;并由社区团队维护 React 版本和支付宝小程序版本。这样开发原生微信小程序的会方便很多。 官方网址&#xff1a;Vant Weapp - 轻量、可靠的小程序 UI 组件库 步骤一 通过 npm 安装 npm i vant/weap…