转载连接:http://www.askmaclean.com/archives/%E9%9A%90%E8%97%8F%E5%8F%82%E6%95%B0_high_priority_processes%E4%B8%8Eoradism.html
运行在操作系统上的进程存在2种系统时序优先级模式:即 实时模式 Real Time(RT) mode, 与分时模式 Time Sharing(TS) mode.
绝大多数Oracle进程运行在TS模式下:
[oracle@rh1 ~]$ ps -efc|grep ora_|grep -v grep oracle 8510 1 TS 23 Mar27 ? 00:00:02 ora_pmon_PROD oracle 8512 1 TS 23 Mar27 ? 00:00:00 ora_psp0_PROD oracle 8514 1 TS 23 Mar27 ? 00:00:00 ora_mman_PROD oracle 8516 1 TS 23 Mar27 ? 00:00:02 ora_dbw0_PROD oracle 8518 1 TS 23 Mar27 ? 00:00:04 ora_lgwr_PROD oracle 8520 1 TS 23 Mar27 ? 00:00:04 ora_ckpt_PROD oracle 8522 1 TS 23 Mar27 ? 00:00:08 ora_smon_PROD oracle 8524 1 TS 23 Mar27 ? 00:00:00 ora_reco_PROD oracle 8526 1 TS 23 Mar27 ? 00:00:34 ora_cjq0_PROD oracle 8528 1 TS 23 Mar27 ? 00:00:06 ora_mmon_PROD oracle 8530 1 TS 24 Mar27 ? 00:00:07 ora_mmnl_PROD oracle 8538 1 TS 23 Mar27 ? 00:00:00 ora_arc0_PROD oracle 8540 1 TS 23 Mar27 ? 00:00:00 ora_arc1_PROD oracle 8548 1 TS 23 Mar27 ? 00:00:00 ora_qmnc_PROD oracle 8555 1 TS 23 Mar27 ? 00:00:00 ora_q000_PROD oracle 8559 1 TS 23 Mar27 ? 00:00:00 ora_q001_PROD oracle 30500 1 TS 23 22:10 ? 00:00:00 ora_j000_PROD
如上所示所有进程均运行在TS模式下且priority均为23|24.
Oracle一般不推荐使用RT模式,因为虽然个别进程可以通过这种方式获得更多的CPU资源,但往往系统的瓶颈并非CPU,即尽管CPU使用率高了,但实际系统TPS并未得到提升。
在10gr2版本后RAC中的LMS进程成为唯一一个使用RT模式的Oracle进程,我们可以通过查询参数_high_priority_processes了解相关信息:
SQL> col name format a40 SQL> SELECT x.ksppinm NAME, y.ksppstvl VALUE 2 FROM SYS.x$ksppi x, SYS.x$ksppcv y 3 WHERE x.inst_id = USERENV ('Instance') 4 AND y.inst_id = USERENV ('Instance') 5 AND x.indx = y.indx 6 AND x.ksppinm LIKE '%priority%'; NAME VALUE ---------------------------------------- ---------- _high_priority_processes LMS* _os_sched_high_priority 1
_high_priority_processes通过进程功能名进行匹配,下面我们将提高LGWR及PMON进程的优先级:
SQL> alter system set "_high_priority_processes"='LMS*|LGWR|PMON' scope=spfile; System altered. SQL> startup force; ORACLE instance started. Total System Global Area 281018368 bytes Fixed Size 2083336 bytes Variable Size 150996472 bytes Database Buffers 121634816 bytes Redo Buffers 6303744 bytes Database mounted. Database opened. SQL> !ps -efc|grep ora_|grep -v grep oracle 31441 1 RR 41 22:50 ? 00:00:00 ora_pmon_PROD oracle 31445 1 TS 23 22:50 ? 00:00:00 ora_psp0_PROD oracle 31447 1 TS 23 22:50 ? 00:00:00 ora_mman_PROD oracle 31449 1 TS 23 22:50 ? 00:00:00 ora_dbw0_PROD oracle 31451 1 RR 41 22:50 ? 00:00:00 ora_lgwr_PROD oracle 31455 1 TS 23 22:50 ? 00:00:00 ora_ckpt_PROD oracle 31457 1 TS 23 22:50 ? 00:00:00 ora_smon_PROD oracle 31459 1 TS 22 22:50 ? 00:00:00 ora_reco_PROD oracle 31461 1 TS 23 22:50 ? 00:00:01 ora_cjq0_PROD oracle 31463 1 TS 23 22:50 ? 00:00:01 ora_mmon_PROD oracle 31465 1 TS 24 22:50 ? 00:00:00 ora_mmnl_PROD oracle 31471 1 TS 24 22:50 ? 00:00:00 ora_p000_PROD oracle 31473 1 TS 24 22:50 ? 00:00:00 ora_p001_PROD oracle 31475 1 TS 24 22:50 ? 00:00:00 ora_arc0_PROD oracle 31477 1 TS 22 22:50 ? 00:00:00 ora_arc1_PROD oracle 31481 1 TS 23 22:50 ? 00:00:00 ora_qmnc_PROD oracle 31488 1 TS 23 22:50 ? 00:00:00 ora_q000_PROD oracle 31490 1 TS 23 22:50 ? 00:00:00 ora_q001_PROD oracle 31500 1 TS 23 22:50 ? 00:00:00 ora_j000_PROD
好了lgwr和pmon进程也进入实时模式了,同时priority值上升到了41.
注意:
Oracle默认仅允许LMS进程(11g中多了VKTM进程)使用RT模式是有它的原因的,所以如果不是Oracle support 推荐,您没有任何修改隐式参数的理由。
其次根据Oracle文档[ID 602419.1]的描述,oradism文件(该文件位于$ORACLE_HOME/bin目录下)不正确的权限将导致RT模式无法被正确使用,该文件默认属于root用户并具有s权限。如下测试:
[oracle@rh1 bin]$ ls -la oradism -r-sr-s--- 1 root oinstall 14931 Mar 11 2008 oradism [oracle@rh1 bin]$ su - root Password: [root@rh1 ~]# chown oracle:oinstall /s01/oracle/product/10.2.0/db_1/bin/oradism [root@rh1 ~]# exit logout [oracle@rh1 bin]$ ls -la oradism -r-xr-x--- 1 oracle oinstall 14931 Mar 11 2008 oradism [oracle@rh1 bin]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Sun Mar 28 23:07:03 2010 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup; ORACLE instance started. Total System Global Area 281018368 bytes Fixed Size 2083336 bytes Variable Size 150996472 bytes Database Buffers 121634816 bytes Redo Buffers 6303744 bytes Database mounted. Database opened. SQL> col name format a35; SQL> col value format a10; SQL> SELECT x.ksppinm NAME, y.ksppstvl VALUE 2 FROM SYS.x$ksppi x, SYS.x$ksppcv y 3 WHERE x.inst_id = USERENV ('Instance') 4 AND y.inst_id = USERENV ('Instance') 5 AND x.indx = y.indx 6 AND x.ksppinm LIKE '%priority%'; NAME VALUE ----------------------------------- ---------- _high_priority_processes LMS*|LGWR|PMON _os_sched_high_priority 1 SQL> !ps -efc|grep ora_|grep -v grep oracle 31994 1 TS 23 23:07 ? 00:00:00 ora_pmon_PROD oracle 31998 1 TS 23 23:07 ? 00:00:00 ora_psp0_PROD oracle 32000 1 TS 23 23:07 ? 00:00:00 ora_mman_PROD oracle 32002 1 TS 23 23:07 ? 00:00:00 ora_dbw0_PROD oracle 32004 1 TS 24 23:07 ? 00:00:00 ora_lgwr_PROD oracle 32008 1 TS 22 23:07 ? 00:00:00 ora_ckpt_PROD oracle 32010 1 TS 23 23:07 ? 00:00:00 ora_smon_PROD oracle 32012 1 TS 22 23:07 ? 00:00:00 ora_reco_PROD oracle 32014 1 TS 23 23:07 ? 00:00:01 ora_cjq0_PROD oracle 32016 1 TS 23 23:07 ? 00:00:01 ora_mmon_PROD oracle 32018 1 TS 24 23:07 ? 00:00:00 ora_mmnl_PROD oracle 32026 1 TS 24 23:07 ? 00:00:00 ora_arc0_PROD oracle 32028 1 TS 23 23:07 ? 00:00:00 ora_arc1_PROD oracle 32032 1 TS 23 23:07 ? 00:00:00 ora_qmnc_PROD oracle 32045 1 TS 23 23:07 ? 00:00:00 ora_q000_PROD oracle 32065 1 TS 23 23:08 ? 00:00:00 ora_q001_PROD oracle 32072 1 TS 23 23:08 ? 00:00:00 ora_j000_PROD
that’s great, 显然oradism不仅为Oracle实例提供了内存资源控制功能,还包括了进程优先级分配的权限。
我们应当再次声明hidden parameter不应“滥用”于production environment.