ºìÁªLinuxÃÅ»§
Linux°ïÖú

ÈçºÎ¿ìËÙµÄɱµôOracleµÄSession

·¢²¼Ê±¼ä:2006-09-12 12:32:22À´Ô´:ºìÁª×÷Õß:samblue
Ò»¡¢ÎÊÌâµÄÌá³ö ºÜ¶àµÄʱºòÎÒÃÇѸËÙµÄɱµôOralcleµÄһЩsession,ÀíÓÉ´óÌåÈçÏ£º

1¡¢ һЩʱºò£¬ÓÉÓÚÎÒÃǵÄÊý¾ÝÁ¿ºÜ´ó£¬ÏàÓ¦µÄÊÂÎñ´ó²¢ÇҶ࣬ÔÚ×öshutdown immediateµÄʱºò»á»¨·ÑºÃ¶àµÄʱ¼ä£¬¶øÎÒÃÇÈ´ÏëÓÃshutdown immediateµÄ·½Ê½£¬¶øÓÖÒª°ÑÊý¾Ý¿âѸËÙµÄshutdownÏÂÀ´¡£

2¡¢ ÎÒÃǵÄÓ¦ÓÿÉÄÜʹÓÃÁ˻Ự¿ØÖÆ£¬¼´ÔÚÓ¦ÓõIJãÃæ¿ØÖÆÁËһЩÓû§µÄÁ¬½ÓµÄÊýÁ¿¡£µ«ÓÐʱ¿ÉÄÜÍøÂç·¢ÉúµÄ˲¶Ï£¬´Ó¶ø¾Í²úÉúÁËһЩËÀ½ø³Ì£¬ËûÃǵÄ״̬ΪInactiveµÄ״̬¡£µ±ÎÒÃÇÓÃalter system kill session ¡®sid,serial#¡¯½øÐÐÇå³ýʱ£¬ÕâЩsessionµÄ״̬ÓÖ±ä³ÉÁËkilled£¬ÕâЩ¾ÍÓÉPmon½ø³ÌÀ´ÂýÂý½øÐÐÇå³ýÁË£¬¶øÄãÇ¡Ç¡ÓÖÊǸö¼±Æ¢Æø¡£

3¡¢ ϵͳºöÈ»ÂýÁËÏÖÀ´£¬Äã·¢ÏÖÊÇij¸ösessionÔÚ×ö¹Ö£¬ÏëѸËÙ°ÑËüѸËÙ½áÊøµô¡£

¶þ¡¢´¦Àí·½·¨ Æäʵ´¦Àí·½·¨ºÜ¼òµ¥£¬ÊDZ»Ò»Ð©È˳ÆΪ¡°Ä±É±¡±µÄÒ»ÖÖ·½·¨¡£ÒòΪһ¸ösession»á¶ÔÓ¦×ŲÙ×÷ϵͳÖÐÏàÓ¦µÄÒ»¸ö½ø³Ì(process)£¬ÎÒÃDz»Ê¹ÓÃAlter system kill sessionÕâÖÖ·½Ê½ÁË£¬È¡¶ø´úÖ®ÔòÊÇkillµÄ·½Ê½£¬µ±sessionµÄºǫ́½ø³Ì±»É±µôÁË£¬±ã»á´ÙʹÀÁÉ¢µÄPmon½ø³ÌѸËÙ½øÐÐÇåÀí¹¤×÷¡£

1¡¢ ÒÔÒ»¸ösession×öÒÔʾÀý£¬

a¡¢ ÕÒµ½ÄãҪɱµôµÄÄǸösession, ²¢¼ÇÏÂpaddr

b¡¢ ÕÒµ½Õâ¸ösessionËù¶ÔÓ¦µÄspid

c¡¢ ɱµôspidËù±êʶµÄÄǸö½ø³Ì
Èç¹ûÄãµÄOracleÊÇÔÚUnixƽ̨Éϵģ¬¿ÉÒÔÓÃkill¡£

$kill 13824
Èç¹ûÄãµÄOracleÊÇÔÚwindownƽ̨Éϵģ¬ÓÐһЩµÄ²»Í¬£¬ÒòΪwindownÊÇÒÔtheadÀ´´úÌæprocessµÄ£¬ÐèÒªÓõ½sidºÍspidÁ½¸öÖµ£¬ËùÓõÄÃüÁîÒ²ÓÉkillÌ滻ΪOrakill,¸ñʽΪ:orakill sid spid

C:>orakill 941¡¡13824

d¡¢ ÔÙ²éÒ»ÏÂv$session,¿´»á»°ÔÚ²»ÔÚÁË¡£

2¡¢ ÈçºÎıɱµôËùÓеÄOracleµÄÓû§µÄ½ø³ÌÄØ£¿

a¡¢ windowsµÄ»·¾³,Ö´ÐÐÈçÏÂͼÖеÄSQL,²¢°Ñ½á¹û´æ³É.batµÄÎļþ£¬±ÈÈçkill.bat, Ö´ÐÐÒ»ÏÂkill.bat¾Í¿ÉÒÔÁË¡£

b¡¢ UnixµÄ»·¾³Ïà¶ÔÀ´Ëµ¾Í¼òµ¥¶àÁË£¬Ö´ÐÐÈçϵÄÃüÁî¾Í¿ÉÒÔÁË

$ ps -ef|grep $ORACLE_SID|grep -v ora_|grep LOCAL=NO|awk '{print $2}'|xargs kill
È»ºóÄãÔÙshutdown immediate¾ÍºÜ¿ìµÄÁË¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ