萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 作業系統 >  >> Linux 教學

Linux 透過 ps 指令快速查看 Oracle 相關進程完整指南

Oracle 資料庫運行時會產生大量背景進程,運維人員常需快速辨識各進程用途。本文整理 ps 指令搭配 grep 的實用篩選模式,涵蓋 Listener、背景進程、Management Agent 三大類,並對應 v$session 視圖驗證。

1. Oracle Listener 進程

[oracle@www.linuxidc.com ~]$ ps -ef | grep tnslsnr
oracle 1999 29986 0 09:47 pts/2 00:00:00 grep tnslsnr
oracle 3647 1 0 Jul03 ? 00:00:34 /u01/oracle/mc3yd213/db/tech_st/11.1.0/bin/tnslsnr mc3yd213 -inherit
oracle 6431 1 0 Jul03 ? 00:00:00 /u01/oracle/mc3yd213/apps/tech_st/10.1.2/bin/tnslsnr APPS_mc3yd213 -inherit
oracle 13616 1 0 May27 ? 00:00:40 /u01/oracle/mc3yd213/apps/tech_st/10.1.2/bin/tnslsnr LISTENER -inherit

關鍵字 tnslsnr 可精準過濾所有 Listener 進程,包含資料庫與應用層的多個監聽器。

2. Oracle 背景進程

[oracle@www.linuxidc.com ~]$ ps -ef | grep -i "ora_"
oracle 1887 1 0 09:42 ? 00:00:00 ora_w000_mc3yd213
oracle 2159 1 0 09:54 ? 00:00:00 ora_j000_mc3yd213
oracle 2167 29986 0 09:55 pts/2 00:00:00 grep -i ora_
oracle 3516 1 0 Jul03 ? 00:02:00 ora_pmon_mc3yd213
oracle 3518 1 0 Jul03 ? 00:02:08 ora_vktm_mc3yd213
oracle 3522 1 0 Jul03 ? 00:00:27 ora_diag_mc3yd213
oracle 3524 1 0 Jul03 ? 00:00:18 ora_dbrm_mc3yd213
oracle 3526 1 0 Jul03 ? 00:00:35 ora_psp0_mc3yd213
oracle 3528 1 0 Jul03 ? 00:05:59 ora_dia0_mc3yd213
oracle 3530 1 0 Jul03 ? 00:00:19 ora_mman_mc3yd213
oracle 3532 1 0 Jul03 ? 00:01:06 ora_dbw0_mc3yd213
oracle 3534 1 0 Jul03 ? 00:02:53 ora_lgwr_mc3yd213
oracle 3536 1 0 Jul03 ? 00:02:08 ora_ckpt_mc3yd213
oracle 3538 1 0 Jul03 ? 00:01:36 ora_smon_mc3yd213
oracle 3540 1 0 Jul03 ? 00:00:06 ora_reco_mc3yd213
oracle 3542 1 0 Jul03 ? 00:02:01 ora_mmon_mc3yd213
oracle 3544 1 0 Jul03 ? 00:03:20 ora_mmnl_mc3yd213
oracle 3564 1 0 Jul03 ? 00:00:09 ora_fbda_mc3yd213
oracle 3569 1 0 Jul03 ? 00:00:16 ora_qmnc_mc3yd213
oracle 3584 1 0 Jul03 ? 00:00:36 ora_q000_mc3yd213
oracle 3586 1 0 Jul03 ? 00:00:15 ora_q001_mc3yd213
oracle 3690 1 0 Jul03 ? 00:02:30 ora_cjq0_mc3yd213
oracle 3707 1 0 Jul03 ? 00:00:28 ora_smco_mc3yd213
oracle 7676 1 0 Jul03 ? 00:42:49 ora_m000_mc3yd213

以 ora_ 為前綴的進程即為 Oracle 背景進程。常見進程對照:

資料庫視圖驗證

亦可透過 SQL 查詢確認背景進程:

SELECT * FROM v$session WHERE type = 'BACKGROUND';

PROGRAM 欄位將顯示 SMON、MMON、CKPT、PMON、MMAN、MMNL 等進程名稱。

3. Oracle Management Agent (OEM Agent)

[oracle@www.linuxidc.com ~]$ ps -ef | grep emagent
oracle 2097 29986 0 09:51 pts/2 00:00:00 grep emagent
oraem 3130 1 0 May24 ? 00:08:57 /opt/oracle/oraem/agent10g/perl/bin/perl /opt/oracle/oraem/agent10g/bin/emwd.pl agent /opt/oracle/oraem/agent10g/sysman/log/emagent.nohup
oraem 3150 3130 0 May24 ? 00:25:56 /opt/oracle/oraem/agent10g/bin/emagent

關鍵字 emagent 可過濾 Enterprise Manager Agent 進程,通常以 oraem 用戶運行。

圖示說明

Oracle 進程查看示意圖

總結

掌握 ps -ef | grep tnslsnr、ps -ef | grep -i ora_、ps -ef | grep emagent 三組指令,即可快速掌握 Oracle 核心進程狀態。建議收藏備查,大幅提升排障效率。

copyright © 萬盛學電腦網 all rights reserved
進程名稱全名功能說明
PMONProcess Monitor使用者進程異常終止時釋放資源(如釋放鎖)
SMONSystem Monitor執行實例恢復、清理臨時段
DBWnDatabase Writer將緩衝區髒塊寫入資料檔
LGWRLog Writer將重做日誌緩衝寫入線上重做日誌檔
CKPTCheckpoint定期更新資料檔標頭與控制檔
MMON/MMNLManageability Monitor負責 AWR 統計收集與閾值告警
RECORecoverer處理分散式交易恢復