1. 先看2個(gè)命令執(zhí)行的結(jié)果:
[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 的區(qū)別是顯示的選項(xiàng)不一樣,aux 能顯示進(jìn)程占用的 內(nèi)存 和CPU.
????2. Less 可以對(duì)返回結(jié)果上下翻動(dòng)
?
?
2. 我們?cè)诜?wù)器上用sqlplus 連接數(shù)據(jù)庫(kù),在查看進(jìn)程,會(huì)多出一條記錄:
oracle???16007 16006??0 10:27 ???00:00:00
oraclenewccs (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
?
通過(guò)上面2個(gè)示例,我們可以看出區(qū)別在 LOCAL=NO 和 LOCAL=YES。
LOCAL=NO :非本地連接,即網(wǎng)絡(luò)連接。 它是通過(guò)Listener 連接到服務(wù)器的。 客戶端的應(yīng)用通過(guò)客戶端的監(jiān)聽向服務(wù)器的監(jiān)聽發(fā)送請(qǐng)求,服務(wù)器的監(jiān)聽接收后,在與數(shù)據(jù)庫(kù)連接,執(zhí)行相關(guān)操作,在把結(jié)果返回給客戶端。 這是通過(guò)監(jiān)聽的流程。 所以在客戶端需要配置監(jiān)聽,即配置tnsnames.ora。
LOCAL=YES:本地連接。 本地連接不走監(jiān)聽,所以在服務(wù)監(jiān)聽沒有啟動(dòng)的情況下,通過(guò)本地的sqlplus 還是可以連上數(shù)據(jù)庫(kù)的。
?
現(xiàn)在就有一個(gè)問(wèn)題,假如我們?cè)诳蛻舳送ㄟ^(guò)PL/SQL developer 或者 Toad 工具連上服務(wù)器后,在執(zhí)行sql 的過(guò)程中死掉了,我們只能結(jié)束程序,亦或者我們直接kill 掉toad 的進(jìn)程,那么在服務(wù)器上并不會(huì)釋放之間建立的監(jiān)聽進(jìn)程。 沒有釋放的相關(guān)進(jìn)程還是繼續(xù)占用系統(tǒng)資源。 所以對(duì)于這些已經(jīng)死掉的進(jìn)程,我們可以kill 掉這些進(jìn)程: kill -9 PID。不過(guò)在生產(chǎn)庫(kù)上要慎用,要確認(rèn)進(jìn)程是死掉的才可以kill。
LOCAL=NO的進(jìn)程分析處理
2008-09-01 23:26
?????????????????????????殺死運(yùn)行3天以上LOCAL=NO的進(jìn)程 --------------------------------------------------------------------------------------- 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.實(shí)例分析 -------------------------------------------------------------------------------------- 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.參數(shù)說(shuō)明 --------------------------------------------------------------------------------------
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}'
總結(jié)
以上是生活随笔 為你收集整理的Oracle 服务器 进程中的 LOCAL=NO 和 LOCAL=YES 的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺得生活随笔 網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔 推薦給好友。