今天在导入全库的元数据时特别慢,几个小时了都没执行完。
按理说元数据是很小的,不至于几个小时都执行不完
查找impdp hang在什么地方
SQL> set lines 200 pages 200 feedback off newpage none
SQL> select * from dba_datapump_jobs;
OWNER_NAME JOB_NAME OPERATION JOB_MODE
------------------------------ ------------------------------ ------------------------------------------------------------ ------------------------------------------------------------
STATE DEGREE ATTACHED_SESSIONS DATAPUMP_SESSIONS
------------------------------ ---------- ----------------- -----------------
SYS SYS_IMPORT_FULL_01 IMPORT FULL
EXECUTING 1 1 3
--attach impdp任务
nzportadb:/u01/dmpdir>impdp \'/ as sysdba\' attach=SYS_IMPORT_FULL_01
Import: Release 11.2.0.4.0 - Production on Fri Oct 26 15:09:43 2018
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_IMPORT_FULL_01
Owner: SYS
Operation: IMPORT
Creator Privs: TRUE
GUID: 791C455C50FF00A0E0530AAE1A125A8D
Start Time: Friday, 26 October, 2018 13:48:42
Mode: FULL
Instance: portadb
Max Parallelism: 1
EXPORT Job Parameters:
CLIENT_COMMAND "/******** AS SYSDBA" DIRECTORY=AWR_EXTR DUMPFILE=porta.dmp logfile=porta.log FULL=y content=metadata_only
INCLUDE_METADATA 1
IMPORT Job Parameters:
Parameter Name Parameter Value:
CLIENT_COMMAND "/******** AS SYSDBA" DIRECTORY=dmpdir DUMPFILE=porta.dmp logfile=porta.log TABLE_EXISTS_ACTION=SKIP FULL=y content=metadata_only
INCLUDE_METADATA 1
TABLE_EXISTS_ACTION SKIP
State: EXECUTING
Bytes Processed: 0
Current Parallelism: 1
Job Error Count: 0
Dump File: /u01/dmpdir/porta.dmp
Worker 1 Status:
Process Name: DW00
State: EXECUTING
Object Schema: MV_PORTA
Object Name: DBLNK_CRMCENDB
Object Type: DATABASE_EXPORT/SCHEMA/DB_LINK
Worker Parallelism: 1
impdp正在执行导入dblink的任务
Import> STATUS
Job: SYS_IMPORT_FULL_01
Operation: IMPORT
Mode: FULL
State: EXECUTING
Bytes Processed: 0
Current Parallelism: 1
Job Error Count: 0
Dump File: /u01/dmpdir/porta.dmp
Worker 1 Status:
Process Name: DW00
State: EXECUTING
Object Schema: MV_PORTA
Object Name: DBLNK_CRMCENDB
Object Type: DATABASE_EXPORT/SCHEMA/DB_LINK
Worker Parallelism: 1
卡在了导入dblink处
--查找数据库是否有异常
--查找等待事件的语句
col resource_name for a20 SQL>
col event for a40
select inst_id,event,state,count(1)
from gv$session
where wait_class <> 'Idle'
group by inst_id,event,state
order by 4 desc;
SQL> SQL> 2 3 4 5 INST_ID EVENT STATE COUNT(1)
---------- ---------------------------------------- ------------------- ----------
1 SQL*Net message to client WAITED SHORT TIME 1
1 db file sequential read WAITED SHORT TIME 1
数据库没有异常等待时间
--查找锁的语句
SQL> set lin 200
col username for a25
col sid for 99999
col serial# for 9999999
col object_name for a40
col osuser for a10
col program for a20
col lock_mode for 999
select
t1.inst_id,
t2.username,
t2.sid,
t2.serial#,
t4.spid spid_osprocess_id, --osprocess_id
t3.object_name,
t2.OSUSER,
t2.PROGRAM,
t1.LOCKED_MODE
from gv$locked_object t1, gv$session t2, dba_objects t3,gv$process t4SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> 2 3 4 5 6 7 8 9 10 11
where t1.session_id = t2.sid and t2.paddr=t4.addr
and t1.object_id = t3.object_id
and t3.object_name='SC_BALANCE'
and t1.inst_id=t2.inst_id
and t1.inst_id=t4.inst_id
order by t2.logon_time;
12 13 14 15 16 17 SQL>
没有锁
那么数据库是正常的
推测impdp在导入dblink时会验证dblink的可用性
impdp在导入dblink时会验证dblink,如果dblink不可用,超时才会返回
所以在老库的dblink放到新库不可用时(由于网络原因dblink不可用)尽量不要导dblink,会严重拖慢导入的速度
如果需要dblink直接create dblink新建就好了。
最后解决办法就是stop掉impdp进程,加上exclude=db_link参数重新导入
停impdp任务不能kill进程,数据泵任务是在数据库中是一个job,kill进程不能停止任务。
就算kill掉了impdp job任然存在,任然在跑。需要attach 进去stop掉job
停impdp任务:
nzportadb:/oracle/.ssh>impdp \'/ as sysdba\' attach=SYS_IMPORT_FULL_01
Import> STOP_JOB=IMMEDIATE
Are you sure you wish to stop this job ([yes]/no): yes
SQL> select * from dba_datapump_jobs;
SYS SYS_IMPORT_FULL_01 IMPORT FULL
NOT RUNNING 0 0 0
SYS_IMPORT_FULL_01 处于not running状态,过一段时间这个job在视图中就查不到了,也可以使用kill_job去手动杀掉这个job;