Linux cleans Oracle logs and uses the close_trace command to release accidentally deleted trace files.

Source: Internet
Author: User
Many of my friends may have encountered this situation. On UNIXLinux, when regularly clearing Oracle log folders, they may delete trace files that are still open by background processes, that is, some

Many of my friends may have encountered this situation. When regularly clearing Oracle log folders on UNIX/Linux, they may delete trace files that are still open by background processes, that is, some

Many of my friends may have encountered this situation. When regularly clearing Oracle log folders on UNIX/Linux, they may delete trace files that are still open by background processes, that is, some background processes keep holding these "accidentally deleted" file opening Descriptors (fd ), in this case, the space occupied by the file in the file system will not be released ,, this leads to the inconsistency between using the df command to view the remaining space of the file system and using the du command to view the used space of the folder. In addition, because the background process holds these open file descriptors, we cannot solve this problem like the kill service process (some background processes can be killed, but we do not recommend this ). Oradebug is a powerful debug command in sqlplus. We can use this command to initiate multiple trace/dump events, including close_trace events. The close_trace event allows the specified process to close the trace file it holds.

The following describes the related operations:

[Maclean @ rh2 ~] $ Ps-ef | grep ora _ | grep-v grep
Maclean 7281 1 0? 00:00:00 ora_pmon_PROD
Maclean 7283 1 0? 00:00:00 ora_psp0_PROD
Maclean 7285 1 0? 00:00:00 ora_mman_PROD
Maclean 7287 1 0? 00:00:00 ora_dbw0_PROD
Maclean 7289 1 0? 00:00:00 ora_lgwr_PROD
Maclean 7291 1 0? 00:00:00 ora_ckpt_PROD
Maclean 7293 1 0? 00:00:00 ora_smon_PROD
Maclean 7295 1 0? 00:00:00 ora_reco_PROD
Maclean 7297 1 0? 00:00:00 ora_cjq0_PROD
Maclean 7299 1 0? 00:00:00 ora_mmon_PROD
Maclean 7301 1 0? 00:00:00 ora_mmnl_PROD
Maclean 7303 1 0? 00:00:00 ora_d000_PROD
Maclean 7305 1 0? 00:00:00 ora_s000_PROD
Maclean 7313 1 0? 00:00:00 ora_qmnc_PROD
Maclean 7430 1 0? 00:00:00 ora_q000_PROD
Maclean 7438 1 0? 00:00:00 ora_q001_PROD

/* Lgwr is a well-known Oracle background process. In this started instance, its system process number is 7289 */

[Maclean @ rh2 ~] $ Ls-l/proc/7289/fd/* The proc file system on linux allows us to easily detect process information */
Total 0
Lr-x ------ 1 maclean oinstall 64 Jul 26 16: 38 0->/dev/
Lr-x ------ 1 maclean oinstall 64 Jul 26 16:38 1->/dev/null
Lr-x ------ 1 maclean oinstall 64 Jul 26 16: 38 10->/dev/zero
Lr-x ------ 1 maclean oinstall 64 Jul 26 16: 38 11->/dev/zero
Lr-x ------ 1 maclean oinstall 64 Jul 26 :38 12->/s01/rac10g/rdbms/mesg/oraus. msb
Lrwx ------ 1 maclean oinstall 64 Jul 26 :38 13->/s01/rac10g/dbs/hc_PROD.dat
Lrwx ------ 1 maclean oinstall 64 Jul 26 16: 38 14->/s01/rac10g/dbs/lkPROD
Lrwx ------ 1 maclean oinstall 64 Jul 26 16: 38 15->/s01/rac10g/oradata/PROD/controlfile/ow.mf_64q6xphj _. ctl
Lrwx ------ 1 maclean oinstall 64 Jul 26 16->/s01/rac10g/flash_recovery_area/PROD/controlfile/o1_mf_64q6xpms _. ctl
Lrwx ------ 1 maclean oinstall 64 Jul 26 17->/s01/rac10g/oradata/PROD/onlinelog/ow.mf_000064q6xrsr _. log
Lrwx ------ 1 maclean oinstall 64 Jul 26 18->/s01/rac10g/flash_recovery_area/PROD/onlinelog/o1_mf_1_64q6xsoy _. log
Lrwx ------ 1 maclean oinstall 64 Jul 26 16: 38 19->/s01/rac10g/oradata/PROD/onlinelog/ow.mf_2_64q6xths _. log
L-wx ------ 1 maclean oinstall 64 Jul 26 :38 2->/s01/rac10g/admin/PROD/bdump/prod_lgwr_7289.trc
Lrwx ------ 1 maclean oinstall 64 Jul 26 16: 38 20->/s01/rac10g/flash_recovery_area/PROD/onlinelog/o1_mf_2_64q6xv9o _. log
Lrwx ------ 1 maclean oinstall 64 Jul 26 :38 21->/s01/rac10g/oradata/PROD/onlinelog/ow.mf_3_64q6xw1b _. log
Lrwx ------ 1 maclean oinstall 64 Jul 26 22->/s01/rac10g/flash_recovery_area/PROD/onlinelog/o1_mf_3_64q6xwv0 _. log
Lrwx ------ 1 maclean oinstall 64 Jul 26 23->/s01/rac10g/oradata/PROD/datafile/ow.mf_system_64q6wd5j _. dbf
Lrwx ------ 1 maclean oinstall 64 Jul 26->/s01/rac10g/oradata/PROD/datafile/ow.mf_undotbs1_64q6wd7f _. dbf
Lrwx ------ 1 maclean oinstall 64 Jul 26 25->/s01/rac10g/oradata/PROD/datafile/ow.mf_sysaux_64q6wd5m _. dbf
Lrwx ------ 1 maclean oinstall 64 Jul 26 16: 38 26->/s01/rac10g/oradata/PROD/datafile/ow.mf_users_64q6wd89 _. dbf
Lrwx ------ 1 maclean oinstall 64 Jul 26 27->/s01/rac10g/oradata/PROD/datafile/o1_mf_temp_64q6xyox _. tmp
Lr-x ------ 1 maclean oinstall 64 Jul 26 :38 28->/s01/rac10g/rdbms/mesg/oraus. msb
Lr-x ------ 1 maclean oinstall 64 Jul 26 16: 38 3->/dev/
Lr-x ------ 1 maclean oinstall 64 Jul 26 16:38 4->/dev/null
L-wx ------ 1 maclean oinstall 64 Jul 26 16:38 5->/s01/rac10g/admin/PROD/udump/prod_ora_7279.trc
L-wx ------ 1 maclean oinstall 64 Jul 26 16: 38 6->/s01/rac10g/admin/PROD/bdump/alert_prod.
Lrwx ------ 1 maclean oinstall 64 Jul 26 16: 38 7->/s01/rac10g/dbs/lkinstPROD (deleted)
Lrwx ------ 1 maclean oinstall 64 Jul 26 16: 38 8->/s01/rac10g/dbs/hc_PROD.dat
L-wx ------ 1 maclean oinstall 64 Jul 26 :38 9->/s01/rac10g/admin/PROD/bdump/alert_PROD.log

/* You can see that the trace file related to the lgwr process is/s01/rac10g/admin/PROD/bdump/prod_lgwr_7289.trc. The file descriptor is 2 */

[Maclean @ rh2 ~] $ Ls-lh/s01/rac10g/admin/PROD/bdump/prod_lgwr_7289.trc
-Rw-r ----- 1 maclean oinstall 1.7 M Jul 26 16:37/s01/rac10g/admin/PROD/bdump/prod_lgwr_7289.trc

[Maclean @ rh2 ~] $ Rm-f/s01/rac10g/admin/PROD/bdump/prod_lgwr_7289.trc

/* Try to delete the trace file */

[Maclean @ rh2 ~] $ Ls-l/proc/7289/fd | grep lgwr
L-wx ------ 1 maclean oinstall 64 Jul 26 16:38 2->/s01/rac10g/admin/PROD/bdump/prod_lgwr_7289.trc (deleted)

/* The file is already in the deleted state, but the lgwr process still holds the file descriptor related to the file. At this time, the space occupied by the file will not be released */

[Maclean @ rh2 ~] $ Lsof | grep lgwr
Oracle 7289 maclean 2 w REG 1702391 3867134/s01/rac10g/admin/PROD/bdump/prod_lgwr_7289.trc (deleted)

[Maclean @ rh2 ~] $ Sqlplus/as sysdba

SQL * Plus: Release 10.2.0.5.0-Production on Mon Jul 26 17:03:04 2010

Copyright (c) 1982,201 0, Oracle. All Rights Reserved.

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

SQL> oradebug setospid 7289;
Oracle pid: 6, Unix process pid: 7289, image: oracle @ rh2 (LGWR)
SQL> oradebug flush;/* write the trace buffer content to the trace file */
Statement processed.
SQL> oradebug close_trace;
Statement processed.
/* Close_trace can release the file that is being opened by the specified Oracle process, To close the current trace file use */
SQL> host
[Maclean @ rh2 ~] $ Lsof | grep lgwr

[Maclean @ rh2 ~] $ Ls-l/proc/7289/fd/| grep lgwr
[Maclean @ rh2 ~] $
/* The original trace file cannot be found in the fd folder related to the process. The close_trace command successfully releases the file and recycles disk space. */

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.