Oracle和Tomcat端口冲突
今天新装了Oracle 9i 结果启动Tomcat后打开 http://localhost:8080 出来的是oracle的相关页面,管理工具—服务中关掉oracle的http服务再启动tomcat又好了,看来端口有冲突。
查了一下,改动tomcat端口很容易,打开D:/Tomcat5/conf/server.xml
找到这么一段
<!-- Define a non-SSL Coyote HTTP/1.1 Connector on the port specified during installation -->
<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />
将port="8080"改为 port="8081"就ok了,可不要改成80等热门端口哟
oracle网上也有改动方法,但对oracle还不会用,没有试
改变或关闭Oracle XDB的ftp和http端口
Oracle 9i开始,创建数据库时默认包含了XDB特性。一旦启动了数据库和Listener,Oracle XDB的http服务就占用8080端口,刚好和JBoss、Tomcat等默认端口冲突。因此,必须有一个做出更改。改Tomcat等容易,只是一时不知道怎么改XDB的配置。
在Google上搜索一下,找到了答案。原来Oracle XDB的端口设置不在配置文件中,而是在数据库里。修改XDB的http和ftp服务端口的方法有3种:
1.使用sys登录Oracle,利用dbms_xdb修改端口设置
SQL> -- Change the HTTP/WEBDAV port from 8080 to 8081
SQL> call dbms_xdb.cfg_update(updateXML(
2 dbms_xdb.cfg_get()
3 , '/xdbconfig/sysconfig/protocolconfig/httpconfig/http-port/text()'
4 , 8081))
5 /
Call completed.
SQL> -- Change the FTP port from 2100 to 2111
SQL> call dbms_xdb.cfg_update(updateXML(
2 dbms_xdb.cfg_get()
3 , '/xdbconfig/sysconfig/protocolconfig/ftpconfig/ftp-port/text()'
4 , 2111))
5 /
Call completed.
SQL> COMMIT;
Commit complete.
SQL> EXEC dbms_xdb.cfg_refresh;
PL/SQL procedure successfully completed.
2.使用OEM console,选择数据库,XML Database,Configuration。更改XDB的有关设置。
3.去掉数据库的初始化参数: dispatchers='(PROTOCOL=TCP) (SERVICE=XDB)',将会禁止XDB的http和ftp服务。
修改oracle监听占用的8080端口
SQL> call dbms_xdb.cfg_update(updateXML(dbms_xdb.cfg_get(),
2 '/xdbconfig/sysconfig/protocolconfig/httpconfig/http-port/text()',8081))
3 /
SQL> commit;
Commit complete.
SQL> exec dbms_xdb.cfg_refresh;
[oracle@test11 oracle]$ sqlplus /nolog
SQL*Plus: Release 9.2.0.4.0 - Production on Sat Aug 6 14:24:49 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> connect / as sysdba;
Connected.
-- 把HTTP/WEBDAV端口从8080改到8081
SQL> call dbms_xdb.cfg_update(updateXML(dbms_xdb.cfg_get(),
2 '/xdbconfig/sysconfig/protocolconfig/httpconfig/http-port/text()',8081))
3 /
Call completed.
-- 把FTP端口从2100改到2111
SQL> call dbms_xdb.cfg_update(updateXML(dbms_xdb.cfg_get(),
2 '/xdbconfig/sysconfig/protocolconfig/ftpconfig/ftp-port/text()',2111))
3 /
Call completed.
SQL> commit;
Commit complete.
SQL> exec dbms_xdb.cfg_refresh;
PL/SQL procedure successfully completed.
-- 检查修改是否已经成功
SQL> select dbms_xdb.cfg_get from dual;
CFG_GET
--------------------------------------------------------------------------------
<xdbconfig xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd" xmlns:xsi="http://w
SQL>
[oracle@test11 oracle]$ netstat -ntlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:32768 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:32769 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:2401 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:33730 0.0.0.0:* LISTEN 14987/ora_d000_szdb
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 2473/tnslsnr
tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN 2473/tnslsnr
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:2111 0.0.0.0:* LISTEN 2473/tnslsnr
tcp 0 0 :::11009 :::* LISTEN -
tcp 0 0 ::ffff:127.0.0.1:4001 :::* LISTEN -
tcp 0 0 ::ffff:127.0.0.1:4002 :::* LISTEN -
tcp 0 0 :::9090 :::* LISTEN -
tcp 0 0 ::ffff:127.0.0.1:12005 :::* LISTEN -
tcp 0 0 :::12009 :::* LISTEN -
tcp 0 0 :::8080 :::* LISTEN -
tcp 0 0 :::80 :::* LISTEN -
tcp 0 0 :::22 :::* LISTEN -
tcp 0 0 ::ffff:127.0.0.1:11005 :::* LISTEN -
[oracle@test11 oracle]$
Oracle数据库取消8080端口占用
安装Oracle数据库后,当我们访问8080端口时,会弹出一个XDB窗口,要求输入用户名和密码。这样将和我们本地一些使用该端口的应用冲突,比如tomcat、jboss等,虽然这些端口是可以修改的,但总是不爽oracle一直占用这个端口。以下是我找到的一个方法,我已经试验成功了,如果你想用此法进行修改,请首先备份数据库重要内容,如果操作不慎,难免要重装数据库。
Oracle数据库可以使用TCP协议通过8080端口进行连接,所以占用了8080端口。
要取消占用,可以打开Oracle安装目录下的database目录内的SPFILE[SID名].ORA文件进行修改。这个文件是Oracle的启动配置文件。
把其中的*.dispatchers=’(PROTOCOL=TCP) (SERVICE=or9iXDB)’这一行去掉即可。
然后重启计算机,或者在服务中重启OracleService[SID名]这个服务。重启后可能无法使用Enterprise Manager Console和其他客户端连接,这时请使用Oracle的Configuration and Migration Tools/Net Configuration Assistant工具删除监听器,然后新建一个监听器,重启监听器。
使用Configuration and Migration Tools/Net Manager工具,将服务命名删除,然后新建一个。
现在Oracle应该就可以正常使用,8080也不会占用了。
修改Oracle XDB默认监听端口
默认情况下, oracle listener监听1521 端口接受客户端对数据库的访问, 使用lsnrctl stat可以查看当前监听器的情况:
oracle@blueice:~/product/9.2.0/network/admin$ lsnrctl start
LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 15-JUL-2006 09:31:16
Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.
Starting /home/oracle/product/9.2.0/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 9.2.0.4.0 - Production
System parameter file is /home/oracle/product/9.2.0/network/admin/listener.ora
Log messages written to /home/oracle/product/9.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=blueice.blueice.com)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=blueice.blueice.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 9.2.0.4.0 - Production
Start Date 15-JUL-2006 09:31:16
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File /home/oracle/product/9.2.0/network/admin/listener.ora
Listener Log File /home/oracle/product/9.2.0/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=blueice.blueice.com)(PORT=1521)))
Services Summary...
Service "orcl.blueice.com" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
oracle@blueice:~/product/9.2.0/network/admin$ lsnrctl stat
LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 15-JUL-2006 09:31:19
Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=blueice.blueice.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 9.2.0.4.0 - Production
Start Date 15-JUL-2006 09:31:16
Uptime 0 days 0 hr. 0 min. 2 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File /home/oracle/product/9.2.0/network/admin/listener.ora
Listener Log File /home/oracle/product/9.2.0/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=blueice.blueice.com)(PORT=1521)))
Services Summary...
Service "orcl.blueice.com" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
使用root用户运行netstat -lnp|grep tns可以看到当前listener监听的端口
blueice:/home/oracle/product/9.2.0# netstat -lnp|grep tns
tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN 10583/tnslsnr
unix 2 [ ACC ] STREAM LISTENING 88815 10583/tnslsnr /var/tmp/.oracle/s#10583.1
数据库启动后, oracle listener增加了XDB的监听端口, lsnrctl stat结果如下
blue_stone@blueice:~$ lsnrctl stat
LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 15-JUL-2006 09:34:29
Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=blueice.blueice.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 9.2.0.4.0 - Production
Start Date 15-JUL-2006 09:31:16
Uptime 0 days 0 hr. 3 min. 12 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File /home/oracle/product/9.2.0/network/admin/listener.ora
Listener Log File /home/oracle/product/9.2.0/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=blueice.blueice.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=blueice.blueice.com)(PORT=8080))(Presentation=HTTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=blueice.blueice.com)(PORT=2100))(Presentation=FTP)(Session=RAW))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl.blueice.com" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
root用户运行netstat -lnp|grep tns结果如下
blueice:/home/oracle/product/9.2.0# netstat -lnp|grep tns
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 10583/tnslsnr
tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN 10583/tnslsnr
tcp 0 0 0.0.0.0:2100 0.0.0.0:* LISTEN 10583/tnslsnr
unix 2 [ ACC ] STREAM LISTENING 88815 10583/tnslsnr /var/tmp/.oracle/s#10583.1
但是有些情况下, 我们并不希望8080或者2100端口被oracle使用, 这就需要修改修改oracle XDB的监听端口来达到这样的目标.
在linux 下使用ftp databasehost 2100联接到oracle, 在windows下可以使用ftp://databasehost:2100/联接到oracle, 输入用户名system, 密码system的密码. 下载xdbconfig.xml文件, 使用兼容unix的编辑工具如vi或者写字板对这个文件进行修改, 如需修改ftp监听端口, 则修改
<ftpconfig>
<ftp-port>2100</ftp-port>
<ftp-listener>local_listener</ftp-listener>
<ftp-protocol>tcp</ftp-protocol>
<session-timeout>6000</session-timeout>
</ftpconfig>
中的2100为目的端口. 如许修改http监听的端口则修改
<httpconfig>
<http-port>8080</http-port>
<http-listener>local_listener</http-listener>
<http-protocol>tcp</http-protocol>
<session-timeout>6000</session-timeout>
<server-name>XDB HTTP Server</server-name>
<max-header-size>16384</max-header-size>
中的8080为目的端口. 修改完毕后, 上传回原来的位置. 比如我们将http监听的端口修改为8081后, 使用lsnrctl和netstat -lnp|grep tns结果如下
blue_stone@blueice:~$ lsnrctl stat
LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 15-JUL-2006 09:46:06
Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=blueice.blueice.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 9.2.0.4.0 - Production
Start Date 15-JUL-2006 09:31:16
Uptime 0 days 0 hr. 14 min. 50 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File /home/oracle/product/9.2.0/network/admin/listener.ora
Listener Log File /home/oracle/product/9.2.0/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=blueice.blueice.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=blueice.blueice.com)(PORT=2100))(Presentation=FTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=blueice.blueice.com)(PORT=8081))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl.blueice.com" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
blueice:/home/oracle/product/9.2.0# netstat -lnp|grep tns
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 10583/tnslsnr
tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN 10583/tnslsnr
tcp 0 0 0.0.0.0:2100 0.0.0.0:* LISTEN 10583/tnslsnr
unix 2 [ ACC ] STREAM LISTENING 88815 10583/tnslsnr /var/tmp/.oracle/s#10583.1
监听的端口已经发生了改变.
也可以使用SYSTEM用户登录运行如下语句修改http, ftp端口
BEGIN
DBMS_XDB.CFG_UPDATE(UPDATEXML(DBMS_XDB.CFG_GET(),'/xdbconfig/descendant::ftp-port/text()','2121'));
DBMS_XDB.CFG_UPDATE(UPDATEXML(DBMS_XDB.CFG_GET(),'/xdbconfig/descendant::http-port/text()','8085'));
DBMS_XDB.CFG_REFRESH();
END;
但我在运行上面语句的时候提示PLS-00201: identifier 'UPDATEXML' must be declared
原因未知.
如果不需要使用xml db, 也可以删除xdb用户, 使oracle不监听http和ftp端口
drop user xdb cascade;