Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Ranjan.

Asked: October 12, 2001 - 8:08 pm UTC

Last updated: April 22, 2013 - 3:06 pm UTC

Version: 8.1.7

Viewed 50K+ times! This question is

You Asked

Hi Tom,

Oracle database is running on some particular unix box. From the database can we get the port number. From v$instance i can get the hostname and instance name. The purpose of getting the port number is to create a database link dynamicaly using the instance and port number so that we don't have to configured the TNS entry on the client machine.
Thanks
Ranjan

and Tom said...

You cannot get the port -- the port is not necessarily known to the database.

The listener need not be running on the same machine with the database, a single listener might be servicing many databases.

A database may have many listeners servicing it.


You might be interested in Oracle Names -- a names server that can run to serve up this information to interested clients.

see
</code> http://docs.oracle.com/cd/A81042_01/DOC/network.816/a76933/products.htm#439800 <code>
...

Rating

  (16 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

How can I change Oracle 9i port number in Windows 2k

Susie Maxwell, January 24, 2003 - 12:22 pm UTC

My oracle port number default to 80, my IIS5 port number is 81, I want to disable Oracle port number, then change IIS5 port to 80, how can I do that?

Tom Kyte
January 24, 2003 - 1:04 pm UTC

port 80, sounds more like http then Oracle net?

anyway, no idea what software you are running on port 80, oas, ias, just apache. assuming apache -- shutdown the service, edit the apache config files change 80 to whatever and restart.

where can I find Apache config file

Susie Maxwell, January 24, 2003 - 5:23 pm UTC

Would you please tell me where is Apache config file? Thanks!

Tom Kyte
January 24, 2003 - 6:06 pm UTC

anyone have a windows install about? i don't....

on my unix boxes it is in the Apache/Apache/conf/httpd.conf file.

Suggestion

Riaz Shahid, January 25, 2003 - 5:34 am UTC

You can disable running apache server from services of windows....just disable the apache server to be run and that port will be free.

Riaz

I know how to change Apache config

A reader, January 27, 2003 - 10:49 am UTC

Thanks very much! It works!
In Windows 2000, the standard config files are located in the c:\oracle\ora90\apache\apache\conf\httpd.conf. You can change port from here. And also you can start up and shut down the server from the Start menu. Click Start | Programs|Oracle - OraHome90 | Oracle HTTP Server and choose the appropriate shortcut. You can also manage the HTTP service from teh Service applet.

Vague

Victor, May 06, 2003 - 12:39 pm UTC

I can't understand , if listener is on one mashine and database on the other, how do they communicate?
And I've read that PMON asks listener port,
if port is unknown what does PMON ask ?
May be I mislead ?
Thanks.

Tom Kyte
May 06, 2003 - 12:47 pm UTC


we communicate over a network.

PMON uses the default 1521 address on the local machine, if the listener is not there, it does not register itself.

If 1521 on the local machine is "wrong", you use the init.ora parameter local_listner to tell it where it really is.

is this still true for 9.2?

Mark Rem, July 01, 2003 - 1:36 pm UTC

Thanks for your initial response to this question. However, is it still true in 9.2 there is no place in the data dictionary where Oracle stores the port number users have connected via?

I find it hard to imagine how Oracle knows where to send responses. In a dedicated server environment, when Oracle wants to send data to a server process, how does Oracle know where the server process is ((which port it is waiting on)?
-Mark

Tom Kyte
July 01, 2003 - 2:13 pm UTC

the client is connected to the dedicated server -- they both "know" the port.

The dedicated server attaches the SGA, reads datafiles. That is how the pieces talk. tcp is between the client and the dedicated server.

In shared server, the client connects to a dispatcher on a port. They both "know" that port. The dispatcher and shared server use a queue in the SGA to communicate.

"oracle" as a whole doesn't need to know.

Need to know

Richard, July 01, 2003 - 3:51 pm UTC

I see your point that oracle 'doesnt need to know' however if my customer needs to know, how can I record the port number which was used in the connection? Are you saying Oracle does not record any port specific info in the data dict? It seems like a good piece of info to have if you deploy an application that uses different SSL and non-SSL ports and needed to monitor how users are connecting.

Tom Kyte
July 01, 2003 - 4:00 pm UTC

if they use dedicated server, it is easy -- they use the port the listener is on.

if they use shared server, they connect to a dispatcher. dispatchers can be told what ports to use or they optimally use wildcard ports.

I don't understand where the "different ssl and non-ssl" ports come into play at all.

If you have a real world scenario, something you are trying to accomplish, feel free to try and ask that -- seems like we are dancing around here. Why would they care what port i used last week? of what use is that information?

If you need to see how users are connecting to the database (ssl, non-ssl, whatever) you certainly do not need to see the port. We can tell you how they connected (audting does that)

Could you demonstrate how?

Reader, July 01, 2003 - 8:12 pm UTC

Tom,

"If you need to see how users are connecting to the database (ssl, non-ssl, whatever) you certainly do not need to see the port. We can tell you how they
connected (audting does that)"

Could you please let us know how the above could be accomplished? Thanks.

Tom Kyte
July 02, 2003 - 7:02 am UTC

SQL> audit connect;

and then the comment$text in sys.aud$ will have the protocol (and apparently the client PORT as well....)

sys@ORA920> /

COMMENT$TEXT
-----------------------------------------------------------------------------------------------------------------------------------
Authenticated by: DATABASE; Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=138.1.120.255)(PORT=35837))
Authenticated by: OS
Authenticated by: DATABASE; Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=138.1.120.255)(PORT=35838))
Authenticated by: DATABASE; Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=138.2.5.52)(PORT=60004))
Authenticated by: DATABASE
Authenticated by: OS
Authenticated by: DATABASE; Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=138.2.5.52)(PORT=60037))
Authenticated by: DATABASE

8 rows selected.


On the server, they were all connected to 1521 when using tcp (the protocol is what would be of interest to you) 

Good response and follow q&a.

MarkRem, July 02, 2003 - 8:30 am UTC

thanks TK, et. al. for your insights. You've answered all my questions.

For Richard, here's my 2 cents on getting the port number for audit purposes. When a user's request hits the listener, only the listener's log file records which port the user's request came in on. Any port info known to the database would be the redirect port, which is of no use in an audit of user activity. However, you could use package utl_file to read the contents of file listener.log into a dummy audit table, and parse it from there using pl/sql. Should be very easy to do.

RE: Need to know

Richard, July 03, 2003 - 9:42 pm UTC

Currently we are running a two node RAC cluster with a listenr on each node supporting two ports SSL and non-SSL. We have to audit everything, even what ports are used for each connection. We had to lock down our non-SSL port with IPSEC since the portal we are using only supported ODBC via 1521 (non SSL). Even with all this security we still have to monitor what ports 'specific' users are coming in on for auditing purposes. We are also using Selective Audit, which does not monitor what port is being used so that is suprising. I see your point, just making the comment that it would be nice if port info was recorded in DD somewhere such as V$session.

Mark Rem - Good advice, I seemed to remember hearing that somewhere else . .

Follow-up on port

Rory Concepcion, October 06, 2003 - 10:37 pm UTC

Hi Tom,

Congrats on your new book. Havent gotten it yet coz it has
not arrived the Philippines yet. But I've already ordered
thru some relatives in the US.

How do I determine if the port for httpd which is "8001"
is listening? I forgot the linux command that shows if that
port is open. Should there be an error when starting the
services if that port is down? thanks

Tom Kyte
October 07, 2003 - 7:52 am UTC

well, you can just

telnet hostname 8001


or you can use netstat to see whats on what.



Which port number should opened for an Oracle Database?

Dawar, February 22, 2005 - 5:06 pm UTC

Hello Tom,

OS: SuSE Linux Enterprise Server 8.

I have Oracle Database 10.1.0.2.0 running on SuSE Linux Enterprise Server 8.

We will use this database for internal uses.
Our security folks wants from me to tell them which ports should be open?



1) Are there any default list of port for an Oracle database running on linux?

2) Which port number must opened for an Oracle Database?

3) Could you tell me what ports should I requested to open? --- may be repeating




Regards,
Dawar

Tom Kyte
February 22, 2005 - 5:25 pm UTC

1) nope, they are all configurable and NONE are mandatory.

2) none

3) you tell me, what services would YOU like to provide

Oracle Consultnat

Dawar, February 22, 2005 - 9:45 pm UTC

Tom,

What about port 1521?

We will provide access for FTP, SSH.
If you think any thing else important for us, please let me know.

But right now, I can see 1521 (Beacause this is use in tnsname), FTP (?) & SSH (Port 22).


Regards,
Dawar


Tom Kyte
February 23, 2005 - 2:00 am UTC

1521 is not mandatory.


do you NEED 1521, you are the only one that can answer that. and if you are using shared server, 1521 is just the first bit.

you need to determine your needs in your environment - what services do you want to provide.


the answers to 1, 2, 3 above stand as they are.

Dawar, February 23, 2005 - 10:26 am UTC

Here what I get
Tom,

I understand your point.

This is just for sharing new ideas.
Here what I get from :

$ORACLE_HOME/install> more porlist*
Ultra Search HTTP port number =5620
iSQL*Plus HTTP port number =5560
Enterprise Manager Agent Port =
Enterprise Manager Console HTTP Port (witsprd) = 5505
Enterprise Manager Agent Port (witsprd) = 1830

I am using above ports for my console.
So I need all above ports, plus what ever services I need such as SSH, FTP etc.

Regards,
Dawar




Changing port to 80

mohannad, April 02, 2008 - 1:29 am UTC

Hi Tom, wishing you are so fine,
we have application server installed in our server, we can access the application in the internet using this url
http://ipADDRESS:7778/forms/frmservlet
we need to change the port 7778 to 80, we change this in httpd file and disaple IIS. still this is not working. is there any further steps to be done? thank you so much

parse tnsnames.ora

A reader, April 12, 2013 - 11:33 am UTC

Tom,

Do you have a script for windows and unix which parses the tnsnames.ora file a can pull out the host and port? Maybe that would be easiest way for telling what port the listener is on for the DB?

Thank,
Mihhail
Tom Kyte
April 22, 2013 - 3:06 pm UTC

$ lsnrctl services

would be (is) what I use...