[SQL Server2005]SQL ServerËÀËø×ܽá(ת)
1. ËÀËøÔÀí
¸ù¾Ý²Ù×÷ϵͳÖеĶ¨Ò壺ËÀËøÊÇÖ¸ÔÚÒ»×é½ø³ÌÖеĸ÷¸ö½ø³Ì¾ùÕ¼Óв»»áÊͷŵÄ×ÊÔ´£¬µ«Òò»¥ÏàÉêÇë±»ÆäËû½ø³ÌËùÕ¾Óò»»áÊͷŵÄ×ÊÔ´¶ø´¦ÓÚµÄÒ»ÖÖÓÀ¾ÃµÈ´ý״̬¡£
ËÀËøµÄËĸö±ØÒªÌõ¼þ£º
»¥³âÌõ¼þ(Mutual exclusion)£º×ÊÔ´²»Äܱ»¹²Ïí£¬Ö»ÄÜÓÉÒ»¸ö½ø³ÌʹÓá£
ÇëÇóÓë±£³ÖÌõ¼þ(Hold and wait)£ºÒѾµÃµ½×ÊÔ´µÄ½ø³Ì¿ÉÒÔÔÙ´ÎÉêÇëеÄ×ÊÔ´¡£
·Ç°þ¶áÌõ¼þ(No pre-emption)£ºÒѾ·ÖÅäµÄ×ÊÔ´²»ÄÜ´ÓÏàÓ¦µÄ½ø³ÌÖб»Ç¿ÖƵذþ¶á¡£
Ñ»·µÈ´ýÌõ¼þ(Circular wait)£ºÏµÍ³ÖÐÈô¸É½ø³Ì×é³É»·Â·£¬¸Ã»·Â·ÖÐÿ¸ö½ø³Ì¶¼ÔڵȴýÏàÁÚ½ø³ÌÕýÕ¼ÓõÄ×ÊÔ´¡£
¶ÔÓ¦µ½SQL ServerÖУ¬µ±ÔÚÁ½¸ö»ò¶à¸öÈÎÎñÖУ¬Èç¹ûÿ¸öÈÎÎñËø¶¨ÁËÆäËûÈÎÎñÊÔͼËø¶¨µÄ×ÊÔ´£¬´Ëʱ»áÔì³ÉÕâЩÈÎÎñÓÀ¾Ã×èÈû£¬´Ó¶ø³öÏÖËÀËø£»ÕâЩ×ÊÔ´¿ÉÄÜÊÇ£ºµ¥ÐÐ(RID£¬¶ÑÖеĵ¥ÐÐ)¡¢Ë÷ÒýÖеļü(KEY£¬ÐÐËø)¡¢Ò³(PAG£¬8KB)¡¢Çø½á¹¹(EXT£¬Á¬ÐøµÄ8Ò³)¡¢¶Ñ»òBÊ÷(HOBT) ¡¢±í(TAB£¬°üÀ¨Êý¾ÝºÍË÷Òý)¡¢Îļþ(File£¬Êý¾Ý¿âÎļþ)¡¢Ó¦ÓóÌÐòרÓÃ×ÊÔ´(APP)¡¢ÔªÊý¾Ý(METADATA)¡¢·ÖÅäµ¥Ôª(Allocation_Unit)¡¢Õû¸öÊý¾Ý¿â(DB)¡£Ò»¸öËÀËøʾÀýÈçÏÂͼËùʾ£º
˵Ã÷£ºT1¡¢T2±íʾÁ½¸öÈÎÎñ£»R1ºÍR2±íʾÁ½¸ö×ÊÔ´£»ÓÉ×ÊÔ´Ö¸ÏòÈÎÎñµÄ¼ýÍ·(ÈçR1->T1£¬R2->T2)±íʾ¸Ã×ÊÔ´±»¸ÄÈÎÎñËù³ÖÓУ»ÓÉÈÎÎñÖ¸Ïò×ÊÔ´µÄ¼ýÍ·(ÈçT1->S2£¬T2->S1)±íʾ¸ÃÈÎÎñÕýÔÚÇëÇó¶ÔӦĿ±ê×ÊÔ´£»
ÆäÂú×ãÉÏÃæËÀËøµÄËĸö±ØÒªÌõ¼þ£º
(1).»¥³â£º×ÊÔ´S1ºÍS2²»Äܱ»¹²Ïí£¬Í¬Ò»Ê±¼äÖ»ÄÜÓÉÒ»¸öÈÎÎñʹÓã»
(2).ÇëÇóÓë±£³ÖÌõ¼þ£ºT1³ÖÓÐS1µÄͬʱ£¬ÇëÇóS2£»T2³ÖÓÐS2µÄͬʱÇëÇóS1£»
(3).·Ç°þ¶áÌõ¼þ£ºT1ÎÞ·¨´ÓT2ÉÏ°þ¶áS2£¬T2Ò²ÎÞ·¨´ÓT1ÉÏ°þ¶áS1£»
(4).Ñ»·µÈ´ýÌõ¼þ£ºÉÏͼÖеļýÍ·¹¹³É»·Â·£¬´æÔÚÑ»·µÈ´ý¡£
2. ËÀËøÅŲé
(1). ʹÓÃSQL ServerµÄϵͳ´æ´¢¹ý³Ìsp_whoºÍsp_lock£¬¿ÉÒԲ鿴µ±Ç°Êý¾Ý¿âÖеÄËøÇé¿ö£»½ø¶ø¸ù¾ÝobjectID(@objID)(SQL Server 2005)/ object_name(@objID)(Sql Server 2000)¿ÉÒԲ鿴Äĸö×ÊÔ´±»Ëø£¬ÓÃdbcc ld(@blk)£¬¿ÉÒԲ鿴×îºóÒ»Ìõ·¢Éú¸øSQL ServerµÄSqlÓï¾ä£»
(2). ʹÓà SQL Server Profiler ·ÖÎöËÀËø: ½« Deadlock graph ʼþÀàÌí¼Óµ½¸ú×Ù¡£´ËʼþÀàʹÓÃËÀËøÉæ¼°µ½µÄ½ø³ÌºÍ¶ÔÏóµÄ XML Êý¾ÝÌî³ä¸ú×ÙÖÐµÄ TextData Êý¾ÝÁС£SQL Server ʼþ̽²éÆ÷ ¿ÉÒÔ½« XML ÎĵµÌáÈ¡µ½ËÀËø XML (.xdl) ÎļþÖУ¬ÒÔºó¿ÉÔÚ SQL Server Management Studio Öв鿴¸ÃÎļþ¡
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
http://technet.microsoft.com/zh-cn/magazine/2008.04.blocking.aspx
SQL Server
×î´ó³Ì¶È½µµÍ SQL Server ÖеÄ×èÈû
Cherié Warren
¸ÅÀÀ:
·¢ÉúËøÉý¼¶µÄÔÒò
±ÜÃâ²»±ØÒªµÄ×èÈû
ÓÅ»¯²éѯ
¼àÊÓËø¶¨¶ÔÐÔÄܵÄÓ°Ïì
Ëø¶¨¶ÔÖ§³ÖÊý¾Ý¿âµÄ²¢·¢¶Áд»î¶¯¶øÑÔÊDZØÐèµÄ£¬µ«×èÈûÈ´»á¶ÔϵͳÐÔÄܲúÉú¸ºÃæÓ°Ï죬 ......
¶¨Ò壺ºÎΪ´¥·¢Æ÷£¿ÔÚSQL ServerÀïÃæÒ²¾ÍÊǶÔijһ¸ö±íµÄÒ»¶¨µÄ²Ù×÷£¬´¥·¢Ä³ÖÖÌõ¼þ£¬´Ó¶øÖ´ÐеÄÒ»¶Î³ÌÐò¡£´¥·¢Æ÷ÊÇÒ»¸öÌØÊâµÄ´æ´¢¹ý³Ì¡£
³£¼ûµÄ´¥·¢Æ÷ÓÐÈýÖÖ£º·Ö±ðÓ¦ÓÃÓÚInsert , Update , Delete ʼþ¡£
ÎÒΪʲôҪʹÓô¥·¢Æ÷£¿±ÈÈ磬ÕâôÁ½¸ö±í£º
&n ......
ͨ¹ý“Ìí¼Óɾ³ý³ÌÐò”Àï²¢²»ÄÜÍêȫɾ³ýSQlL server¡£
ͨ¹ýÏÂÃæµÄÃüÁÍêÈ«·´°²×°SQL server 2005
d:\Setup.exe
/
qb REMOVE
=ALL
INSTANCENAME
=<
InstanceName
>
ĬÈÏʵÀýµÄÃû×ÖÊÇMSSQLSERVER
ÒýÓÃÎÄÕµØÖ·£ºhttp://www.cnblogs.com/jvstudio/archive/2010/01/17/1650089.ht ......
¾ßÌå²½Ö裺
¡¡¡¡Ò».ÔÚ·þÎñÆ÷¶ËÒÔ
dbsrv7.exe pathyyy.db -n
ServiceName -x tcpip -q
¡¡¡¡Æô¶¯Êý¾Ý¿â£¬ÕâÀïÒ²¿ÉÒÔÖ¸¶¨¶Ë¿Ú£¬ÏêϸµÄ²ÎÊýÇëÓÃdbsrv7.exe /?»ñÈ¡¡£
¡¡¡¡-n servicename:Æô¶¯·þÎñÃûΪservicenameµÄÊý¾Ý¿â·þÎñÓÃÒÔ±ê¼ÇÍøÂçÊý¾Ý¿â·þÎñΨһ±ê¼Ç£»
¡¡¡¡-x tcpip£ºÊ¹ÓÃtcp/ipÐÒ飬ĬÈ϶˿Ú3362,×¢Òâ²»Òª± ......