ÓÐЩʱºî£¬ÎÒµ±È»Ö¸µÄÊǷdz£ÉÙµÄÇé¿öÏ£¬ÎÒÃÇ»á¸Ð¾õÎÒÃǵĿ⡱Hang¡±ÁË£¬¼ÓÁËÒþºÅµÄÒâ˼ÊÇ˵ÓÐʱÕæµÄÊÇHangÁË£¬ÓÐһЩÔò²»ÊÇ£¬ÊÇÓÉÓÚÐÔÄܵÄÎÊÌâÒýÆðµÄ¡£ÎÒÓöµ½¹ý¼¸´ÎHangµÄÇé¿ö£¬½áºÏ×ÅÍøÉÏһЩÎÄÕ£¬°Ñ¿ÉÄܵÄÔÒò¡¢µ±Ê±ÎÒÃÇÓ¦¸Ã×öµÄһЩ²Ù×÷½øÐÐÁËÈçϵÄ×ܽᣬ²»¶ÔµÄµØ·½´ó¼Ò¿ÉÒÔ·¢Mail¸øÎÒ:qiuyb@21cn.com¡£
Ò»¡¢Êý¾Ý¿âHangʱ¿ÉÄܵÄÏÖÏó
1¡¢×îÖ±¹ÛµÄÊÇÄãµÄ´ó²¿·ÖµÄÒµÎñ²Ù×÷£¬±ÈÈç˵һ¸ö²éѯ¶¼Ê¹Óúó¤µÄʱ¼ä£¬»ò¸ù±¾¾Í·µ»Ø²»³ö½á¹û¡£ÕâºÍ¼òµ¥ÄÇÖÖËø±íÊÇÓÐÇø±ðµÄ¡£
2¡¢ÔÚ²Ù×÷ϵͳÉÏÓ**p-unixÓÃglance¡¢AixÓÃnmon¼°ÓÃsar×ö¼à²â»á³öÏÖϵͳ¿ÕÏеļÙÏ󣬱íÃæ¿´ÆðÀ´ÏµÍ³ºÜÏУ¬Êµ¼ÊÉÏϵͳÒѾHangÁË¡£
3¡¢²év$session_wait»á³öÏÖ´óÁ¿µÄ¡±latch free¡±¡¢¡±enqueue¡±¡¢¡± free buffer waits¡±µÈµÈ´ýʼþ£¬ÓÐʱºǫ́»á³öÏÖ´óÁ¿µÄ.trcÎļþ£¬ÁíÍâÐèÒª¹Û×¢Ò»ÏÂ$ORACLE_HOME/rdbms/logÕâ¸öλÖã¬ÓÐһЩʱºîtraceÎļþ»áÉú³Éµ½ÕâÀï¡£
¶þ¡¢Oracle¿âHangʱһЩÓÐÓõIJÙ×÷ºÍ²éѯ
1¡¢Èç¹ûҪѰÇóOracleµÄ¼¼ÊõÖ§³Ö£¬ÎÒÃÇÐèÒªdumpÒ»ÏÂOracleµÄsystemstate£¬²Ù×÷ÈçÏ SQL>conn / as sysdba; SQL> alter session set events 'immediate trace name SYSTEMSTATE level 10'; ÐèÒªµÈ¼¸·ÖÖÓµÄʱ¼ä£¬ÕâʱÔÚinit<SID>.oraÖÐËùÉèÖõÄuser_dump_destËù±êʶµÄλÖþͿÉÒÔÕÒµ½Õâ¸ö.trcÎļþ£¬Ò»°ã±È½Ï´ó¡£
2¡¢²¶»ñһЩÊÓͼµÄ״ֵ̬ SQL>conn / as sysdba; SQL>set linesize 500 SQL>set pagesize 0 SQL>spool v_views.txt SQL> SELECT * FROM v$parameter; SQL>SELECT class, value, name FROM v$sysstat; SQL>SELECT sid, id1, id2, type, lmode, request FROM v$lock; SQL>SELECT l.latch#, n.name, h.pid, l.gets, l.misses, l.immediate_gets, l.immediate_misses, l.sleeps FROM v$latchname n, v$latchholder h, v$latch l WHERE l.latch# = n.latch# AND l.addr = h.laddr(+); SQL>SELECT * FROM v$session_wait ORDER BY sid; --¸ô¼¸ÃëÖظ´Ö´ÐÐ3´Î¡£ SQL>spool off
3¡¢ÓÐÌõ¼þµÄ»°ÓÃstatspackÉú³ÉÁËÒ»¸öReport£¬Èç¹ûÄã¶Ôstatspach²»ÊìϤ£¬¿ÉÒÔ²ÎÕÕhttp://www.itpub.net/showthread.php?s=&threadid=144448Õâ¸öÁ´½Ó¡£
Èý¡¢²úÉúHang¿ÉÄܵļ¸¸öÔÒò
1¡¢¿ª¹éµµµÄÇé¿öÏ£¬¹éµµÎ»ÖÃËùÔÚµÄÎļþϵͳÂúÁË£¬Õâʱlgwr¾Í»áµÈ´ý¹éµµ½ø³ÌµÄÍê³É£¬DMLд²»ÁËÈÕÖ¾£¬¶¼´¦ÓڵȴýµÄ״̬¡£
2¡¢ÔÚHPµÄϵͳ¿ªÒì²½Ioʱ£¬Ã»ÎªdbaµÄ×éÉèÖÃMLOCKȨÏÞ¡£Õý³£À´ËµOracleµÄÆô¶¯Êǻᱨ´íµÄ£¬¿ÉÊÇÓÐЩʱºî±ÈÈçOracle8.1.6µÄ°æ±¾¾Í²»±¨´íÆô¶¯£¬µ«ÊÇ´ËʱµÄÒì²½IoÊÇÓÐÎÊÌâµÄ£¬×Ðϸ²é¿´Äã»áÔÚ$ORACLE_HOME/rdbms/log¿´µ½´óÁ¿µÄ.trcÎļþ¡£ÕâÖÖÇéÐÎÒýµÄHangÎÒÓöµ½¹ý¡£
3¡¢ÓÉÓÚÒì³£½ø³ÌÒýÆðµÄ£¬ÎÒËù˵µÄÊÇÄÇЩռÓÃϵͳ×ÊÔ´(cpu,memory)Ìرð´óµÄ½ø³Ì£¬ÕâЩ½ø³ÌÒ»°ãÕ¼ÓÃcpu»á´ïµ½90%ÒÔÉÏ£¬Ïà¶ÔÆäËüµÄ½ø³Ì±È½ÏÍ»³ö¡£¿ÉÒÔͨ¹ýhp-unixµÄglance¡¢topas£¬IBMµÄnmod,topas,psµÈ¹¤¾ß½øÐмà²â¡£
4¡¢ÓÉÓÚÖ÷»úϵͳ¡¢ÕóÁеÄij·½ÃæµÄÆ¿¾±ÒýÆðµÄ£¬ÔÚʵ¼ÊÖÐ×îÆÕ±éµÄÓ¦¸ÃÊÇIoµÄÎÊÌ⣬±ÈÈçIO·½ÃæÓÐÆ¿¾±£¬Ôòdbwr¡¢lgwr¾Í»áÒý¡± free buffer waits¡±¡¢¡± log buffer space¡±µÈһϵÁеĵȴýʼþ£¬´ËʱÊÇÐÔÄܵÄÎÊÌ⣬¸Ð¾õÆðÀ´ÏñHang¡£
5¡¢Ò²ÓÐbugµÄÒòËØ£¬ÎҵĿⶼÊÇ×îеIJ¹¶¡£¬Õâ·½ÃæµÄÎÊÌ⻹ûÓöµ½¹ý¡£
ËÄ¡¢¼¸µã´¦Àí½¨Òé µ±µÃµ½OracleµÄ¿âÆæÂý»òHangʱ±£³ÖÀä¾²µÄÍ·ÄÔºÜÖØÒªµÄ£¬¿ÉÒÔ°´Èçϵķ½·¨½øÐÐһЩ´¦Àí£º
1¡¢Ê×ÏÈÒªµ½²Ù×÷ϵͳÉÏÈ¥£¬ÓÃglanceµÈ¹¤¾ß½øÐÐһϹ۲죬¿´Ò»ÏÂcpu¡¢ÄÚ´æ¡¢½»»»Çø¡¢´ÅÅ̵ķ±Ã¦³Ì¶ÈÓëƽʱÊDz»ÊÇÏàËƵģ¬Í¬Ê±¿´Ò»¿´ÓÐûÓÐռϵͳ×ÊÔ´Ìرð´óµÄ½ø³Ì£¬ÓÐЩʱºîÊÇÕâЩ½ø³ÌÒýÆðµÄ£¬Í¨¹ýv$processºÍv$sessionÁ½¸öÊÓͼÕÒµ½ÕâOracle½ø³ÌµÄsid,serial#,°ÑËüÓÃAlter system kill session ¡®sid,serial#¡¯;ɱµô¾ÍÐÐÁË¡£Èç¹ûƽʱͬÑùµÄʱ¶ÎÄãµÄ´ÅÅ̵ķ±Ã¦³Ì¶ÈÊÇ95%£¬¶øЩʱËüΪ20%£¬µ±È»ÊǼÙÉèÁË£¬ËµÃ÷OracleµÄ¿âû׼ÕæµÄhangÁË¡£
2¡¢Ê±¼äÀ´µÃ¼°µÄ»°Ö´ÐÐһϡ±¶þ¡±ÖеÄÓï¾äÊǺܱØÒªµÄ£¬ÕâÑù¿ÉÒÔ°ÑÕâЩÐÅÏ¢Ìá½»¸øOracleµÄsupporter£¬ÈÃÄãÃǸøÄã·ÖÎöһϣ¬²éÒ»ÏÂÔÒò¡£
3¡¢Èç¹ûÄãµÄ¿â¿ª¹éµµÁË£¬³öÏÖHangµÄʱºîÒ»¶¨Òª¿´Ò»Ï¹鵵ÈÕÖ¾µÄÎļþϵͳÊDz»ÊÇÂúÁË£¬×öÒ»¸öÍ걸һЩµÄÍø¹ÜϵͳÊǺܱØÒªµÄ¡£
4¡¢ÔÚHPϵͳÉÏ´ò¿ªÒì²½IOʱһ¶¨²»ÒªÍü¼ÇΪdbaÕâ¸ö×é¼ÓÉÏMLOCKµÄȨÏÞ£¬ÎҾͳԹýÕâ¸ö¿÷¡£
5¡¢Ê±³£µÄ¹Û×¢Ò»ÏÂv$session_wait»òÓÃstatspack½øÐйÛעһϵȴýʼþ£¬Ò»°ãIOÏà¹ØµÄʼþ½Ï¶à£¬ÎªOracle´ò¿ªÒì²½IO¡¢¶à¼Ó¼¸¸öд½ø³Ì¼°ÎªOracleÊý¾ÝÎļþËùÓõÄraw deviceʹÓÃÌõ´ø¶¼ÊǺܱØÒªµÄ¡£ÓëÓ¦ÓõĿª·¢É̽»Á÷Ò²ºÜÖØÒª£¬Ã»×¼×î½üÐÂÉϵÄÒ»¸öÓ¦ÓþÍÌغÄIO»òÌØÕ¼CPU×ÊÔ´¡£
6¡¢¾¡Á¿ÒªÊ¹ÓñȽÏÎȶ¨µÄOracleµÄ°æ±¾,±ÈÈçOracle8.1.7.4¼°Oracel9.2.0.4(×îÐÂΪ 9.2.0.5)¶¼ºÜÎȶ¨µÄ£¬¿ÉÒÔÉÙÈ¥ºÃ¶àµÄÂé·³¡£
|