您的位置:首页 > 数据库 > Oracle

Oracle客户端连接防火墙设置手记

2007-08-14 12:50 465 查看
最近由于工作原因,需使用Oracle作为后台的数据库。于是先在自己的电脑架设一测试环境,遂使用vmware安装一Windows XP Professional,然后在其上安装Oracle 9i for Windows。原本是打算在Red Hat Linux 9下面安装Oracle 9i for linux的,只是网上查到的资料显示,Oracle在linux平台下面安装非常复杂,而且不容易成功,因为没有太多时间弄linux,因此暂时就安装一个windows版的oracle作为测试只用,连接Oracle的客户端放在Host机子上面,使用Oracle官方的SQL Develpoer作为访问工具。

客户端在连接数据库的时候,客户端报建立连接失败。首先想到的当然是防火墙,于是把XP的防火墙关闭,重新建立连接,OK,成功。但是Oracle到底是使用哪些Port呢?暂时还不想把windows的firewall关闭。好了,百度一下,你就知道,但是无果,可能是关键字选错了吧,好了,自己动手,自力更生吧。

重新开启防火墙,打开防火墙的log记录,然后Client端尝试连接,失败,检查log记录发现TCP 1521端口被Drop掉了(1521是Oracle默认的Listen端口),于是在防火墙里面把TCP 1521设置为例外。

重新连接,发现客户端又使用了新的Port,把这个新的端口加入例外中,再试,又出现新的端口号码,又加入,还是不行,反复试了多次,仍然以失败告终,发现这个端口一直在变化,而且没有规律性的,测试宣告失败。

再次去Baidu一下,找到问题原因,原来1521只是通讯初期使用的端口,而建立连接的端口是由服务器随机产生的。在注册表的HKEY_LOCAL/SOFTWARE/ORACLE/HOMEx(x为0,1,2....)的位置添加字符串:USE_SHARED_SOCKET,并设置其值为:TRUE,重启系统,或者重启Oracle数据库后重新连接成功。百度上搜到的原文URL如下:http://akaiwh.bokee.com/viewdiary.14531941.html

另外,可参考如下英文资料

引用资料:
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: