Windows 2012 R2訪問數據庫緩慢(Windows 也適用)(局域網)


解決辦法

前段時間公司新采購了一台ibm的服務器,裝的是 windows server 2012R2, 在做完項目遷移后,發現項目訪問數據庫緩慢,於是逐項查找原因,最后終於找到解決辦法

Administrator權限執行命令行(開始菜單中右鍵點擊命令行程序,右鍵菜單中有以管理員身份執行的選型),並在命令行中執行一下命令(關閉自動調節)

netsh interface tcp set global autotuninglevel=disabled

譯文:

NETSH接口TCP設置全局自動轉換級別=禁用

 

 

打開自動調節的命令是:

  netsh interface tcp set global autotuninglevel=normal

問題原因

原因在於從vista開始,微軟在TCP/IP協議棧里新加了一個叫做“Window Auto-Tuning”的功能。這個功能本身的目的是為了讓操作系統根據網絡的實時性能(比如響應時間)來動態調整網絡上傳輸的數據窗口的大小,從而達到實時優化網絡性能的目的。但是,在某種情況下(具體是怎樣的一個環境,目前我也不清楚),這個功能反而會使遠程桌面的響應變的非常的慢。
通過把autotuninglevel設置成disabled,就可以讓數據窗口保持默認值。如果設置成highlyrestriected的話,那么就是非常保守地來調整這個數據窗口大小(不到萬不得已,還是使用默認值)。
設置命令如下:
netsh interface tcp set global autotuninglevel=disabled (或者highlyrestricted)。

 

補充內容:(可選擇性閱讀)

理解:http://www.askmaclean.com/archives/how-to-disable-windows-tcpip-auto-tuning.html

Windows上如何禁用TCP/IP自動調優特性

2012/01/05 BY MACLEAN LIU LEAVE A COMMENT

 

 

 

之前有網友在t.askmaclean.com提問版上提問關於遠程PL/SQL Developer連接Oracle數據庫發現查詢v$sessionhang住的問題,而本地連接(local connection)則可以正常查詢。

 

分析了問題相關的10046 traceMOS上的一些案例發現可能是由Bug 9087501: SELECT FROM V$SESSION AND SOME OTHER DICTIONARY VIEWS HANG FROM A REMOTE CLIENT      所引起, 該Bug Note 還指出在Windows Vista上存在因為操作系統默認啟用了TCP/IP Auto-tuning(TCP Window Scaling)從而可能導致使用如PL/SQL Developer這樣的客戶端登錄數據庫后某些查詢Hang住的問題。 而在其他Windows版本中(Win 7)沒有默認啟用該TCP/IP Auto-tuning特性,所以默認不存在該問題; 看起來Vista還真是一個失敗的作品。

 

TCP Window Scaling(接收窗口自動調諧級別)用以優化TCP網絡的吞吐量,更多信息參考一下文本:

 

TCP Window Scaling
For larger window sizes to accommodate high-speed transmission paths, RFC 1323 (ietf.org/rfc/rfc1323.txt) defines window scaling that allows a receiver to advertise a window size larger than 65,535 bytes. A TCP Window Scale option includes a window scaling factor that, when combined with the 16-bit Window field in the TCP header, can increase the receive window size to a maximum of approximately 1GB. The Window Scale option is sent only in synchronize (SYN) segments during the connection establishment process. Both TCP peers can indicate different window scaling factors to use for their receive window sizes. By allowing a sender to send more data on a connection, TCP window scaling allows TCP nodes to better utilize some types of transmission paths with high BDPs.
Although the receive window size is important for TCP throughput, another important factor for determining the optimal TCP throughput is how fast the application retrieves the accumulated data in the receive window (the application retrieve rate). If the application does not retrieve the data, the receive window can begin to fill, causing the receiver to advertise a smaller current window size. In the extreme case, the entire maximum receive window is filled, causing the receiver to advertise a window size of 0 bytes. In this case, the sender must stop sending data until the receive window has been cleared. Therefore, to optimize TCP throughput, the TCP receive window for a connection should be set to a value that reflects both the BDP of the connection’s transmission path and the application retrieve rate.
Even if you could correctly determine both the BDP and the application retrieve rate, they can change over time. The BDP rate can vary based on the congestion in the transmission path and the app retrieve rate can vary based on the number of connections on which the app is receiving data.

 

 

為了在Windows Vista上正常使用受此影響的網絡客戶端程序,我們需要手動禁用該TCP/IP Auto-tuning特性,步驟如下:

 

1. 點擊開始->ALL Programs -> Accessories(附件) -> 右鍵以管理員身份運行Command Prompt(命令提示符)

 

2.  輸入命令”netsh interface tcp show global”

C:\Windows\system32>netsh interface tcp show global
Querying active state...

TCP Global Parameters
----------------------------------------------
Receive-Side Scaling State          : enabled
Chimney Offload State               : automatic
NetDMA State                        : enabled
Direct Cache Acess (DCA)            : disabled
Receive Window Auto-Tuning Level    : normal
Add-On Congestion Control Provider  : none
ECN Capability                      : disabled
RFC 1323 Timestamps                 : disabled

若命令輸出的Receive Window Auto-Tuning Level(接收窗口自動調諧級別)值 為normal則說明系統啟用了Auto-Tuning特性。

 

3. 輸入命令netsh interface tcp set global autotuninglevel=disabled 以禁用Auto-Tuning特性:

 

C:\Windows\system32>netsh interface tcp set global autotuninglevel=disabled
Ok.

C:\Windows\system32>netsh interface tcp show global
Querying active state...

TCP Global Parameters
----------------------------------------------
Receive-Side Scaling State          : enabled
Chimney Offload State               : automatic
NetDMA State                        : enabled
Direct Cache Acess (DCA)            : disabled
Receive Window Auto-Tuning Level    : disabled
Add-On Congestion Control Provider  : none
ECN Capability                      : disabled
RFC 1323 Timestamps                 : disabled

 

4.  重啟計算機,以便設置生效(restart computer)

 

5. 如今后希望再次啟用該autotuning特性則可以在命令行中輸入”netsh interface tcp set global autotuninglevel=normal”命令,並重啟計算機

 

C:\Windows\system32>netsh interface tcp set global autotuninglevel=normal
Ok.

C:\Windows\system32>netsh interface tcp show global
Querying active state...

TCP Global Parameters
----------------------------------------------
Receive-Side Scaling State          : enabled
Chimney Offload State               : automatic
NetDMA State                        : enabled
Direct Cache Acess (DCA)            : disabled
Receive Window Auto-Tuning Level    : normal
Add-On Congestion Control Provider  : none
ECN Capability                      : disabled
RFC 1323 Timestamps                 : disabled

Reference:
http://support.microsoft.com/kb/934430
http://technet.microsoft.com/en-us/magazine/2007.01.cableguy.aspx

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM