Windows上Oracle开放防火墙端口问题

时间:2024.4.20

Windows上Oracle开放防火墙端口问题

安装完Windows版的Oracle 10G 后,开启了windows 2003自带的防火墙,发现在本机可以访问oracle数据库,但在远程不能连接,一直都在报连接超时。关闭防火墙后,可以用远程连接Oracle 10G 数据库。但开启防火墙后,又不能连接,说明问题出在防火墙上,防火墙开启TCP 1521端口,仍然不能连接数据库。解决问题的办法如下:

1.如果是Oracle 8i ,修改注册表HKLM\Software\Oracle,增加一个字符串值USE_SHARED_SOCKET = TRUE。

2.如果是非Oracle 9i,打开%Oracle_Home%\bin\oracle.key文件,按里面的路径HKLM增加一个字符串值USE_SHARED_SOCKET = TRUE。

[HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0]

"USE_SHARED_SOCKET"="TRUE"

3.增加以后重启机子让注册表生效

问题描述:

要使Oracle客户端能正常连接到设置有防火墙的安装在windows上的Oracle服务器,单开放一个1521或自定义的监听端口是不够的。

unix平台不用担心,系统自动会解决这个问题.,只需要开放一个1521端口就行。

在windows系统下,Oracle客户端连接服务器,首先去找1521监听端口,服务器的1521监听端口再向server process进程发出请求,并返回一个随机端口给客户端,客户端再来连接这个端口和数据库进行通信。

监听端口之外的这个新的连接端口是不可预知的,因而会被防火墙阻止。如何做到只开放1521端口就能正常访问Oracle数据库?下面我们来具体介绍解决此问题的方法。

解决方案一:

Windows Socket2 规范有一个新的特性,就是Shared Socket, 所谓共享套接字是指一个进程共享另一个进程的套接字(详见MSDN相关参考)。如果让network listener与数据库服务进程共享套接字,那么连接端口就不会变化。

如何设置Shared Socket?

在注册表:HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE \HOME0上新建一个字符串值:USE_SHARED_SOCKET=true。如果安装了多个目录,则每个类似的目录都要设置:HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOMEx (x目录编号) 设置后要求重新启动oracle数据库服务(只通过sqlplus工具shutdown后,再startup数据库发现没有效果)。

解决方案二:

1、 在Windows防火墙上设置开放 TCP 1521端口(Oracle TNSListener),使用telnet oracle服务器ip 1521 测试端口是否开放;

2、打开注册表,找到HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0,新建一个字符串值:USE_SHARED_SOCKET=true;

3、修改Oracle数据库操作模式,默认为“专用服务器模式”,修改为“共享服务器模式”。可以使用Database Configuration Assistant工具修改;

4、重新启动Oracle数据库实例。

Oracle 9i 在window 2003防火墙设置 2009-06-25 Oracle客户端连接服务器,首先去找1521监听端口,服务器的1521监听端口再向server process进程发出请求,并返回一个随机端口,返回给客户端,客户端再来连接这个端口。这样就给服务器上的防火墙设置带来了麻烦,这个端口是随机的,如何开放?

windows 平台上的这个问题成了一大难题,很多论坛都有人问,但很少有人能解决。unix平台不用担心,系统自动会解决这个问题.

Matalink上提供了三种解决办法,实际上USE_SHARED_SOCKET 是最有效最方便的。

方法一:

在windows2003的注册表中,hkey_local_machine\software\oracle\home0\下加入字符串值: USE_SHARED_SOCKET=TRUE,在服务器上开启TCP“1521”端口,重启ORCALE服务器即可!

方法二:

1、首先将数据库实例改为SHARED SERVER模式

2、以SYSDBA登录SQLPLUS,通过SQLPLUS生成系统当前的参数设置文件pfile:create pfile='d:\init.ora' from spfile;

3、修改d:\init.ora文件,在其中增加(用editplus编辑):*.service_names='your service name'和*.dispatchers='(address=(protocol=tcp)(host=localhost)(port=1521)(dispatchers=1)'

4、生成新的SPFILE:create spfile from pfile='d:\init.ora';

5、重启动数据库。

6、在防火墙中开放1521端口。

方法三:

在数据库端(也可以是另外的机器,但是cman的机器必须和数据库都在防火墙的后面)安装了cman的前提下,启动cman,然后开放防火墙端的1630端口(看cman开的是什么端口啦),最后在客户端的tnsnames.ora文件中添加:

cmantest = (description = (address_list = (address = <- first address is to CMAN (protocol=tcp) (host=hostname or ip of cman) (port=1610) ) (address= <- second address is to Listener (protocol=tcp) (host=hostname or ip of listener) (port=1521) ) ) (connect_data = (sid = sidname)) (source_route = yes)


第二篇:在防火墙上开放Oracle服务端口


在防火墙上开放Oracle服务端口

我们有的时候需要映射端口远程去访问Oracle 数据库,这里有个防火墙的问题,在unix 上没有问题,但是在win 平台上却无法正确访问,下面的可以解决这个问题

要使Oracle客户端能正常连接到设置有防火墙的Oracle服务器,单开放一个1521或自定义的监听端口是不够的。

昨天晚上为了测试BOM的多层转单层程序,而需要连接到服务器上的Oracle将数据导入。因为服务器重装成Windows2003了,并开放了系统自带的防火墙,在连接中发现在防火墙上打开监听端口1521后还是无法连通,报连接超时错误。于是试将防火墙关闭,就可以连通,说明还有什么端口未打开所致。

而我现有的Oracle知识,并不知道还需要开放什么端口,于是上网查查先,问题终于解决了。从网上找到有如下资料:

资料一、

近来由于工作需要,在Windows XP平台上安装了Oracle9i数据库作为测试之用,一切正常。但当客户机连接服务器时却总是超时,我首先想到了防火墙,当我打开1521端口时,连接操作仍然失败。我又怀疑网络有问题,用telnet server_ip:1521尝试,连接被接受,说明1521端口已经被打开。

没有办法,查询Oracle资料后才明白,network listener 只起一个中介作用,当客户连接它时,它根据配置寻找到相应的数据库实例进程,然后spawned一个新的数据库连接,这个连接端口由network listener传递给客户机,此后客户机就不再和打交道了,即使listener停止了工作。这个新的连接端口是不可预知的,因而会被防火墙阻止。

Windows Socket2 规范有一个新的特性,就是Shared Socket, 所谓共享套接字是指一个进程共享另一个进程的套接字(详见MSDN相关参考)。如果让network listener与数据库服务进程共享套接字,那么连接端口就不会变化。

如何设置 Shared Socket?

在注册表:HKEY_LOCAL_MACHINESOFTWAREORACLEHOME0上新建一个字符串值:USE_SHARED_SOCKET=true。如果安装了多个目录,则每个类似的目录都要设置:HKEY_LOCAL_MACHINESOFTWAREORACLEHOMEx (x目录编号)

设置后要求重新启动实例(只重启listener发现没有效果)

引用资料:

/aud_450.htm

典型问题:

/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

==============

资料二、

oracle客户端连接服务器,首先去找1521监听端口,服务器的1521监听端口再向server process进程发出请求,并返回一个随机端口,返回给客户端,客户端再来连接这个端口。 这样就给服务器上的防火墙设置带来了麻烦,这个端口是随机的,如何开放?

windows 平台上的这个问题成了一大难题,很多论坛都有人问,但很少有人能解决。 unix平台不用担心,系统自动会解决这个问题.

windows 平台上的这个问题成了一大难题,很多论坛都有人问,但很少有人能解决。 unix平台不用担心,系统自动会解决这个问题. Matalink上提供了三种解决办法,实际上USE_SHARED_SOCKET 是最有效最方便的。但经过无数次实现,仍然没有成功,最后终于发现是Oracle 8.1.7的bug 需要打补丁,升级到Oracle 8.1.7.1.2

需要在MTS模式下(共享模式)

需要在MTS模式下(共享模式) oracle默认是专用模式。

经试验发现,如果不在init文件中设参数的话,Oracle仍然会要求一个随机端口和1521端口来共同通讯,只是这个随机端口,并不随客户端会话和登录的变化而变化,在没有重启服

务器时,是固定的。

经试验发现,如果不在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_MACHINESoftwareOracleHomeX 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...

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_MACHINESoftwareOracleHomeX 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.

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

regards p.v.raju Contributed by pvraju (p_v_raju73@rediffmail.com) on October 8, 2001. Modify Windows registry.

USE_SHARED_SOCKET = TRUE

Modify Windows registry.

USE_SHARED_SOCKET = TRUE - oracle 8.1.6 for NT/2k HKEY_LOCAL_MACHINESOFTWAREORACLEHOME<#> (# 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_MACHINESOFTWAREORACLE

- FAQ Site

/archive/comp.databases.oracl e.server/2002/04/13/143024.htm /archive/comp.databases.oracl e.server/2002/04/13/143024.htm http://www.pauck.de/marco/misc/oracle_and_firewall s.html

- FAQ Site

/archive/comp.databases.oracl e.server/2002/04/13/143024.htm /archive/comp.databases.oracl e.server/2002/04/13/143024.htm http://www.pauck.de/marco/misc/oracle_and_firewall s.html

环境:win2000,oracle 9.2.0.1

方法一:在windows2000的注册表中,hkey_local_machinesoftwareoraclehome0下加入字符串值:

USE_SHARED_SOCKET=TRUE,即可

方法二:1、首先将数据库实例改为SHARED SERVER模式

2、以SYSDBA登录SQLPLUS,通过SQLPLUS生成系统当前的参数设置文件pfile:create pfile='d:init.ora' from spfile;

3、修改d:init.ora文件,在其中增加(用editplus编辑):*.service_names='your service name'和*.dispatchers='(address=(protocol=tcp)(host=localhost)(port=1521)(dispatchers=1)'

4、生成新的SPFILE:create spfile from pfile='d:init.ora';

5、重启动数据库。

6、在防火墙中开放1521端口。

方法三:在数据库端(也可以是另外的机器,但是cman的机器必须和数据库都在防火墙的后面)安装了cman的前提下,启动cman,然后开放防火墙端的1630端口(看cman开的是什么端口啦),最后在客户端的tnsnames.ora文件中添加:

cmantest = (description = (address_list = (address = <- first address is to CMAN (protocol=tcp) (host=hostname or ip of cman) (port=1610) ) (address= <- second address is to Listener (protocol=tcp) (host=hostname or ip of listener) (port=1521) ) ) (connect_data = (sid = sidname)) (source_route = yes)

更多相关推荐:
Diogenes and Alexander 翻译

Lesson18DiogenesandAlesander他躺在光溜溜的地上赤着脚胡子拉茬的半裸着身子模样活像个乞丐或疯子可他就是他而不是别的什么人大清早他随着初升的太阳睁开双眼搔了搔痒便像狗一样在路边解手他在公...

Diogenes and Alexander 戴奥吉尼斯和亚历山大

GilbertHighetThisarticlebythelateclassicistGilbertHighetdescribesameetingbetweentwosharplycontrastingpers...

Diogenes and Alexander retelling第欧根尼和亚历山大

ThepassagecanbedevidedintotwopartsthefirstparttalksaboutDiogenesthesecondpartisaboutDiogenes39meetingwithAlexanderI...

大学英语(四)Diogenes and Alexander 戴奥吉尼斯和亚历山大

DiogenesandAlexander戴奥吉尼斯和亚历山大TheDogHasHisDayGilbertHighetThisarticlebythelateclassicistGilbertHighetdesc...

Thoughts After Diogenes and Alexander

TheQuestThatNeverEndsThisessayontheencounterofDiogenesandAlexanderisreallythoughtprovokingIknewalittleabouttheDoggi...

Diogenes_and_Alexander__戴奥吉尼斯和亚历山大

GilbertHighetThisarticlebythelateclassicistGilbertHighetdescribesameetingbetweentwosharplycontrastingpers...

Diogenes and Alexander

DiogenesandAlexanderLyingonthebareearthshoelessbeardedhalfnakedhelookedlikeabeggaroralunaticHewasonebutnottheotherH...

What made Alexander the Great

WhatmadeAlexandertheGreatAbstractAlexanderofMacedonknownasAlexandertheGreatwasaGreekkingofMacedonHewasthefirstkingt...

Diogense and Alexander

01LyingonthebareearthshoelessbeardedhalfnakedhelookedlikeabeggaroralunaticHewasonebutnottheotherHehadopenedhiseyesw...

The Paraphrase of Units 现代大学英语精读3单元重点句子

Unit1YourCollegeYears123456789Unit2HowReadingChangedMyLife12345678937Unit4DiogenesandAlexander12withafewhandfulsofw...

introductions of Diogenes and Alexander

introductionsofDiogenesandAlexander1TheworldsgreatestCynicDiogeneswasbornin412BCEinSinopeacityontheBlackSeaAsayoung...

Diogenes and Alexander

DiogenesandAlexander1LyingonthebareearthshoelessbeardedhalfnakedhelookedlikeabeggaroralunaticHewasonebutnottheother...

diogenes and alexander读后感(13篇)