[Oracle工程师手记] 通过 lsof 命令查找oracle client 端和 server 端进程

时间:2021-04-10 13:37:55   收藏:0   阅读:0

通过 lsof 命令,可以找到 Oracle 的 client 端 和 server 端的进程。

例如,我从远端连接到 oracle 数据库:

-bash-4.1$ sqlplus sys/oracle@my19c as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sat Apr 10 03:45:20 2021

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

SQL>

 
在 server 端,我可以通过 LOCAL=NO 关键字,找到为远端client 服务的进程:

[oracle@celvpvm06027 ~]$ ps -ef | grep oracle | grep LOCAL
oracle    4609     1  0 02:45 ?        00:00:00 oracledb193cdb (LOCAL=NO)
oracle   29721 29696  0 02:55 pts/0    00:00:00 grep --color=auto LOCAL
[oracle@celvpvm06027 ~]$

可以看到,服务器端进程ID 是 4609。

这时,通过 lsof ,可以找到与之进行网络通信的client 端进程:

[oracle@celvpvm06027 ~]$ lsof -p 4609 | grep ESTABLISHED
oracle_46 4609 oracle   16u     IPv6 492894739       0t0       TCP my06027.mytst.com:ncube-lm->my05200.mytst.com:62311 (ESTABLISHED)
[oracle@celvpvm06027 ~]$

 
我在client 端,用上面查询得到的 62311 ,通过 lsof 来查询:

-bash-4.1$ lsof | grep 62311
sqlplus    6123    oracle    9u     IPv4            4946370       0t0        TCP my05200.mytst.com:62311->my06027.mytst.com:ncube-lm (ESTABLISHED)
-bash-4.1$

-bash-4.1$ ps -ef | grep 6123
oracle    6123  5861  0 03:45 pts/0    00:00:00 sqlplus                  as sysdba
oracle    7031  6183  0 03:58 pts/1    00:00:00 grep 6123
-bash-4.1$

 
可以得知,client 端进程 ID 是 6123。

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!