1. 先看2個命令執行的結果:
[oracle@localhost ~]$ ps -ef | less
UID????????PID??PPID??C STIME TTY??????????TIME CMD
oracle?????469?????1??0 May28 ?????????00:00:05 oraclenewccs (LOCAL=NO)
oracle?????495?????1??1 May28 ?????????05:57:23 oraclenewccs (LOCAL=NO)
oracle?????863?????1??1 May28 ?????????05:30:25 oraclenewccs (LOCAL=NO)
oracle????1209?????1??0 May28 ?????????01:19:29 oraclenewccs (LOCAL=NO)
oracle????1479?????1??0 May28 ?????????01:30:50 oraclenewccs (LOCAL=NO)
oracle????1583?????1??0 May28 ?????????01:32:50 oraclenewccs (LOCAL=NO)
oracle????2234?????1??0 May28 ?????????00:16:05 oraclenewccs (LOCAL=NO)
oracle????2285?????1??0 May28 ?????????00:17:24 oraclenewccs (LOCAL=NO)
oracle????2479?????1??0 May28 ?????????00:20:57 oraclenewccs (LOCAL=NO)
oracle????2891?????1??0 May28 ?????????00:03:55 oraclenewccs (LOCAL=NO)
oracle????3213?????1??0 May28 ?????????00:02:55 oraclenewccs (LOCAL=NO)
oracle????3447?????1??0 May28 ?????????00:03:58 oraclenewccs (LOCAL=NO)
oracle????3460?????1??0 May28 ?????????00:00:23 oraclenewccs (LOCAL=NO)
[oracle@localhost ~]$ ps -aux | less
USER???????PID %CPU %MEM???VSZ??RSS TTY??????STAT START???TIME COMMAND
oracle?????469??0.0??0.4 10759972 320408 ????Ss???May28???0:05 oraclenewccs (LOCAL=NO)
oracle?????495??1.2 10.1 10762344 7505684 ???Rs???May28 356:58 oraclenewccs (LOCAL=NO)
oracle?????863??1.1 10.0 10762344 7455964 ???Ss???May28 330:21 oraclenewccs (LOCAL=NO)
oracle????1209??0.2??7.3 10762216 5485856 ???Ss???May28??79:28 oraclenewccs (LOCAL=NO)
oracle????1479??0.3??7.5 10762344 5595556 ???Ss???May28??90:49 oraclenewccs (LOCAL=NO)
oracle????1583??0.3??7.6 10761216 5679140 ???Ss???May28??92:50 oraclenewccs (LOCAL=NO)
oracle????2234??0.0??5.9 10762212 4398364 ???Ss???May28??16:05 oraclenewccs (LOCAL=NO)
oracle????2285??0.0??5.8 10762220 4313736 ???Ss???May28??17:24 oraclenewccs (LOCAL=NO)
oracle????2479??0.0??5.9 10761176 4436164 ???Ss???May28??20:57 oraclenewccs (LOCAL=NO)
?
?
注:1. ps -aux 和 ps -ef 的區別是顯示的選項不一樣,aux 能顯示進程占用的 內存 和CPU.
????2. Less 可以對返回結果上下翻動
?
?
2. 我們在服務器上用sqlplus 連接數據庫,在查看進程,會多出一條記錄:
oracle???16007 16006??0 10:27 ???00:00:00
oraclenewccs (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
?
通過上面2個示例,我們可以看出區別在 LOCAL=NO 和 LOCAL=YES。
LOCAL=NO :非本地連接,即網絡連接。 它是通過Listener 連接到服務器的。 客戶端的應用通過客戶端的監聽向服務器的監聽發送請求,服務器的監聽接收后,在與數據庫連接,執行相關操作,在把結果返回給客戶端。 這是通過監聽的流程。 所以在客戶端需要配置監聽,即配置tnsnames.ora。
LOCAL=YES:本地連接。 本地連接不走監聽,所以在服務監聽沒有啟動的情況下,通過本地的sqlplus 還是可以連上數據庫的。
?
現在就有一個問題,假如我們在客戶端通過PL/SQL developer 或者 Toad 工具連上服務器后,在執行sql 的過程中死掉了,我們只能結束程序,亦或者我們直接kill 掉toad 的進程,那么在服務器上并不會釋放之間建立的監聽進程。 沒有釋放的相關進程還是繼續占用系統資源。 所以對于這些已經死掉的進程,我們可以kill 掉這些進程: kill -9 PID。不過在生產庫上要慎用,要確認進程是死掉的才可以kill。
LOCAL=NO的進程分析處理
2008-09-01 23:26
?????????????????????????殺死運行3天以上LOCAL=NO的進程 --------------------------------------------------------------------------------------- 1.腳本 -------------------------------------------------------------------------------------- HNDBSVR-3-/opt/oracle8/tools> touch kill3DPro.sh HNDBSVR-3-/opt/oracle8/tools> chmod +x kill3DPro.sh HNDBSVR-3-/opt/oracle8/tools> vi kill3DPro.sh HNDBSVR-3-/opt/oracle8/tools> cat kill3DPro.sh #!/bin/sh ps -e -o pid -o etime -o args|grep oracle|grep LOCAL=NO|grep ->/tmp/tmpfile # ps -e -o pid -o etime -o args|grep oracle|grep LOCAL=NO|grep -|awk '{print $2}'|awk -F- '{print $1}'? cat /tmp/tmpfile|while read LINE? do? TIME=`echo $LINE|awk '{print $2}'`? TIME=`echo $TIME|awk -F- '{print $1}'`? if [ $TIME -gt 3 ]? then? echo $LINE|awk '{print $1}'|xargs -t -n1 kill -9? fi? done? rm -f /tmp/tmpfile
-------------------------------------------------------------------------------------- 2.實例分析 -------------------------------------------------------------------------------------- ps -e -o pid -o etime -o args|grep oracle|grep LOCAL=NO 27897 4-04:45:50 oraclegpnms4 (LOCAL=NO) 2804??? 05:47:03 oraclegpnms4 (LOCAL=NO) 20078??? 01:14:52 oraclegpnms4 (LOCAL=NO) 19556??? 06:01:56 oraclegpnms4 (LOCAL=NO) 27855 4-04:45:52 oraclegpnms4 (LOCAL=NO) 12976 4-05:47:28 oraclegpnms4 (LOCAL=NO) 2414??? 05:47:51 oraclegpnms4 (LOCAL=NO) 8656??? 05:40:43 oraclegpnms4 (LOCAL=NO) 15656 11-06:21:13 oraclegpnms4 (LOCAL=NO) 2410??? 05:47:52 oraclegpnms4 (LOCAL=NO) 19083 28-11:42:58 oraclegpnms4 (LOCAL=NO) 10259 52-08:23:39 oraclegpnms4 (LOCAL=NO) 15620 11-06:21:15 oraclegpnms4 (LOCAL=NO) 20232 6-12:03:09 oraclegpnms4 (LOCAL=NO) 24844 1-07:54:46 oraclegpnms4 (LOCAL=NO) 2552??? 05:47:45 oraclegpnms4 (LOCAL=NO) 4338 17-19:23:28 oraclegpnms4 (LOCAL=NO) 3778 28-11:24:14 oraclegpnms4 (LOCAL=NO) 2412??? 05:47:52 oraclegpnms4 (LOCAL=NO) 3316??? 05:45:40 oraclegpnms4 (LOCAL=NO) 2939??? 05:46:40 oraclegpnms4 (LOCAL=NO) 3302??? 05:45:44 oraclegpnms4 (LOCAL=NO) 12662 30-11:37:37 oraclegpnms4 (LOCAL=NO) 24254 24-06:38:27 oraclegpnms4 (LOCAL=NO) 16504 55-13:42:30 oraclegpnms4 (LOCAL=NO) 2416??? 05:47:51 oraclegpnms4 (LOCAL=NO) 2530??? 05:47:45 oraclegpnms4 (LOCAL=NO) 2491??? 05:47:46 oraclegpnms4 (LOCAL=NO) 3585??? 05:44:53 oraclegpnms4 (LOCAL=NO) 29661 26-03:36:02 oraclegpnms4 (LOCAL=NO) 5409??? 02:35:57 oraclegpnms4 (LOCAL=NO) 23442 51-22:23:46 oraclegpnms4 (LOCAL=NO) 19204 3-13:14:05 oraclegpnms4 (LOCAL=NO) 10602 40-11:45:35 oraclegpnms4 (LOCAL=NO) 29541?????? 56:16 oraclegpnms4 (LOCAL=NO) 19805?????? 18:08 oraclegpnms4 (LOCAL=NO) -------------------------------------------------------------------------------------- 3.參數說明 --------------------------------------------------------------------------------------
ps -e -o pid -o etime -o args
-e Lists information about every process now running; -o Prints information according to the format specifica- ?????????? tion given in format. This is fully described in ?????????? DISPLAY FORMATS. Multiple -o options can be specified; ?????????? the format specification will be interpreted as the ?????????? space-character-separated concatenation of all the ?????????? format option-arguments. -A Lists information about all processes most frequently ?????????? requested: all those except process group leaders and ?????????? processes not associated with a terminal. -e etime In the POSIX locale, the elapsed time since the pro- ?????????? cess was started, in the form:
?????????? [[dd-]hh:]mm:ss args? ???? The command with all its arguments as a string. The ?????????? implementation may truncate this value to the field ?????????? width; it is implementation-dependent whether any ?????????? further truncation occurs. It is unspecified whether ?????????? the string represented is a version of the argument ?????????? list as it was passed to the command when it started, ?????????? or is a version of the arguments as they may have been ?????????? modified by the application.?? Applications cannot ?????????? depend on being able to modify their argument list and ?????????? having that modification be reflected in the output of ?????????? ps. The Solaris implementation limits the string to ?????????? 80 bytes; the string is the version of the argument ?????????? list as it was passed to the command when it started. -------------------------------------------------------------------------------------- 4.其它 --------------------------------------------------------------------------------------—?????????? ??????????? ps -e -o pid -o etime -o args|grep oracle|grep LOCAL=NO|grep -|awk '{print $2}'|awk -F: '{print $1}'
ps -e -o pid -o etime -o args|grep oracle|grep LOCAL=NO|grep -|awk '{print $2}'|awk -F- '{print $1}'
總結
以上是生活随笔 為你收集整理的Oracle 服务器 进程中的 LOCAL=NO 和 LOCAL=YES 的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔 網站內容還不錯,歡迎將生活随笔 推薦給好友。