启动数据库后,再次查询发现已经成功清理:
SQL>
set lines 300
col OWNER_NAME for a10
col OPERATION for a15
col JOB_MODE for a20
col STATE for a15
select * from dba_datapump_jobs;
no rows selected
小结:数据泵任务与ora_dm进程相关;如果数据泵任务发生异常,但任务并没有退出的情况,需要同时杀掉这类进程(杀掉后状态就会变为NOT RUNNING)。关库不是必须的,只是演示此时正常关闭被阻塞的场景。这也能说明为什么要保证在NOT RUNNING状态下才可以清理。
2.追本溯源查MOS
上面的步骤只是清理了异常的数据泵任务,但没有解决问题,再次后台执行备份任务依然会重现故障:
nohup sh expdp_xtts.sh &
$ ps -ef|grep expdp
oracle 6684914 8061208 0 15:30:07 pts/2 0:00 grep expdp
oracle 7143482 8061208 0 15:30:03 pts/2 0:00 sh expdp_xtts.sh
oracle 6685096 7143482 0 15:30:03 pts/2 0:00 expdp '/ as sysdba' parfile=expdp_xtts.par
$ ps -ef|grep ora_dm
oracle 7602308 8061208 0 15:30:10 pts/2 0:00 grep ora_dm
oracle 3997964 1 1 15:30:05 - 0:00 ora_dm00_xxxxdb
$
此时查询dba_datapump_jobs,state依然一直是defining状态:
OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS
---------- ------------------------------ --------------- ------------------------------ ------------------------------ ---------- ----------------- -----------------
SYS SYS_EXPORT_TRANSPORTABLE_01 EXPORT TRANSPORTABLE DEFINING 1 1 2
其他的导出任务都一样,不再赘述。
为了方便测试,写一个简单的单表expdp导出,现象也一样。
expdp \'/ as sysdba\' directory=XTTS tables=query.test dumpfile=query_test.dmp logfile=query_test.log
根据故障现象,用如下关键字在MOS中搜索: expdp state DEFINING,匹配到文档:
•DataPump Export/Import Hangs With "DEFINING" Status When Using A Directory On NFS Filesystem (文档 ID 2262196.1)
正好这次测试是在NFS文件系统上,MOS建议移动到本地文件系统导出。
这次再将expdp进程全部杀掉:
ps -ef|grep ora_dm|grep -v grep|awk '{print $2}'|xargs kill -9
ps -ef|grep expdp|grep -v grep|awk '{print $2}'|xargs kill -9
此时查询dba_datapump_jobs:
OWNER_NAME JOB_NAME OPERATION JOB_MODE STATE DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS
---------- ------------------------------ --------------- ------------------------------ --------------- ---------- ----------------- -----------------
SYS SYS_EXPORT_TABLE_04 EXPORT TABLE NOT RUNNING 0 0 0
SYS SYS_EXPORT_SCHEMA_01 EXPORT SCHEMA NOT RUNNING 0 0 0
SYS SYS_EXPORT_TABLE_02 EXPORT TABLE NOT RUNNING 0 0 0
SYS SYS_EXPORT_TABLE_05 EXPORT TABLE NOT RUNNING 0 0 0
SYS SYS_EXPORT_TABLE_03 EXPORT TABLE NOT RUNNING 0 0 0
SYS SYS_EXPORT_TABLE_01 EXPORT TABLE NOT RUNNING 0 0 0
SYS SYS_EXPORT_TRANSPORTABLE_01 EXPORT TRANSPORTABLE NOT RUNNING 0 0 0
7 rows selected.