当前位置: 首页 > BASIC, LINUX > 正文

1,测试环境

www.htz.pw > !lsb_release -a

LSB Version:    :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch

Distributor ID: RedHatEnterpriseServer

Description:    Red Hat Enterprise Linux Server release 4.8 (Tikanga)

Release:        4.8

Codename:       Tikanga

 

www.htz.pw > select * from v$version where rownum<3;

 

BANNER

—————————————————————-

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 – 64bi

PL/SQL Release 10.2.0.5.0 – Production

2,数据库中修改指定进程的调度策略

linux环境中进程调度的策略有如下几种:

普通的分时策略    TS  SCHED_OTHER

实时FIFO的策略    FF  SCHED_FIFO

实时时间片策略    RR  SCHED_RR

普通批处理策略   B  SCHED_BATCH

下面lgwr为例在数据库中修改进程的调度策略

[root@www.htz.pw ~]#ps -Acfl|head -1;ps -Acfl|grep lgwr

F S UID        PID  PPID CLS PRI ADDR SZ WCHAN  STIME TTY          TIME CMD

0 S oracle   22959     1 TS   24 – 70706 –      Jul17 ?        00:00:00 asm_lgwr_+ASM

0 S oracle   26054     1 TS   41 – 190806 –     05:26 ?        00:00:00 ora_lgwr_asm10g

0 R root     26227 26114 TS   21 – 15296 –      05:53 pts/4    00:00:00 grep lgwr

 

 

 

www.htz.pw > alter system set "_high_priority_processes"="LMS*|LGWR" scope=spfile;

 

System altered.

 

www.htz.pw > startup force;

ORACLE instance started.

 

Total System Global Area  599785472 bytes

Fixed Size                  2098112 bytes

Variable Size             163580992 bytes

Database Buffers          427819008 bytes

Redo Buffers                6287360 bytes

Database mounted.

Database opened.

www.htz.pw > show parameter high

 

NAME                                 TYPE

———————————— ———–

VALUE

——————————

_high_priority_processes             string

LMS*|LGWR

 

[root@www.htz.pw ~]#ps -Acfl|head -1;ps -Acfl|grep lgwr

F S UID        PID  PPID CLS PRI ADDR SZ WCHAN  STIME TTY          TIME CMD

0 S oracle   22959     1 TS   24 – 70706 –      Jul17 ?        00:00:00 asm_lgwr_+ASM

0 S oracle   26054     1 RR   41 – 190806 –     05:26 ?        00:00:00 ora_lgwr_asm10g

0 R root     26227 26114 TS   21 – 15296 –      05:53 pts/4    00:00:00 grep lgwr

这里可以看到lgwr的调试策略已经更改为RR模式。

3,操作系统更改进程调度模式

在操作以上面我们也可以通过chrt来更改进程的调度模式,不过只能在root用户下面执行,下面以dbw为例

[root@www.htz.pw ~]#chrt -r -p 1 26052

[root@www.htz.pw ~]#ps -Afl|head -1;ps -Afl|grep dbw

F S UID        PID  PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD

0 S oracle   22957     1  0  75   0 – 71540 –      Jul17 ?        00:00:00 asm_dbw0_+ASM

0 S oracle   26052     1  0  58   – – 186310 –     05:26 ?        00:00:00 ora_dbw0_asm10g

0 R root     26555 26114  0  79   0 – 15296 –      06:42 pts/4    00:00:00 grep dbw

[root@www.htz.pw ~]#ps -Afcl|head -1;ps -Afcl|grep dbw

F S UID        PID  PPID CLS PRI ADDR SZ WCHAN  STIME TTY          TIME CMD

0 S oracle   22957     1 TS   24 – 71540 –      Jul17 ?        00:00:00 asm_dbw0_+ASM

0 S oracle   26052     1 RR   41 – 186310 –     05:26 ?        00:00:00 ora_dbw0_asm10g

0 R root     26559 26114 TS   20 – 15296 –      06:42 pts/4    00:00:00 grep dbw

下面将dbw进程调度模式从RR更改TS

[root@www.htz.pw ~]#chrt –other -p 0 26052

[root@www.htz.pw ~]#ps -Afcl|head -1;ps -Afcl|grep dbw

F S UID        PID  PPID CLS PRI ADDR SZ WCHAN  STIME TTY          TIME CMD

0 S oracle   22957     1 TS   24 – 71540 –      Jul17 ?        00:00:00 asm_dbw0_+ASM

0 S oracle   26052     1 TS   29 – 186310 –     05:26 ?        00:00:00 ora_dbw0_asm10g

0 R root     26586 26114 TS   20 – 15296 –      06:47 pts/4    00:00:00 grep db

3renice更改进程优先级

renice只能在root用户下才能提高进程优先级,普通用户下只能降低进程的优化先级

下面两样以dbw进程为例

[root@www.htz.pw ~]#ps -Afcl|head -1;ps -Afcl|grep dbw

F S UID        PID  PPID CLS PRI ADDR SZ WCHAN  STIME TTY          TIME CMD

0 S oracle   22957     1 TS   24 – 71540 –      Jul17 ?        00:00:00 asm_dbw0_+ASM

0 S oracle   26052     1 TS   29 – 186310 –     05:26 ?        00:00:00 ora_dbw0_asm10g

0 R root     26532 26114 TS   20 – 15296 –      06:37 pts/4    00:00:00 grep dbw

[root@www.htz.pw ~]#ps -Afl|head -1;ps -Afl|grep dbw

F S UID        PID  PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD

0 S oracle   22957     1  0  75   0 – 71540 –      Jul17 ?        00:00:00 asm_dbw0_+ASM

0 S oracle   26052     1  0  75   0 – 186310 –     05:26 ?        00:00:00 ora_dbw0_asm10g

0 R root     26522 26114  0  79   0 – 15296 –      06:36 pts/4    00:00:00 grep dbw

这里看到DBW进程的调度策略为TSNI的值为0,下面我们将NI的更改为5

[root@www.htz.pw ~]#renice -5 -p 26052

26052: old priority 0, new priority -5

[root@www.htz.pw ~]#ps -Afl|head -1;ps -Afl|grep dbw

F S UID        PID  PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD

0 S oracle   22957     1  0  75   0 – 71540 –      Jul17 ?        00:00:00 asm_dbw0_+ASM

0 S oracle   26052     1  0  70  -5 – 186310 –     05:26 ?        00:00:00 ora_dbw0_asm10g

这里看到renice已经修改成功。

不过这里需要注意的是,renice修改进程的调试模式为RR时,提示修改成功,但是使用命令无法查看。

[root@www.htz.pw ~]#ps -Afcl|head -1;ps -Afcl|grep lgw

F S UID        PID  PPID CLS PRI ADDR SZ WCHAN  STIME TTY          TIME CMD

0 S oracle   22959     1 TS   24 – 70706 –      Jul17 ?        00:00:00 asm_lgwr_+ASM

0 S oracle   26054     1 RR   80 – 190806 –     05:26 ?        00:00:00 ora_lgwr_asm10g

0 R root     26541 26114 TS   20 – 15296 –      06:39 pts/4    00:00:00 grep lgw

[root@www.htz.pw ~]#renice -5 -p 26054

26054: old priority -5, new priority -5

[root@www.htz.pw ~]#ps -Afl|head -1;ps -Afl|grep lgw

F S UID        PID  PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD

0 S oracle   22959     1  0  75   0 – 70706 –      Jul17 ?        00:00:00 asm_lgwr_+ASM

0 S oracle   26054     1  0  19    – 190806 –     05:26 ?        00:00:00 ora_lgwr_asm10g

0 R root     26546 26114  0  79   0 – 15296 –      06:40 pts/4    00:00:00 grep lgw

linux环境ORACLE进程调度策略与优先级:等您坐沙发呢!

发表评论

gravatar

? razz sad evil ! smile oops grin eek shock ??? cool lol mad twisted roll wink idea arrow neutral cry mrgreen

快捷键:Ctrl+Enter