Oracle客戶穿越防火墻難題
2024-08-29 13:45:05
供稿:網(wǎng)友
近來由于工作需要,在Windows xp平臺(tái)上安裝了Oracle9i數(shù)據(jù)庫(kù)作為測(cè)試之用,一切正常。但當(dāng)客戶機(jī)連接服務(wù)器時(shí)卻總是超時(shí),我首先想到了防火墻,當(dāng)我打開1521端口時(shí),連接操作仍然失敗。 我又懷疑網(wǎng)絡(luò)有問題,用telnet server_ip:1521嘗試,連接被接受,說明1521端口已經(jīng)被打開。
沒有辦法,查詢Oracle資料后才明白,network listener 只起一個(gè)中介作用,當(dāng)客戶連接它時(shí),它根據(jù)配置尋找到相應(yīng)的數(shù)據(jù)庫(kù)實(shí)例進(jìn)程,然后spawned一個(gè)新的數(shù)據(jù)庫(kù)連接,這個(gè)連接端口由network listener傳遞給客戶機(jī),此后客戶機(jī)就不再和打交道了,即使listener停止了工作。這個(gè)新的連接端口是不可預(yù)知的,因而會(huì)被防火墻阻止。
Windows Socket2 規(guī)范有一個(gè)新的特性,就是Shared Socket, 所謂共享套接字是指一個(gè)進(jìn)程共享另一個(gè)進(jìn)程的套接字(詳見MSDN相關(guān)參考)。假如讓network listener與數(shù)據(jù)庫(kù)服務(wù)進(jìn)程共享套接字,那么連接端口就不會(huì)變化。
如何設(shè)置 Shared Socket?
在注冊(cè)表:HKEY_LOCAL_MACHINE OFTWARE/ORACLE/HOME0上新建一個(gè)字符串值:USE_SHARED_SOCKET=true。假如安裝了多個(gè)目錄,則每個(gè)類似的目錄都要設(shè)置:HKEY_LOCAL_MACHINE OFTWARE/ORACLE/HOMEx (x目錄編號(hào))
設(shè)置后要求重新啟動(dòng)實(shí)例(只重啟listener發(fā)現(xiàn)沒有效果)
引用資料:
http://www.computer-book-authors.org/aud_450.htm
典型問題:
http://www.lazydba.com/oracle/0__37815.Html
when a client connects to a listener it uses port 1521 at the client machine. the listener then returns to the client thru a different port. The 1521 port is closed and the db connection uses the new port for communicating with the client. i want the listener to return to the client using port 1521, how?
metalink says use the use_shared_socket parameter, but its still not working. i set the parameter to true in the sys env and in the registry.
....
Oracle 原文:
USE_SHARED_SOCKET
You can set the USE_SHARED_SOCKET parameter to TRUE to enable the use of shared sockets. If this parameter is set to TRUE, the network listener passes the socket descriptor for client connections to the database thread. As a result, the client does not need to establish a new connection to the database thread and database connection time imPRoves. Also, all database connections share the port number used by the network listener, which can be useful if you are setting up third-party proxy servers.
On Windows NT 4.0 Service Pack3 or earlier, enabling this option precludes bringing the network listener up or down in a case where a database connection spawned by the network listener is active. Therefore, you may
need to shut down all of the databases serviced by a network listener before you can bring down and restart a network listener. This results from the way shared sockets have been implemented in WINSOCK2. WINSOCK2 does not
allow a reliable thread to a network listener on any port on which other connections are also active. This is not an issue on Windows NT 4.0 Service Pack 4 orlater. Oracle recommends that you upgrade to Windows NT 4.0 Service Pack 4 if you intend to set this parameter.
This parameter only works in dedicated server mode in a TCP/IP environment. If this parameter is set,
you cannot use the 8.1.5 listener to spawn Oracle 7.x databases. To spawn an Oracle 8.0.x database from an 8.1.5 listener
==============