linux pstack命令总结
2016-03-07 11:50 潇湘隐者 阅读(15800) 评论(1) 编辑 收藏 举报pstack命令用来显示进程的栈跟踪。 pstack 命令必须由相应进程的属主或root账号运行。可以使用pstack来确定进程挂起的位置。此命令只有一个参数,那就是pid,具体关于pstack的介绍可以查看man手册,如下所示:
[root@DB-Server ~]# man pstack
PSTACK(1) Linux Programmer’s Manual PSTACK(1)
NAME
pstack - print a stack trace of a running process
SYNOPSIS
pstack pid
DESCRIPTION
pstack attaches to the active process named by the pid on the command line, and prints out an execution stack trace. If ELF symbols exist in the binary (usually the case
unless you have run strip(1)), then symbolic addresses are printed as well.
If the process is part of a thread group, then pstack will print out a stack trace for each of the threads in the group.
SEE ALSO
nm(1), ptrace(2), gdb(1)
AUTHORS
Ross Thompson <ross@whatsis.com>
Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Red Hat Linux Dec 17 2004 PSTACK(1)
(END)
例如我们可以使用pstack命令来查看Oracle监听进程的栈跟踪,如下所示
1: 首先找到监听进程的进程号
[oracle@DB-Server~]$ ps -ef | grep lsn
oracle 12027 11806 0 11:18 pts/1 00:00:00 grep lsn
oracle 31440 1 0 Mar04 ? 00:01:41 /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
2: 将监听进程的栈跟踪信息写入文件lsn_pstack.log
[oracle@DB-Server~]$ pstack 31440 >> lsn_pstack.log
[oracle@DB-Server~]$ pstack 31440 >> lsn_pstack.log
[oracle@DB-Server~]$ pstack 31440 >> lsn_pstack.log
[oracle@DB-Server~]$
3:如下所示,我们可以看到函数调用关系为:main->nsglma->nsevwait->ntevque->ntevpque->poll.
[oracle@DB-Server~]$ more lsn_pstack.log
#0 0x0000003c7d0cb65f in poll () from /lib64/libc.so.6
#1 0x00007f82c63292e7 in ntevpque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#2 0x00007f82c6326aab in ntevque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#3 0x00007f82c62fc81e in nsevwait () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#4 0x00000000004108d9 in nsglma ()
#5 0x0000000000405abd in main ()
#0 0x0000003c7d0cb65f in poll () from /lib64/libc.so.6
#1 0x00007f82c63292e7 in ntevpque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#2 0x00007f82c6326aab in ntevque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#3 0x00007f82c62fc81e in nsevwait () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#4 0x00000000004108d9 in nsglma ()
#5 0x0000000000405abd in main ()
#0 0x0000003c7d0cb65f in poll () from /lib64/libc.so.6
#1 0x00007f82c63292e7 in ntevpque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#2 0x00007f82c6326aab in ntevque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#3 0x00007f82c62fc81e in nsevwait () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#4 0x00000000004108d9 in nsglma ()
#5 0x0000000000405abd in main ()
[oracle@DB-Server~]$

· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· DeepSeek 解答了困扰我五年的技术问题
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
2015-03-07 RMAN-06023: no backup or copy of datafile 1 found to restore
2014-03-07 Database 'xxx' cannot be upgraded because it is read-only or has read-only file Make the database or files writeable, and rerun recovery.
2014-03-07 Tomcat启动找不到JRE_HOME的解决方法