如何停止ORACLE数据库Expdp与impdp备份任务的后台进程
如何停止ORACLE数据库Expdp与impdp备份任务的后台进程
[color=#ff660]如何停止oracle expdp或impdp备份任务的后台进程,这里首先就要了解下面的内容:
1、DBA_DATAPUMP_JOBS介绍
DBA_DATAPUMP_JOBS identifies all active Data Pump jobs in the database, regardless of their state, on an instance (or on all instances for Real Application Clusters). It also show all Data Pump master tables not currently associated with an active job.
Related View
USER_DATAPUMP_JOBS displays the Data Pump jobs owned by the current user. This view does not display the OWNER_NAME column.
Column Datatype NULL Description
OWNER_NAME VARCHAR2(30) User that initiated the job
JOB_NAME VARCHAR2(30) User-supplied name for the job (or the default name generated by the server)
OPERATION V ARCHAR2(30) Type of job
JOB_MODE V ARCHAR2(30) Mode of job
STATE VARCHAR2(30) Current job state
DEGREE NUMBER Number of worker processes performing the operation
ATTACHED_SESSIONS NUMBER Number of sessions attached to the job
DATAPUMP_SESSIONS NUMBER Number of Data Pump sessions participating in the job
下面我们举例来说明在oracle数据库中如何停止oracle expdp或impdp备份任务的后台进程:
2、启动一个备份任务
[color=#3366ff]nohup expdp parfile=test.par &
如果这个时候想停止这个进程,我想大部分朋友都是通过操作系统命令kill -9 PID来结束,如果这样操作了,操作系统的进程是没有了,但是数据库中的JOB还一直运行,同时备份的目录空间也会不断增加。
3、查询datapump任务job
要结束这个备份任务,首先在数据库中查到相应的JOB名称,然后能过datapump交互模式来终止这个任务,操作如下:
[color=#3366ff]SQL> connect / as sysdba
[color=#3366ff]SQL> select job_name,state from dba_datapump_jobs;
JOB_NAME STATE
--------------------- -------------------------
TEST EXECUTING
注意:
Once the job name is known, that particular job can be stopped by interactively attaching to that job using the ATTACH command line option of Datapump and then stop the job. The following example demonstrates this. The sample assumes that the owner of the job is SCOTT and the job name is TEST, so in this case EXPDP must connect to the SCOTT schema and attach to the TEST job:
所以我们要根据OWNER_NAME用户权限来结束用这个任务,我这里是scott。
4、结束oracle expdp或impdp备份任务的后台进程
$ expdp scott/tiger attach=test
Export: Release 11.2.0.1.0 - Production on Sat Oct 24 12:47:28 2009
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Job: TEST
Owner: TEST
Operation: EXPORT
Creator Privs: TRUE
GUID: 76AA1EE3F300E784E040B10A543B0825
Start Time: Saturday, 24 October, 2009 12:47:28
Mode: SCHEMA
Instance: ORA11GR2
Max Parallelism: 0
EXPORT Job Parameters:
Parameter Name Parameter Value:
CLIENT_COMMAND scott/******** parfile=test.par
State: DEFINING
Bytes Processed: 0
Job Error Count: 0
Dump File: /u02/app/oracle/admin/ORA11GR2/dpdump/test_23oct_rr.dmp
bytes written: 4,096
Export>
Once attached to the job interactively you can manipulate the job. In order to stop the job from running, the STOP_JOB command should be issued. When activated, the command asks for comfirmation. The answer "yes" should be provided to really stop the job:
[size=11pt]Export> stop_job=immediate
Are you sure you wish to stop this job ([yes]/no): [size=11pt]yes <<==
再到数据库中去查询,可以看到这个JOB状态已是NOT RUNNING了。
The DBA_DATAPUMP_JOBS view can be queried again to see that the job is not running anymore:
SQL> select job_name,state from dba_datapump_jobs;
JOB_NAME STATE
--------------------- -------------------------
TEST NOT RUNNING
5、关于数据泵datapump EXPDP/IMPDP交互模式常用命令
[color=#ff0ff]CONTINUE_CLIENT返回到记录模式。假如处于空闲状态, 将重新启动作业。
[color=#ff0ff]START_JOB 启动恢复当前作业。
[color=#ff0ff]STATUS在默认值 (0) 将显示可用时的新状态的情况下,要监视的频率 (以秒计) 作业状态。
[color=#ff0ff]STATUS=[interval]
[color=#ff0ff]STOP_JOB顺序关闭执行的作业并退出客户机。
[color=#ff0ff]STOP_JOB=IMMEDIATE 将立即关闭数据泵作业。
[color=#ff0ff]ADD_FILE向转储文件集中添加转储文件。
[color=#ff0ff]ADD_FILE=dirobjdumpfile-name
[color=#ff0ff]CONTINUE_CLIENT 返回到记录模式。假如处于空闲状态, 将重新启动作业。
[color=#ff0ff]EXIT_CLIENT 退出客户机会话并使作业处于运行状态。
[color=#ff0ff]HELP总结交互命令。
[color=#ff0ff]KILL_JOB分离和删除作业。
[color=#ff0ff]PARALLEL更改当前作业的活动 worker 的数目。
[color=#ff0ff]PARALLEL=worker 的数目。
[color=#ff0ff]START_JOB 启动恢复当前作业。
[color=#ff0ff]STATUS在默认值 (0) 将显示可用时的新状态的情况下,
[color=#ff0ff]要监视的频率 (以秒计) 作业状态。
[color=#ff0ff]STATUS=[interval]
[color=#ff0ff]STOP_JOB顺序关闭执行的作业并退出客户机。
[color=#ff0ff]STOP_JOB=IMMEDIATE 将立即关闭