故障描述
在windows中使用impdp导入数据时,使用ctrl+c快捷键异常结束导入任务后,发现产生大量归档日志,并迅速打满快速恢复区,导致报错
故障分析
AWR报告分析
生成AWR报告
# 生成快照文件
SQL> exec dbms_workload_repository.create_snapshot();
# 输出AWR报告
SQL> @?/rdbms/admin/awrrpt
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
1684367924 ORCL 1 orcl
Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
Would you like an HTML report, or a plain text report?
Enter 'html' for an HTML report, or 'text' for plain text
Defaults to 'html'
输入 report_type 的值: html
Type Specified: html
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
* 1684367924 1 ORCL orcl WIN-E014KL8J
V41
Using 1684367924 for database Id
Using 1 for instance number
Specify the number of days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed. Pressing <return> without
specifying a number lists all completed snapshots.
输入 num_days 的值: 2
Listing the last 2 days of Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
orcl ORCL 3531 09 7月 2024 00:00 1
3532 09 7月 2024 01:00 1
3533 09 7月 2024 02:00 1
3534 09 7月 2024 03:00 1
3535 09 7月 2024 04:00 1
3536 09 7月 2024 05:00 1
3537 09 7月 2024 06:00 1
3538 09 7月 2024 07:00 1
3539 09 7月 2024 08:00 1
3540 09 7月 2024 09:00 1
3541 09 7月 2024 10:00 1
3542 09 7月 2024 11:00 1
3543 09 7月 2024 12:00 1
3544 09 7月 2024 13:00 1
3545 09 7月 2024 14:00 1
3546 09 7月 2024 15:00 1
3547 09 7月 2024 16:00 1
3548 09 7月 2024 17:00 1
3549 10 7月 2024 10:45 1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
输入 begin_snap 的值: 3548
Begin Snapshot Id specified: 3548
输入 end_snap 的值: 3549
End Snapshot Id specified: 3549
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_3548_3549.html. To use this name,
press <return> to continue, otherwise enter an alternative.
输入 report_name 的值: E:\awrrpt.html
查看AWR报告
发现存在大量的日志切换
发现主要消耗CPU资源的SQL仍然是impdp导入任务
查看系统中存在的数据泵任务
select * from dba_datapump_jobs
从上图可以看到,虽然在操作系统中使用ctrl+c结束了impdp任务,但是在数据库中,仍然在运行impdp任务
原因分析
在执行expdp/impdp任务时,使用ctrl+c快捷键,并不会真正的停止任务,这是一种错误的终止任务的方式。
解决方法
①正常停止导入任务
使用以下方法正确的结束expdp/impdp任务。
从操作系统中登入到impdp导入的job中,这里需要先查询dba_datapump_jobs表获取job_name的值
# attach参数后需要填写任务名称,任务名称通过dba_datapump_jobs表获得job_name的值
impdp NCC/123456 attach=SYS_IMPORT_FULL_01
Import> STOP_JOB=IMMEDIATE
是否确实要停止此作业 ([Y]/N): Y
是否确实要停止此作业 ([Y]/N): Y
Import> KILL_JOB
正确结束impdp任务后,归档日志停止大量增长。
②删除归档日志,释放快速恢复区空间
由于本人使用的是测试环境,因此直接删除了7天前的归档日志。
生产环境中,请酌情删除归档日志。
# 使用rman本地登入数据库
rman target /
# 检查所有归档日志
RMAN> crosscheck archivelog all;
# 删除7天前的归档日志
RMAN> delete archivelog until time 'sysdate-7';
有额外的磁盘空间的情况下也可对快速恢复区进行空间扩容。
# 本地管理员登录
sqlplus / as sysdba
# 查看当前快速恢复区空间大小
SQL> show parameter db_recovery_file_dest_size
# 对快速恢复区进行空间扩容,本次此时环境扩容到10G
SQL> alter system set db_recovery_file_dest_size=10000M;