Περιγραφή των ρυθμίσεων TCP/IP που πρέπει να προσαρμόζονται όταν απενεργοποιείται η ομαδοποίηση συνδέσεων του SQL Server

Αναγν. άρθρου: 328476 - Δείτε τα προϊόντα στα οποία αναφέρεται το συγκεκριμένο άρθρο.
Ανάπτυξη όλων | Σύμπτυξη όλων

Σε αυτήν τη σελίδα

Περίληψη

Όταν χρησιμοποιείτε το πρόγραμμα οδήγησης ODBC του διακομιστή SQL, η υπηρεσία παροχής SQL Server OLE DB ή την υπηρεσία παροχής διαχειριζόμενης System.Data.SqlClient, μπορείτε να απενεργοποιήσετε, χρησιμοποιώντας τις τις αντίστοιχες διασυνδέσεις προγραμματισμού εφαρμογών (API) για την ομαδοποίηση συνδέσεων. Όταν απενεργοποιήσετε την ομαδοποίηση, το φόρτο στον υποκείμενο βιβλιοθήκης δικτύου SQL Server μπορεί να αυξηθεί εάν η εφαρμογή σας συχνά ανοίγει και κλείνει τις συνδέσεις. Αυτό το άρθρο περιγράφει ορισμένες ρυθμίσεις TCP/IP που ίσως χρειαστεί να προσαρμόσετε αυτές τις συνθήκες.

Περισσότερες πληροφορίες

Απενεργοποίηση ομαδοποίηση μπορεί να προκαλέσει το υποκείμενο πρόγραμμα οδήγησης δικτύου του SQL Server για να ανοίξετε γρήγορα και να κλείσει τις νέες συνδέσεις υποδοχή στον υπολογιστή που εκτελεί τον SQL Server. Ίσως χρειαστεί να αλλάξετε τις προεπιλεγμένες ρυθμίσεις υποδοχών TCP/IP για το λειτουργικό σύστημα και τον υπολογιστή που εκτελεί τον SQL Server για να χειριστείτε τα υψηλότερα επίπεδα καταπόνησης.

Σημειώστε ότι αυτό το άρθρο περιγράφει μόνο τις ρυθμίσεις που επηρεάζουν τη βιβλιοθήκη δικτύου του SQL Server, όταν χρησιμοποιείτε το πρωτόκολλο TCP/IP. Απενεργοποίηση συγκέντρωση μπορούν επίσης να προκαλέσουν προβλήματα που σχετίζονται με το φόρτο, με άλλα πρωτόκολλα του SQL Server, όπως οι επώνυμες διοχετεύσεις, αλλά αυτό το άρθρο δεν περιγράφει το θέμα αυτό. Αυτό το άρθρο είναι μόνο για έμπειρους χρήστες. Εάν δεν γνωρίζετε τα θέματα σε αυτό το άρθρο, η Microsoft συνιστά να βλέπετε ένα καλό βιβλίο σχετικά με τις υποδοχές TCP/IP.

Σημειώστε ότι η Microsoft συνιστά ιδιαιτέρως ότι χρησιμοποιείτε πάντα την ομαδοποίηση με τα προγράμματα οδήγησης του SQL Server. Χρησιμοποιεί σε μεγάλο βαθμό την ομαδοποίηση βελτιώνει τις συνολικές επιδόσεις στην πλευρά προγράμματος-πελάτη και πλευρά του SQL Server όταν χρησιμοποιείτε τα προγράμματα οδήγησης του SQL Server. Using pooling also considerably reduces network traffic to the computer that is running SQL Server. For example, a sample test that used 20,000 SQL Server connection opens and closes with pooling enabled used about 160 TCP/IP network packets, for a total of 23,520 bytes of network activity. With pooling disabled, the same sample test generated 225,129 TCP/IP network packets, for a total of 27,209,622 bytes of network activity.

Note that when you see these stress-related TCP/IP socket issues with the SQL Server network libraries, you may receive one or more of the following error messages when you try to connect to a computer that is running SQL Server:
SQL Server Does Not Exist Or Access Denied
Timeout Expired
General Network Error
TCP Provider: Only one usage of each socket address (protocol/network address/port) is normally permitted.
Note that you can also receive these specific error messages when other problems are occurring with SQL Server; for example, you may receive these error messages if the remote computer that is running SQL Server is shut down, if the remote computer that is running SQL Server is not listening to TCP/IP sockets at all, if network connectivity to the computer that is running SQL Server is broken because the network cable is pulled out, or if you are having DNS resolution issues. Basically anything that can cause the client to fail to open a TCP/IP socket to the computer that is running SQL Server can also cause the error messages. However, with a stress-related socket issue, the problem occurs intermittently as the stress rises and falls. The computer may run for hours with no errors, then the error occurs one or two times, and the computer then runs for several more hours with no errors. Also, when you have this problem, general connectivity to SQL Server works one instant, fails the next, then works again the next instant. In other words, stress-related socket issues typically occur sporadically, but real network connectivity problems with SQL Server typically do not occur sporadically.

Two main stress-related issues typically occur when you disable pooling while you use the SQL Server TCP/IP protocol: You may run out of anonymous ports on the client computer, or you may exceed the defaultWinsockListenBacklogsetting on the computer that is running SQL Server.

For additional information about anonymous ports, click the article number below to view the article in the Microsoft Knowledge Base:
319502PRB: 'WSAEADDRESSINUSE' Error Message When You Try to Connect Through an Anonymous Port After You Increase the IMAP Connection Limit

Adjust the MaxUserPort and TcpTimedWaitDelay settings

Σημειώστε ότι τοMaxUserPortANDTcpTimedWaitDelaysettings are applicable only for a client computer that is rapidly opening and closing connections to a remote computer that is running SQL Server and that is not using connection pooling. For example, these settings are applicable on an Internet Information Services (IIS) server that is servicing a large number of incoming HTTP requests and that is opening and closing connections to a remote computer that is running SQL Server and that is using the TCP/IP protocol with pooling disabled. If pooling is enabled, you do not have to adjust theMaxUserPortANDTcpTimedWaitDelayρυθμίσεις.

When you use the TCP/IP protocol to open a connection to a computer that is running SQL Server, the underlying SQL Server network library opens a TCP/IP socket to the computer that is running SQL Server. When it opens this socket, the SQL Server network library does not enable theSO_REUSEADDRTCP/IP socket option. Για περισσότερες πληροφορίες σχετικά με τοSO_REUSEADDRsocket setting, see the "Setsockopt" topic in the Microsoft Developer Network (MSDN).

Note that the SQL Server network library specifically does not enable theSO_REUSEADDRTCP/IP socket option for security reasons. WhenSO_REUSEADDRis enabled, a malicious user can hijack a client port to SQL Server and use the credentials that the client supplies to gain access to the computer that is running SQL Server. By default, because the SQL Server network library does not enable theSO_REUSEADDRsocket option, every time you open and close a socket through the SQL Server network library on the client side, the socket enters a TIME_WAIT state for four minutes. If you are rapidly opening and closing SQL Server connections over TCP/IP with pooling disabled, you are rapidly opening and closing TCP/IP sockets. In other words, each SQL Server connection has one TCP/IP socket. If you rapidly open and close 4000 sockets in less than four minutes, you will reach the default maximum setting for client anonymous ports, and new socket connection attempts fail until the existing set of TIME_WAIT sockets times out.

On the client side, you may have to increase theMaxUserPortANDTcpTimedWaitDelaysettings that are discussed in Q319502 when you have pooling disabled. The settings for these values are determined by how many SQL Server connection opens and closes occur on the client side. You can examine how many client ports are in a TIME_WAIT state by using the Netstat tool on the client computer. Run the Netstat tool with the-nflag as follows, and count the number of client sockets to your SQL Server IP address that are in a TIME_WAIT state. In this example, the IP address of the remote computer that is running SQL Server is 10.10.10.20, the IP address of the client computer is 10.10.10.10, and three established connections and two connections are in a TIME_WAIT state:
C:\>netstat -n

Active Connections

  Proto  Local Address         Foreign Address       State
  TCP    10.10.10.10:2000      10.10.10.20:1433      ESTABLISHED
  TCP    10.10.10.10:2001      10.10.10.20:1433      ESTABLISHED
  TCP    10.10.10.10:2002      10.10.10.20:1433      ESTABLISHED
  TCP    10.10.10.10:2003      10.10.10.20:1433      TIME_WAIT
  TCP    10.10.10.10:2004      10.10.10.20:1433      TIME_WAIT
				
If you runnetstat -nand you see that close to 4000 connections to the IP address of the target computer that is running SQL Server are in a TIME_WAIT state, you can both increase the defaultMaxUserPortsetting and reduce theTcpTimedWaitDelaysetting so that you do not run out of client anonymous ports. For example, you can set theMaxUserPortsetting to 20000 and set theTcpTimedWaitDelaysetting to 30. A lowerTcpTimedWaitDelaysetting means that the sockets wait in the TIME_WAIT state for less time. A higherMaxUserPortsetting means that you can have more sockets in the TIME_WAIT state.

Note that if you adjust theMaxUserPortήTcpTimedWaitDelaysetting, you must restart Microsoft Windows for the new setting to take effect. Για ναMaxUserPortANDTcpTimedWaitDelaysettings are for any client computer that is talking to a computer that is running SQL Server over TCP/IP sockets. These settings do not have any effect if they are set on the computer that is running SQL Server unless you are making local TCP/IP socket connections to the local computer that is running SQL Server.

ΣΗΜΕΙΩΣΗIf you adjust theMaxUserPortsetting, we recommend that you reserve port 1434 for use by the SQL Server Browser service (sqlbrowser.exe).Για περισσότερες πληροφορίες σχετικά με αυτήν τη διαδικασία, κάντε κλικ στον αριθμό του άρθρου παρακάτω, για να προβάλετε το άρθρο της Γνωσιακής Βάσης της Microsoft (Knowledge Base):
812873Τρόπος δέσμευσης ενός εύρους προσωρινών θυρών σε έναν υπολογιστή που εκτελεί Windows Server 2003 ή Windows 2000 Server

Προσαρμόστε τη ρύθμιση WinsockListenBacklog

Για πρόσθετες πληροφορίες σχετικά με αυτήν τη ρύθμιση μητρώου αφορούν το SQL Server, κάντε κλικ στον αριθμό του άρθρου παρακάτω, για να προβάλετε το άρθρο της Γνωσιακής Βάσης της Microsoft:
154628INF: Αρχεία καταγραφής SQL 17832 με πολλές αιτήσεις σύνδεσης TCP\IP
Όταν η βιβλιοθήκη δικτύου SQL Server εκτελεί ακρόαση σε υποδοχές TCP/IP, η βιβλιοθήκη δικτύου SQL Server χρησιμοποιεί τοακρόασηWinsock API. Η δεύτερη παράμετρος για τοακρόασηAPI είναι το backlog που επιτρέπεται για την υποδοχή. Αυτό το backlog αντιπροσωπεύει το μέγιστο μήκος της ουράς των εκκρεμών συνδέσεων για την παρακολούθηση. Κατά τη διάρκεια της ουράς υπερβαίνει το μέγιστο μήκος, η βιβλιοθήκη δικτύου SQL Server απορρίπτει αμέσως περισσότερες προσπάθειες σύνδεσης υποδοχών TCP/IP. Επιπλέον, η βιβλιοθήκη δικτύου SQL Server αποστέλλει ένα πακέτο ACK + RESET.

Η ακρόαση SQL Server 2000 χρησιμοποιεί μια προεπιλεγμένη ρύθμιση backlog 5. Αυτό σημαίνει ότι ο υπολογιστής που εκτελεί τον SQL Server μεταβιβάζει την τιμή 5 στην παράμετρο backlog από τοακρόασηWinsock API κατά τηνακρόασηΡυθμίζει το πρωτόκολλο TCP/IP ακρόαση νημάτων στον υπολογιστή που εκτελεί τον SQL Server API. Μπορείτε να προσαρμόσετε το κλειδί μητρώου WinsockListenBacklog για να καθορίσετε μια διαφορετική τιμή για αυτήν την παράμετρο μεταβίβαση. Εκκίνηση του SQL Server 2005, η βιβλιοθήκη δικτύου μεταβιβάζει μια τιμή του SOMAXCONN ως ρύθμιση backlog για τοακρόασηAPI. SOMAXCONN επιτρέπει στην υπηρεσία παροχής Winsock για να ορίσετε ένα μέγιστο λογική τιμή για αυτήν τη ρύθμιση. Επομένως, το κλειδί μητρώου WinsockListenBacklog είναι πλέον να χρησιμοποιούνται ή να χρειάζεται σε SQL Server 2005.

Το backlog ρύθμιση λειτουργεί ως εξής: Έστω ότι μια αυθαίρετη υπηρεσία κάνει ακρόαση για εισερχόμενες αιτήσεις υποδοχών TCP/IP. Εάν ορίσετε τη ρύθμιση backlog 5 και πολλές αιτήσεις σύνδεσης της υποδοχής συνεχώς ροής σε, η υπηρεσία ενδέχεται να μην μπορείτε να απαντήσετε τα εισερχόμενα αιτήματα ως γρήγορη καθώς αυτοί προέρχονται. Στο σημείο αυτό, το επίπεδο υποδοχών TCP/IP ουρές αυτών των εισερχόμενων αιτήσεων στην ουρά backlog και την υπηρεσία αργότερα να τραβήξτε τις αιτήσεις από αυτήν την ουρά και χειρίζεται τις εισερχόμενες αιτήσεις σύνδεσης υποδοχής. Μόλις γεμίσει την ουρά, το επίπεδο υποδοχών TCP/IP απορρίπτει αμέσως αιτημάτων επιπλέον υποδοχής που διατίθενται με την αποστολή ενός πακέτου ACK + RESET στον υπολογιστή-πελάτη. Αύξηση οι αυξήσεις μέγεθος ουράς backlog ζητά από τον αριθμό των εκκρεμών σύνδεση υποδοχής ότι το επίπεδο υποδοχών TCP/IP ουρές πριν αιτήσεις που απορρίπτονται.

Σημειώστε ότι τοWinsockListenBacklogη ρύθμιση αφορά στον SQL Server. SQL Server προσπαθεί να διαβάσει αυτήν τη ρύθμιση μητρώου κατά την πρώτη εκκίνηση της υπηρεσίας του SQL Server. Αν η ρύθμιση δεν υπάρχει, χρησιμοποιείται το προεπιλεγμένο 5. Εάν η ρύθμιση μητρώου υπάρχει, διαβάζει τη ρύθμιση του SQL Server και να χρησιμοποιεί την τιμή που παρέχεται με τη ρύθμιση backlog όταν ακούσετε το API WinSock ονομάζεται καθώς τα νήματα ακρόασης υποδοχών TCP/IP έχουν ρυθμιστεί στο εσωτερικό του SQL Server.

Για να προσδιορίσετε αν εκτελείτε σε αυτό το πρόβλημα, μπορείτε να εκτελέσετε ένα ίχνος εποπτείας δικτύου στον υπολογιστή-πελάτη ή τον υπολογιστή που εκτελεί τον SQL Server και να αναζητήσετε υποδοχής σύνδεσης αιτήσεις που απορρίπτονται αμέσως με ACK + RESET. Εάν εξετάζετε πακέτα TCP/IP στην Εποπτεία δικτύου, μπορείτε να δείτε ένα πακέτο, όπως οι εξής όταν προέκυψε αυτό το ζήτημα:
Frame: Base frame properties
ETHERNET:  EType = Internet IP (IPv4) 
IP: Protocol = TCP - Transmission Control; Packet ID = 40530; Total IP Length = 40; Options = No Options
TCP: Control Bits: .A.R.., len:    0, seq:         0-0, ack:3409265780, win:    0, src: 1433  dst: 4364 
  TCP: Source Port = 0x0599	
  TCP: Destination Port = 0x110C
  TCP: Sequence Number = 0 (0x0)
  TCP: Acknowledgement Number = 3409265780 (0xCB354474)
  TCP: Data Offset = 20 bytes
  TCP: Flags = 0x14 : .A.R..
    TCP: ..0..... = No urgent data
    TCP: ...1.... = Acknowledgement field significant
    TCP: ....0... = No Push function
    TCP: .....1.. = Reset the connection
    TCP: ......0. = No Synchronize
    TCP: .......0 = Not the end of the data
  TCP: Window = 0 (0x0)
  TCP: Checksum = 0xF1E7
  TCP: Urgent Pointer = 0 (0x0)
				
Σημειώστε ότι η θύρα προέλευσης 0x599 ή 1433 σε δεκαδική μορφή. Αυτό σημαίνει ότι το πακέτο προέρχεται από ενός τυπικού υπολογιστή που εκτελεί τον SQL Server και ότι λειτουργεί με την προεπιλεγμένη πύλη 1433. Σημειώστε επίσης ότι τοΠεδίο επιβεβαίωσης σημαντικόκαι τοΗ επαναφορά της σύνδεσηςέχουν οριστεί σημαίες. If you are familiar with filtering a Network Monitor trace, you can filter the TCP Flags value by 0x14 hexadecimal to see only the ACK+RESET packets in the Network Monitor trace.

Note that you can also see similar ACK+RESET packets if the computer that is running SQL Server is not running at all or if the computer that is running SQL Server is not listening to TCP/IP protocol, so seeing ACK+RESET packets is not definite confirmation that you are having this problem. Αν υπάρχει ήδη ο φάκελοςWinsockListenBacklogis too low, some connection attempts receive accept packets and some connections immediately receive ACK+RESET packets in the same timeframe.

Note that in very rare cases, you may have to adjust this setting even if pooling is enabled on the client computers. For example, if many client computers are talking to a single computer that is running SQL Server, a large number of simultaneous incoming connection attempts may occur at any particular time even if pooling is enabled.

ΣΗΜΕΙΩΣΗIf you adjust theWinsockListenBacklogsetting, you do not have to restart Windows for this setting to take effect. Just stop and restart the SQL Server service for the setting to take effect. Για ναWinsockListenBacklogregistry setting is only for the computer that is running SQL Server. It does not have any effect on any client computer that is talking to SQL Server.

Ιδιότητες

Αναγν. άρθρου: 328476 - Τελευταία αναθεώρηση: Τρίτη, 21 Δεκεμβρίου 2010 - Αναθεώρηση: 2.0
Οι πληροφορίες σε αυτό το άρθρο ισχύουν για:
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft ADO.NET 1.1
  • Microsoft SQL Server 7.0 Standard Edition
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Express Edition
  • Microsoft SQL Server 2005 Workgroup Edition
Λέξεις-κλειδιά: 
kbinfo kbmt KB328476 KbMtel
Μηχανικά μεταφρασμένο
ΣΗΜΑΝΤΙΚΟ: Αυτό το άρθρο είναι προϊόν λογισμικού μηχανικής μετάφρασης της Microsoft και όχι ανθρώπινης μετάφρασης. Η Microsoft σάς προσφέρει άρθρα που είναι προϊόντα ανθρώπινης αλλά και μηχανικής μετάφρασης έτσι ώστε να έχετε πρόσβαση σε όλα τα άρθρα της Γνωσιακής Βάσης μας στη δική σας γλώσσα. Ωστόσο, ένα άρθρο που έχει προκύψει από μηχανική μετάφραση δεν είναι πάντα άριστης ποιότητας. Ενδέχεται να περιέχει λεξιλογικά, συντακτικά ή γραμματικά λάθη, όπως ακριβώς τα λάθη που θα έκανε ένας μη φυσικός ομιλητής επιχειρώντας να μιλήσει τη γλώσσα σας. Η Microsoft δεν φέρει καμία ευθύνη για τυχόν ανακρίβειες, σφάλματα ή ζημίες που προκύψουν λόγω τυχόν παρερμηνειών στη μετάφραση του περιεχομένου ή χρήσης του από τους πελάτες της. Επίσης, η Microsoft πραγματοποιεί συχνά ενημερώσεις στο λογισμικό μηχανικής μετάφρασης.
Η αγγλική έκδοση αυτού του άρθρου είναι η ακόλουθη:328476

Αποστολή σχολίων