Use LinuxStrace to track and debug Oracle program processes

Source: Internet
Author: User
Tags time zones
Oracle itself provides many tools of this type, such as oradebug, various wait events and tracking methods. In addition, various types of operating systems provide many system-level tools,

Oracle itself provides many tools of this type, such as oradebug, various wait events and tracking methods. In addition, various types of operating systems provide many system-level tools,

The so-called operating system is the intermediate layer for communications between applications and server hardware. All operations of an application communicate with the operating system. The operating system is responsible for converting all interactions into device languages for hardware interactions.

We often need to understand the operations and details of background operations when performing Oracle fault debugging and kernel principles. In some fault scenarios, such as program process hang and login failure, you need to monitor the operating system and check and locate the problem.

Oracle itself provides many tools of this type, such as oradebug, various wait events and tracking methods. In addition, various types of operating systems provide many system-level tools to help us monitor them. This article describes the typical use of strace in Linux.

1. Environment Introduction

The author uses Red Hat 6.5 for testing.

[Root @ XXX-Standby-Asm ~] # Cat/etc/RedHat-release

Red Hat Enterprise Linux Server release 6.5 (Santiago)

[Root @ XXX-Standby-Asm ~] # Uname-

Linux XXX-Standby-Asm 2.6.32-431. el6.x86 _ 64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

The corresponding Oracle version is 11.2.0.4.

[Oracle @ XXX-Standby-Asm ~] $ Sqlplus/nolog

SQL * Plus: Release 11.2.0.4.0 Production on Tue Jun 16 16:39:21 2015

Copyright (c) 1982,201 3, Oracle. All rights reserved.

SQL> conn/as sysdba

Connected.

SQL> select * from v $ version;

BANNER

--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0-64bit Production

PL/SQL Release 11.2.0.4.0-Production

CORE 11.2.0.4.0 Production

TNS for Linux: Version 11.2.0.4.0-Production

NLSRTL Version 11.2.0.4.0-Production

2. Strace Command Information

The-h parameter can be used to call the syntax format and parameters of the strace command.

[Oracle @ XXX-Standby-Asm ~] $ Strace-h

Usage: strace [-dDffhiqrtttTvVxx] [-a column] [-e expr]... [-o file]

[-P pid]... [-s strsize] [-u username] [-E var = val]...

[Command [arg...]

Or: strace-c [-D] [-e expr]... [-O overhead] [-S sortby] [-E var = val]...

[Command [arg...]

-C -- count time, cballs, and errors for each syscall and report summary

-F -- follow forks,-ff -- with output into separate files

-F -- attempt to follow vforks,-h -- print help message

-I -- print instruction pointer at time of syscall

-Q -- suppress messages about attaching, detaching, etc.

-R -- print relative timestamp,-t -- absolute timestamp,-tt -- with usecs

-T -- print time spent in each syscall,-V -- print version

-V -- verbose mode: print unabbreviated argv, stat, termio [s], etc. args

-X -- print non-ascii strings in hex,-xx -- print all strings in hex

-A column -- alignment COLUMN for printing syscall results (default 40)

-E expr -- a qualifying expression: option = [!] All or option = [!] Val1 [, val2]...

Options: trace, abbrev, verbose, raw, signal, read, or write

-O file -- send trace output to FILE instead of stderr

-O overhead -- set overhead for tracing syscallto OVERHEAD usecs

-P pid -- trace process with process id PID, may be repeated

-D -- run tracer process as a detached grandchild, not as parent

-S strsize -- limit length of print strings to STRSIZE chars (default 32)

-S sortby -- sort syscall counts by: time, call, name, nothing (default time)

-U username -- run command as username handling setuid and/or setgid

-E var = val -- put var = val in the environment for command

-E var -- remove var from the environment for command

Among the many parameters, the following are commonly used:

U-t parameter: displays the time when the operating system is called. This is very important in diagnosis. If you find that a certain execution process consumes a large amount of time, you can locate the problem;

Ü-p parameter: in addition to monitoring the process from startup, strace can also enter a running process for debugging according to the operating system process number;

Ü-o parameter: If the output result needs to be saved as a file, specify the file name through the-o parameter;

U-e parameter: Monitoring expression. Trace, signal, read, and write are provided to reflect monitoring projects. Common parameters are trace = file, which are concentrated at the file access level of the operating system.

The following two typical application scenarios are used to demonstrate the strace application.

3. Start Program monitoring

An important example of strace monitoring research is sqlplus. Many predecessors use this tool to test the file format used to track access to the sqlplus startup process. Start strace to monitor sqlplus, that is, directly enter the sqlplus command after the strace command.

-- Start command

[Oracle @ localhost ~] $ Strace-t-e trace = file sqlplus/nolog

14:21:14 execve ("/u01/app/oracle/bin/sqlplus", ["sqlplus", "/nolog"], [/* 31 vars */]) = 0-start command

14:21:14 access ("/etc/ld. so. preload", R_ OK) =-1 ENOENT (No such file or directory)

14:21:14 open ("/u01/app/oracle/lib/tls/x86_64/libsqlplus. so", O_RDONLY) =-1 ENOENT (No such file or directory)

14:21:14 stat ("/u01/app/oracle/lib/tls/x86_64", 0x7fff3076da50) =-1 ENOENT (No such file or directory)

14:21:14 open ("/u01/app/oracle/lib/tls/libsqlplus. so", O_RDONLY) =-1 ENOENT (No such file or directory)

14:21:14 stat ("/u01/app/oracle/lib/tls", 0x7fff3076da50) =-1 ENOENT (No such file or directory)

14:21:14 open ("/u01/app/oracle/lib/x86_64/libsqlplus. so", O_RDONLY) =-1 ENOENT (No such file or directory)

14:21:14 stat ("/u01/app/oracle/lib/x86_64", 0x7fff3076da50) =-1 ENOENT (No such file or directory)

14:21:14 open ("/u01/app/oracle/lib/libsqlplus. so", O_RDONLY) = 3

14:21:14 open ("/u01/app/oracle/lib/libclntsh. so.11.1", O_RDONLY) = 3

14:21:14 open ("/u01/app/oracle/lib/libnnz11.so", O_RDONLY) = 3

14:21:14 open ("/u01/app/oracle/lib/libdl. so.2", O_RDONLY) =-1 ENOENT (No such file or directory)

(Space reasons, omitted ......)

14:21:14 access ("/etc/tnsnail v. ora", F_ OK) =-1 ENOENT (No such file or directory)

14:21:14 access ("/u01/app/oracle/network/admin/tnsnail v. ora", F_ OK) =-1 ENOENT (No such file or directory)

14:21:14 open ("/u01/app/oracle/oracore/zoneinfo", O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC) = 6

14:21:14 open ("/u01/app/oracle/oracore/zoneinfo/timezlrg_1.dat", O_RDONLY) = 7

14:21:14 open ("/u01/app/oracle/oracore/zoneinfo/timezlrg_2.dat", O_RDONLY) = 7

(Read data in various time zones ......)

14:21:14 open ("/u01/app/oracle/oracore/zoneinfo/timezone_14.dat", O_RDONLY) = 7

14:21:14 open ("/u01/app/oracle/oracore/zoneinfo/timezlrg_14.dat", O_RDONLY) = 6

14:21:14 open ("/usr/lib64/libnuma. so", O_RDONLY) =-1 ENOENT (No such file or directory)

14:21:14 open ("/usr/lib64/libnuma. so.1", O_RDONLY) = 6

14:21:14 open ("/proc/self/status", O_RDONLY) = 6

14:21:14 open ("/sys/devices/system/node", O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC) = 6

14:21:14 open ("/sys/devices/system/node/node0/meminfo", O_RDONLY) = 7

14:21:14 open ("/sys/devices/system/cpu", O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC) = 6

14:21:14 open ("/proc/self/status", O_RDONLY) = 6

14:21:14 open ("/proc/sys/kernel/shmmax", O_RDONLY) = 6

14:21:14 open ("/proc/meminfo", O_RDONLY) = 6

14:21:14 open ("/usr/lib64/libnuma. so", O_RDONLY) =-1 ENOENT (No such file or directory)

14:21:14 open ("/etc/localtime", O_RDONLY) = 6

14:21:14 open ("/u01/app/oracle/rdbms/mesg/ocius. msb", O_RDONLY) = 6

SQL * Plus: Release 11.2.0.4.0 Production on Fri Jun 12 14:21:14 2015

Copyright (c) 1982,201 3, Oracle. All rights reserved.

-- The file to be read after startup.

14:21:14 stat ("login. SQL", 0x7fff3076c740) =-1 ENOENT (No such file or directory)

14:21:14 stat ("/u01/app/oracle/sqlplus/admin/glogin. SQL", {st_mode = S_IFREG | 0644, st_size = 368,...}) = 0

14:21:14 access ("/u01/app/oracle/sqlplus/admin/glogin. SQL", F_ OK) = 0

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.