正文  软件开发 > java编程技术 >

Tips:datapump异常中断后的处理

Tips:datapump异常中断后的处理博客文章除注明转载外,均为原创。转载请注明出处。本文链接地址:http://blog.chinaunix.net/uid-31396856-id-575...

Tips:datapump异常中断后的处理

博客文章除注明转载外,均为原创。转载请注明出处。
本文链接地址:http://blog.chinaunix.net/uid-31396856-id-5756767.html

oracle数据库在10g的时候推出datapump,expdp/impdp现已成为dba导数的常用工具了。上次客户联系说,在终止expdp进程后,系统空间还是在增长,可用空间越来越小。问了下客户是怎么关闭expdp的,说是一次ctrc+C,一次kill expdp进程....
expdp/impdp的启动,是以job的形式在数据库后台运行。如果只是关闭进程,或者异常退出,是无法停止expdp/impdp,因为job还是在数据库里运行。这个时候处理方式是关闭数据库中expdp/impdp的job。

先登录数据库,确认expdp对应的job名称

SQL> select job_name,state from dba_datapump_jobs;
JOB_NAME STATE
------------------------------ ------------------------------
SYS_EXPORT_TABLE_01 EXECUTING
SYS_EXPORT_TABLE_02 EXECUTING

果然数据库有两个expdp进程跑着呢...


正确的处理方式:

SQL> select job_name,state from dba_datapump_jobs;


JOB_NAME STATE
------------------------------ ------------------------------
SYS_EXPORT_FULL_01 EXECUTING


[oracle@ora11g dp_dir]$
[oracle@ora11g dp_dir]$ expdp \'/ as sysdba\' attach=SYS_EXPORT_FULL_01


Export: Release 11.2.0.4.0 - Production on Thu Dec 15 11:26:31 2016


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


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


Job: SYS_EXPORT_FULL_01
Owner: SYS
Operation: EXPORT
Creator Privs: TRUE
GUID: 43AB008C575C06AAE053E638A8C0C450
Start Time: Thursday, 15 December, 2016 11:25:24
Mode: FULL
Instance: ora11g
Max Parallelism: 1
EXPORT Job Parameters:
Parameter Name Parameter Value:
CLIENT_COMMAND "/******** AS SYSDBA" DIRECTORY=dp_dir DUMPFILE=db.dump full=y
State: EXECUTING
Bytes Processed: 0
Current Parallelism: 1
Job Error Count: 0
Dump File: /home/oracle/dp_dir/db.dump
bytes written: 4,096

Worker 1 Status:
Process Name: DW00
State: EXECUTING
Object Schema: SYSMAN
Object Name: AQ$_MGMT_LOADER_QTABLE_G
Object Type: DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Completed Objects: 1
Worker Parallelism: 1


Export> stop_job /stop_job=immediate
Are you sure you wish to stop this job ([yes]/no): yes


[oracle@ora11g dp_dir]$ expdp \'/ as sysdba\' attach=SYS_EXPORT_FULL_01


Export: Release 11.2.0.4.0 - Production on Thu Dec 15 11:27:27 2016


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


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


Job: SYS_EXPORT_FULL_01
Owner: SYS
Operation: EXPORT
Creator Privs: TRUE
GUID: 43AB008C575C06AAE053E638A8C0C450
Start Time: Thursday, 15 December, 2016 11:27:30
Mode: FULL
Instance: ora11g
Max Parallelism: 1
EXPORT Job Parameters:
Parameter Name Parameter Value:
CLIENT_COMMAND "/******** AS SYSDBA" DIRECTORY=dp_dir DUMPFILE=db.dump full=y
State: IDLING
Bytes Processed: 0
Current Parallelism: 1
Job Error Count: 0
Dump File: /home/oracle/dp_dir/db.dump
bytes written: 4,096

Worker 1 Status:
Process Name: DW00
State: UNDEFINED


Export> kill_job
Are you sure you wish to stop this job ([yes]/no): yes

于是乎处理完毕。因此在expdp/impdp的时候不要随意的kill或者终止进程。
---The end