WIN平臺下僅開一個端口讓Oracle穿過防火墻
2024-08-29 13:36:45
供稿:網友
 
             
  windows平臺下僅開一個端口讓Oracle穿過防火墻 
  很多人問這個問題,查了大量資料,也沒有找到真正完全解決的,經過多次試驗終于成功實現。建議版主此貼加精。
  
                                                                                              Oracle客戶端連接服務器,首先去找1521監聽端口,服務器的1521監聽端口再向server PRocess進程發出請求,并返回一個隨機端口,返回給客戶端,客戶端再來連接這個端口。
  
  這樣就給服務器上的防火墻設置帶來了麻煩,這個端口是隨機的,如何開放。
  
  windows 平臺上的這個問題成了一大難題,很多論壇都有人問,但很少有人能解決。 unix平臺不用擔心,系統自動會解決這個問題.
  
  Matalink上提供了三種解決辦法,實際上USE_SHARED_SOCKET 是最有效最方便的。
  
  但經過無數次實現,仍然沒有成功,最后終于發現是Oracle 8.1.7的bug
  
  需要打補丁,升級到Oracle 8.1.7.1.2
  不同版本,注冊表位置不一樣
  - Oracle 8.1.6 for NT/2k //HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/HOME<#> (# is your desired homedir) 
  - Oracle 8.1.7.0.0 for NT/2k Doesn't work in Oracle 8.1.7.0.0 for NT/2k 
  - Oracle 8.1.7.1.2 for NT/2k //HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE 
  
  需要在MTS模式下(共享模式)Oracle默認是專用模式。
  
  經試驗發現,假如不在init文件中設參數的話,Oracle仍然會要求一個隨機端口和1521端口來共同通訊,只是這個隨機端口,并不隨客戶端會話和登錄的變化而變化,在沒有重啟服務器時,是固定的。
  
  (試驗發現,在專用模式下,每次連接,oracle服務器會按+1方式,提供一個非1521的端口。)
  
  所以,還需要在init.ora文件的最后加上一條參數:
  
  mts_dispatchers="(address=(protocol=tcp)(host=myoradb)(port=1521))(dispatchers=1)" 
  
  這樣才真正實現只用一個端口,穿過防火墻。
  
  參考資料:
  Oracle uses dynamic ports under windows NT because of a bug in windows, so oracle can't use shared sockets. This bug got fixed with service pack 3 I think. By default, oracle uses the dynamic ports without caring which service pack is installed. There is a registry setting to force oracle to use shared sockets. The parameter is (what a surprise!) USE_SHARED_SOCKET in LOCAL_MACHINE/Software/Oracle/HomeX where X is your desired homedir. This parameter should be set to TRUE. There's a whitepaper from oracle for this too, somewhere on their site. Anyway, this parameter doesnt work for 8.1.7 Some users reported that it worked with 8.1.6.3, but 8.1.7 termiates every conection immediately... 
  
  Contributed by Arne Brutschy (abrutschy@xylon.de) on July 5, 2001. 
  
  Actually, I want to establish a replication system in my local machine.. for replicating objects(tables) from remote database to a local database... what data security option i must take in to account. I request you to give me the detail description like which protocal must be used and what parameter must be set in init.ora file,sqlnet.ora and listener.ora file and what other steps to be taken... I would be very thankful to you ... if you kindly describe the things...actually i want to maintain the data privacy which happens between remote and local database while replication take place.. any one can trap the net and extract the data ... so i need to stop that. 
  
  I would be very thankful to you ... this is a request.. please mail me on the address p_v_raju73@rediffmail.com. 
  
  regards p.v.raju 
  
  Contributed by pvraju (p_v_raju73@rediffmail.com) on October 8,
                          2001. 
  
  Modify Windows registry. 
  
  USE_SHARED_SOCKET = TRUE 
  
  - Oracle 8.1.6 for NT/2k //HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/HOME<#> (# is your desired homedir) 
  
  - Oracle 8.1.7.0.0 for NT/2k Doesn't work in Oracle 8.1.7.0.0 for NT/2k 
  
  - Oracle 8.1.7.1.2 for NT/2k //HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE 
  
  - FAQ Site