TOMSYAN 发表于 2011-12-23 03:05

How to Check if Dead Connection Detection (DCD)

<DIV>
<TABLE cellSpacing=6 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top align=left colSpan=6><STRONG>How to Check if Dead Connection Detection (DCD) is Enabled in 9i ,10g and 11g </STRONG></TD></TR>
<TR>
<TD vAlign=top align=left colSpan=6></TD></TR>
<TR>
<TD vAlign=top width="25%" colSpan=2>&nbsp;</TD>
<TD vAlign=top noWrap width="50%" colSpan=3><EM>修改时间</EM> 23-FEB-2011&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<EM>类型</EM> HOWTO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<EM>状态</EM> PUBLISHED</TD>
<TD vAlign=top>&nbsp;</TD></TR></TBODY></TABLE>
<P><B>In this Document</B><BR><FONT size=-1>&nbsp;&nbsp;<A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=395505.1#GOAL" target=_blank>Goal</A><BR>&nbsp;&nbsp;<A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=395505.1#FIX" target=_blank>Solution</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=395505.1#aref1" target=_blank>Scenario</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=395505.1#aref2" target=_blank>Methods to&nbsp;check DCD functionality:&nbsp;</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=395505.1#aref3" target=_blank>(1) Oracle Sqlnet Client Trace </A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=395505.1#aref4" target=_blank>(2) Oracle Sqlnet Server Trace</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=395505.1#aref5" target=_blank>(3) Sniffer Trace</A><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=395505.1#aref6" target=_blank>(4) Strace or System level trace </A><BR>&nbsp;&nbsp;<A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=395505.1#REF" target=_blank>References</A><BR></FONT>
<P>
<P>Applies to: Oracle Net Services - Version: 9.2.0.4.0 to 11.2.0.2 - Release: 9.2 to 11.2<BR>Information in this document applies to any platform.<BR>Checked for relevance on 9-APR-2010. <A name=GOAL></A>GoalYou have enabled Dead Connection Detection (DCD) in the SQLNET.ORA file on the <BR>database server which is of version 9i or 10g&nbsp;and you wish to verify whether it is working. <BR><A name=FIX></A>Solution
<P>We could verify whether DCD is enabled or not by any one of the following mechanism</P>
<P class=km>(1)&nbsp;Oracle Sqlnet&nbsp;Client Trace<BR>&nbsp;&nbsp;&nbsp;&nbsp; (1.a) Using Pre-9.2.0.4 Oracle clients<BR>&nbsp;&nbsp;&nbsp;&nbsp; (1.b) Using Oracle Clients version &gt; 9.2.0.4<BR><BR>(2) Oracle Sqlnet Server Trace<BR><BR>(3) Sniffer Trace<BR><BR>(4) Strace or System level trace</P><A name=aref1></A><BR><BR>Scenario
<P>You have set the SQLNET.EXPIRE_TIME = x (minutes) in the server sqlnet.ora </P>
<P><STRONG>How Dead Connection Detection is Triggered</STRONG></P>
<P>Let us take an example. Suppose we set the sqlnet.expire_time = 2 and the timer got armed at 10.00 am, <BR>then the DCD packets will be sent only if there is no network(I/O) activity for that connection in the next 2 min. i.e. till 10.02 am. <BR><BR>If there is an i/o in between 10 to 10.02 then the connection is not dead one as the activity took place on that particular connection, which means the connection is alive and hence the DCD packets will not be sent for this period of time. <BR>So, at any point of time, the DCD packets will only be sent if there is no activity for the full span of specified time interval. <BR><BR>As the first connection operation itself considered a successul I/O, the first DCD probe packet would go only after 2 * expire_time and successive one's would be sent every expiry_time provided no activity in that next span too.</P><A name=aref2></A>Methods to&nbsp;check DCD functionality:&nbsp;<BR><A name=aref3></A>(1) Oracle Sqlnet Client Trace
<P>Enable the client tracing at support level with following parameters in the client side sqlnet.ora</P>
<DIV class=kmcodeblock style="WIDTH: 95%">TRACE_LEVEL_CLIENT = 16 <BR>TRACE_FILE_CLIENT = CLIENT <BR>TRACE_DIRECTORY_CLIENT= &lt;oracle_home&gt;/network/trace <BR>TRACE_TIMESTAMP_ CLIENT = ON <BR>TRACE_UNIQUE_CLIENT = ON</DIV>
<P>Leave the session on the client idle for atlest for x*2 minutes(twice of 'x' minutes)&nbsp; <BR>ie, if x=2 in the server sqlnet.ora, then leave the client connection idle for atleast 4 minutes.<BR>At this time, if you check the client trace, the client will be on <EM>nioqrc: exit</EM>. <BR></P>
<P>The reason for the (2 * expire time) set initially that is for the first probe is due to the above logic on how DCD works that is DCD probe packets will be sent only if there is no activity for full span of specified time interval.&nbsp;<BR><BR>&nbsp;&nbsp; <STRONG>(1.a) Using Pre-9.2.0.4 Oracle clients</STRONG> <BR><BR>For pre-9.2.0.4 oracle clients you can actually see the null packet of 10 bytes been recieved every x minutes after this period.</P>
<DIV class=kmcodeblock style="WIDTH: 95%">nsprecv:&nbsp;10&nbsp;bytes&nbsp;from&nbsp;transport&nbsp; <BR>nsprecv:&nbsp;tlen=10,&nbsp;plen=10,&nbsp;type=6&nbsp; <BR>nsprecv:&nbsp;packet&nbsp;dump&nbsp; <BR>nsprecv:&nbsp;00&nbsp;0A&nbsp;00&nbsp;00&nbsp;06&nbsp;00&nbsp;00&nbsp;00&nbsp;|........|&nbsp; <BR>nsprecv:&nbsp;00&nbsp;00&nbsp;|..&nbsp;| <BR>nsprecv:&nbsp;normal&nbsp;exit&nbsp; <BR>nsrdr:&nbsp;got&nbsp;NSPTDA&nbsp;packet&nbsp; <BR>nsrdr:&nbsp;NSPTDA&nbsp;flags:&nbsp;0x0&nbsp; <BR>nsrdr:&nbsp;normal&nbsp;exit&nbsp; <BR>nsdo:&nbsp;got&nbsp;"null"&nbsp;packet&nbsp;==&gt;&nbsp;Got&nbsp;Null&nbsp;packet&nbsp;here <BR></DIV>
<P><BR>&nbsp;<STRONG> (1.b) Using Oracle Clients version &gt; 9.2.0.4</STRONG> <BR><BR>After the idle time greater than x*2 minutes(here 4 minutes), execute any &nbsp;query, like <EM>'select * from dual';</EM> You will see in the client trace following information after the query is sent to server<BR>Here for example the query was executed after 8 minutes of idle time</P>
<DIV class=kmcodeblock style="WIDTH: 95%">..14:52:04:734]&nbsp;nioqrc:&nbsp;exit <BR>..15:01:51:546]&nbsp;nioqsn:&nbsp;entry<BR>...<BR>nsprecv: 30 bytes from transport <BR>nsprecv: tlen=30, plen=10, type=6 <BR>nsprecv: 20 bytes to leftover <BR>nsprecv: packet dump <BR>nsprecv: 00 0A 00 00 06 00 00 00 |........| <BR>nsprecv: 00 00 |.. | <BR>nsprecv: normal exit <BR>nsrdr: got NSPTDA packet <BR>nsrdr: NSPTDA flags: 0x0 <BR>nsrdr: normal exit <BR>nsdo: got "null" packet <BR>nsrdr: entry <BR>nsrdr: recving a packet <BR>nsprecv: entry <BR>nsprecv: 20 bytes from leftover <BR>nsprecv: tlen=20, plen=10, type=6 <BR>nsprecv: 10 bytes to leftover <BR>nsprecv: packet dump <BR>nsprecv: 00 0A 00 00 06 00 00 00 |........| <BR>nsprecv: 00 00 |.. | <BR>nsprecv: normal exit <BR>nsrdr: got NSPTDA packet <BR>nsrdr: NSPTDA flags: 0x0 <BR>nsrdr: normal exit <BR>nsdo: got "null" packet <BR>nsrdr: entry <BR>nsrdr: recving a packet <BR>nsprecv: entry <BR>nsprecv: 10 bytes from leftover <BR>nsprecv: tlen=10, plen=10, type=6 <BR>nsprecv: packet dump&nbsp;<BR>nsprecv: 00 0A 00 00 06 00 00 00 |........|&nbsp;<BR>nsprecv: 00 00 |.. | <BR>nsprecv: normal exit <BR>nsrdr: got NSPTDA packet <BR>nsrdr: NSPTDA flags: 0x0 <BR>nsrdr: normal exit&nbsp;<BR>nsdo: got "null" packet</DIV>
<P>This confirms that the DCD packet is sent to the client from the respective database server. The null packets are actually written to the socket , but they are read only when the client becomes active.</P><A name=aref4></A>(2) Oracle Sqlnet Server Trace
<P>Enable Oracle Sqlnet server traces by appending following information to the server side sqlnet.ora<BR></P>
<DIV class=kmcodeblock style="WIDTH: 95%">TRACE_LEVEL_SERVER&nbsp;=&nbsp;16&nbsp; <BR>TRACE_FILE_SERVER&nbsp;=&nbsp;SERVER<BR>TRACE_DIRECTORY_SERVER=&nbsp;&lt;oracle_home&gt;/network/trace&nbsp; <BR>TRACE_TIMESTAMP_&nbsp;SERVER&nbsp;=&nbsp;ON&nbsp; <BR>TRACE_UNIQUE_SERVER&nbsp;=&nbsp;ON</DIV>
<P>Make a client connection to the server and track the server trace which was generated for the client by looking in to the trace directory. Leave the client session idle atleast for x*2 minutes<BR><BR>At the start of the trace we can notice whether DCD is enabled or not for the process by<BR></P>
<DIV class=kmcodeblock style="WIDTH: 95%">niotns: Enabling dead connection detection (2 min) //shows dcd enabled&nbsp;2min</DIV>
<DIV class=kmcodeblock style="WIDTH: 95%">niotns: Not enabling dead connection detection.&nbsp;&nbsp; // shows dcd is not enabled</DIV>
<P><BR>After the recieve <EM>NSPTAC packet </EM>(accept) , you could see the timer being initialised if DCD is enabled</P>
<DIV class=kmcodeblock style="WIDTH: 95%">nstimini: initializing LTM in asynchronous mode <BR>nstimini: normal exit <BR>nstimstart: entry <BR>nstimstart: starting timer at &lt;**timestamp**&gt;<BR>nstimset: entry <BR>nstimset: normal exit <BR>nstimstart: normal exit <BR>nsconbrok: timer created for connection</DIV>
<P><BR>At the close of the connection <BR><BR></P>
<DIV class=kmcodeblock style="WIDTH: 95%">nstimarmed:&nbsp;entry&nbsp; <BR>nstimarmed:&nbsp;no&nbsp;timer&nbsp;allocated&nbsp;//&nbsp;no&nbsp;dcd&nbsp;is&nbsp;enabled <BR>nstimarmed:&nbsp;normal&nbsp;exit <BR></DIV>
<P>&nbsp;</P>
<DIV class=kmcodeblock style="WIDTH: 95%">nsclose:&nbsp;entry&nbsp; <BR>nstimarmed:&nbsp;entry&nbsp; <BR>nstimarmed:&nbsp;timer&nbsp;is&nbsp;armed,&nbsp;with&nbsp;value&nbsp;//indicates&nbsp;DCD&nbsp;was&nbsp;enabled <BR>nstimarmed:&nbsp;normal&nbsp;exit&nbsp; <BR>nstimclear:&nbsp;entry&nbsp; <BR>nstimclear:&nbsp;normal&nbsp;exit</DIV>
<P>&nbsp;</P><A name=aref5></A>(3) Sniffer Trace
<P>Enable Sniffer trace with help of Ethreal / wireshark tools and capture the events on client side.<BR>After narrowing the communication of the oracle client in picture and server process you could actually see that 10 bytes of null packet is been sent as TNS and TCP ack is recieved. <BR></P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>This confirms DCD packet is recieved by the client.</P><A name=aref6></A>(4) Strace or System level trace <BR>
<P><BR>You could check whether DCD is enabled or not by tracing the oracle server process with OS tracing.<BR>For example strace on oracle server process in linux platform will reveal whether dcd is enabled or not.<BR>Refer the below note for more details<BR><A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;id=438923.1" target=_blank>Note 438923.1</A> How To Track Dead Connection Detection(DCD) Mechanism Without Enabling Any Client/Server Network Tracing </P><A name=REF></A>References<A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=BUG&amp;id=5475041" target=_blank>BUG:5475041</A> - PROBE PACKETS ARE NOT SENT IF SQLNET.EXPIRE_TIME IS GREATER THAN 1<BR><A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=BUG&amp;id=5573896" target=_blank>BUG:5573896</A> - DCD IS NOT WORKING IF SET MORE THAN 1 MINUTE<BR><A href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=BUG&amp;id=3588399" target=_blank>BUG:3588399</A> - SQLNET.EXPIRE_TIME IS DOUBLED ON FIRST PASS THRU<BR></DIV>
页: [1]
查看完整版本: How to Check if Dead Connection Detection (DCD)