Two Oracle TNS Listener - oracle

When I want to connect to my database in SQLDeveloper i get a TNS listener error message.
When I stop the OracleOraClient11g_home1_32bitTNSListener in my Services and retry to connect it works fine. Then the OracleXETnsListener is running.
How can I avoid stopping the one listener that the other can start?
I've two listener.ora files where Port 1521 is configured. So I assume it has to do with the ports?

On any operating system, you are not allowed to have 2 processes listening on the same port (in this case 1521) on the same network inteface (I'm going to assume you have only 1 network interface). Otherwise how would the operating system know which process to hand the port connection over to!
As Alex has mentioned you do not need to run multiple listeners. Disable one of the services and edit the listener.ora which points to the correct service - by default this is under the oracle_home/network/admin directory but if you have changed the TNS_ADMIN variable value on the system it will be there. You can add another listener for the SID/Service Name if you wish, but in the case of Windows it will automatically pick up all the Instances running on the system.
Just in case you really do want to run 2 listeners (you would only need to do this if you have a very old RDBMS version for example) you can edit one of the listener.ora files and change the port to say 1522. An example is below:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ROBS)(PORT = 1522))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
You then change the tnsnames.ora for the connect to point to that port like this:
SCN =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ROBS)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = SCN)
)
)
Or with SQLDeveloper you can change the port directly on the IDE with the TNS direct option if that's how you have it configured.

Related

How to open oracle ORA file on DataGrip 2022 on windows 11?

I have an .ora file that I want to open on DataGrip 2022.1.2 installed on windows 11.
I installed Oracle 21c XE, and went with (Connect to Oracle with OCI).
Everything worked okay to the point of creating the tnsnames.ora file. But, I didn't understand the alias and the address I need to fill in, in order to open the .ora file.
What do I do next to open this file?
Edit:
In what folder do i paste the ora file? What do i write in HOST? What do I write in Service Name?
tnsnames.ora is just a text file. You can create or open it with any text editor. As in the example tnsnames.ora file in your link, the content should look something like this (replace example values with your hostname or IP address, port, service_name, etc.):
MyTNSAlias =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db.my.domain.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = my_service.my.domain.com)
)
)
The "alias" is the label MyTNSAlias on the left of the equals sign. It can be almost anything, but must be unique within the file and is not case sensitive.
The "address" is everything to the right of the equals sign:
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db.my.domain.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = my_service.my.domain.com)
)
)
From the link you included:
In the directory that you created on Step 1, create the network directory. Inside the network directory, create the admin directory.
The overall path should look as follows:
~/Oracle/instantclient_19_8/network/admin.
In the admin directory, create the tnsnames.ora file with the following structure:...
tnsnames.ora files can generally be found in the $ORACLE_HOME/network/admin directory. If Oracle 19c XE is installed, then there's probably already a tnsnames.ora file in that directory tree. If you're using Oracle Instant Client, then you'd need to copy the tnsnames.ora to that ORACLE_HOME directory tree.
For Oracle 21c XE connection, see the documentation: https://docs.oracle.com/en/database/oracle/oracle-database/21/xeinl/connecting-oracle-database-xeinl.html
HOST is the DNS resolvable hostname or IP address of your database server (wherever you installed the database). You can check the database listener to see what address it is using with the lsnrctl status command, and list system IP addresses with the ipconfig (Windows) or ifconfig (Linux) commands. If it is on the same machine you want to connect from, you can also say localhost or 127.0.0.1 in your connection address. The default PORT for Oracle is always 1521. The default SERVICE_NAME is XE for the container database (CDB) and XEPDB1 for the pluggable database. For example:
xepdb1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = xepdb1)
)
)
The DataGrid doc page "Step 3. Configuring ORA files" told you to put the tnsnames.ora into ~/Oracle/instantclient_19_8/network/admin.
The part ~/Oracle/instantclient_19_8 is called the Oracle Home, roughly means the installation location of the Oracle software. The default location of of tnsnames.ora is %ORACLE_HOME%\network\admin on Windows, and it should be something like C:\app\oracle\product\21.1.0\xe (according to convention of older XE release). The Oracle software installer should configure the environment variable %ORACLE_HOME% for you.
The DataGrid doc page also includes a sample TNS entry:
MyTNSAlias =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db.my.domain.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = my_service.my.domain.com)
)
)
You can put HOST = localhost or the actual hostname or the IP address. For XE, use SERVICE_NAME = xe.

How to write sqlnet.ora and tnsnames.ora for new database connection

I just created a new database connection from Oracle SQL Developer called BATCHINSERT. But when I try to tnsping it I get the following error.
TNS Ping Utility for 64-bit Windows: Version 11.2.0.2.0 - Production on 27-APR-2016 15:28:37
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
C:\oraclexe\app\oracle\product\11.2.0\server\network\admin\sqlnet.ora
TNS-03505: Failed to resolve name
This is my sqlnet.ora
# sqlnet.ora network configuration file in
# /opt/oracle/product/11.2.0/network/admin
NAMES.DIRECTORY_PATH=(TNSNAMES)
NAMES.DEFAULT_DOMAIN=WORLD
SQLNET.AUTHENTICATION_SERVICES = (NTS)
And this is my tnsnames.ora
BatchInsert=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = XE)
))
How to write the entry for it so I can run it from .bat file?
Your sqlnet.ora sets a default domain name of WORLD, so your tnsnames entry needs to have that too:
BatchInsert.WORLD=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = XE)
))
You should then be able to tnsping and connect using either batchinsert or batchinsert.world.
Alternatively you can remove the NAMES.DEFAULT_DOMAIN=WORLD line from your sqlnet.ora, but you may have other things already that expect that to be set.
This has nothing to do with SQL Developer unless you want to use that TNS alias in a connection definition, rather than using a Basic connection. If you already have a TNS entry for XE you can just use that, without defining a new entry pointing to the same service/SID.
SQL Developer doesn't by default read SQLNet.ORA
Easy fix, in Preferences, point to the directory for your TNSNames files.
If you enable THICK Driver connections and have your $ORACLE_HOME os var set, then SQLDev should see and use your SQLNet.ORA file for connectivity stuff.

How to run two oracle instances in oracle 10g

My Oracle have two instances(2 sid). From that, I can connect to one(A) instance via toad using service name. But another instance(B) is not connecting.
When I am trying to connect that instance, It is showing error like
ORA-01034: ORACLE not available
I have noticed, my ORACLE_SID is pointing to A instance. I wanted two (A&B) instances available.
Please suggest what are the changes required. Actually Oracle installed in Linux.
Can you check your tnsname.ora file has two instance like below..
A =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = A)
)
)
B =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = B)
)
)
Suggested steps to try and tackle the problem -
1. Perform the test Balakumar Subramanian suggested to make sure your tnsnames is configured probably.
2. step 1 doesn't fix the problem, try connecting to the database from within the server by connecting as the user used to install oracle (usually oracle), setting the environment variable ORACLE_SID as the sid of instance B and connecting with the "sqlplus / as sysdba" command.
This should allow you to connect even if the instance is down, and then you can mount and open it from within sqlplus.
3. If connecting as sysdba also fails, than you should check if a service dedicated to instance B exist. If not, you're instance is not installed probably and should probably start from the top and re-install it.
Best of luck.

Oracle SQL Developer: Failure - Test failed: The Network Adapter could not establish the connection?

Problem
Please note that I changed details for security purposes. However, the problem remains intact.
I installed an Oracle 11g database on a server at location, say, herp-devDV.derp.edu.
Now I have another Oracle 11g database on a server at location, say, derp-db.derp.edu.
I entered the connection name, username, password, hostname, and service name in Oracle SQL developer for both herp-devDV.derp.edu and derp-db.derp.edu. I can connect to schema in derp-db.derp.edu, but not herp-devDV.derp.edu. It gives me this message:
Failure - Test failed: The Network Adapter could not establish the connection
Details
I have the following information:
Port 1521 is not open for either server when I telnet
My listener is up and running for both.
I can access derp-db.derp.edu on Oracle SQL Developer.
Oracle client is on my local machine + Oracle SQL Developer
I can remote desktop to both servers
What I have done
Googled
Stackoverflow
Ran stop and start lnrctl commands
On herp-devDB.derp.edu I ran lsnrctl status
I received the following output
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production
Start Date 03-JUN-2014 13:37:22
Uptime 6 days 0 hr. 53 min. 4 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File D:\oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
Listener Log File d:\oracle\diag\tnslsnr\HERP-DEVDB\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=HERP-DEVDB.derp.edu)(PORT=1521)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "HERPDEVDBXDB" has 1 instance(s).
Instance "herpdevdb", status READY, has 1 handler(s) for this service...
Service "herpdevdb" has 1 instance(s).
Instance "herpdevdb", status READY, has 1 handler(s) for this service...
The command completed successfully
I then check out my listener.ora and find
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\oracle\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = HERP-DEVDB.derp.edu)(PORT = 1521))
)
)
At this point, I confess I am scratching my head as I don't see anything sticking out and telling me why this should not be working.
The only clue is when I check derp-db.derp.edu and run the command lsnrctl status. Please
see excerpt below:
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DERP-DB.edu)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 11.2.0.3.0 - Production
Start Date 18-MAY-2014 02:19:01
Uptime 22 days 12 hr. 23 min. 18 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
---etc----
So I am still scratching my head. Why would derp-db be connecting to the DERP-DB.edu but herp-devDB is connecting to EXTPROC1521? How do I fix this? The listener.ora and other files between these two servers are almost identical except for the name of the instances.
Hmmm.
EDIT1: I changed the listener.ora in herp. This didn't fix it.
EDIT2: I cannot telnet into derp-db.derp.edu on port 1521. But I can still connect to it with SQL Developer? Wth?
EDIT3 I cannot telnet into herp-devdb.derp.edu on port 1521 either.
EDIT4 I cannot ping IP addresses of either server.
Anyway assistance would be greatly appreciated. Thanks
Regards,
Geeky
I am answering this for the benefit of future community users. There were multiple issues. If you encounter this problem, I suggest you look for the following:
Make sure your tnsnames.ora is complete and has the databases you wish to connect to
Make sure you can tnsping the server you wish to connect to
On the server, make sure it will be open on the port you desire with the specific application you are using.
Once I did these three things, I solved my problem.
I had a similar issue where I also continuously got the same error. I tried many things like changing the listener port number, turning off the firewall etc. Finally I was able to resolve the issue by changing listener.ora file. I changed the following line:
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
to
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
I also added an entry in the /etc/hosts file.
you can use Oracle net manager to change the above line in listener.ora file. See Oracle Net Services Administrator's Guide for more information on how to do it using net manager.
Also you can use the service name (database_name.domain_name) instead of SID while making the connnection.
I Hope it helps.
I just had same issue when I installed the oracle 11g and then creating the database.
I don't even know that the listener has to create manually.
Hence, I open Net Configuration Assistant and manually create the listener.
And I can connect the database that I created locally through sql developer.
I solved this by writing the explicit IP address defined in the Listener.ora file as the hostname.
So, instead of "localhost", I wrote "192.168.1.2" as the "Hostname" in the SQL Developer field.
In the below picture I highlighted the input boxes that I've modified:
I solved just by: given correct host and port
so:
Open oracle net manager
Local
Listener
in Listener on address 2 then copy host to Oracle Developer
finally connect to oracle
You can locate a file named listener.ora under the installation folder oraclexe\app\oracle\product\11.2.0\server\network\ADMIN
It contains the following entries
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = Codemaker-PC)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
You should verify the HOST (Here it is Codemaker-PC) should be the computer name. If it's not correct the change it as computer name.
then try the following command on the command prompt run as administrator,
lsnrctl start
Curiously, I was able to solve the same issue by doing the exact opposite move to svc's ! I had to :
1) replace the FQDN hostname in my tnsnames.ora / listener.ora files with localhost, and restart the listener service, and
2) two, I had to use "SYS as SYSDBA" as the username in the SQL Developer input textbox
to finally be able to have SQL Developer hook to my local instance.
only start listner then u can connect with database.
command run on editor:
lsnrctl start
its work fine.
I faced the same problem.
I had to turn off my firewall, then it worked.
You could also open the port:
http://windows.microsoft.com/en-in/windows/open-port-windows-firewall#1TC=windows-7
This worked for me. may help some one. Turn off firewall. on RHEL 7
systemctl stop firewalld
For me, the HOST was set differently in tnsnames.ora and listener.ora.
One was set to the full name of the computer and the other was set to IP address.
I synchronized them to the full name of the computer and it worked. Don't forget to restart the oracle services.
I still don't understand exactly why this caused problem because I think IP address and computer name are ultimately same in my understanding.

not able to starting OracleXNTNSListener in windows environment

I have installed oracleXE in my local meachine.
I have changed the services of Oracle level Automatic to Manual.
Know when i start the Oracle Services all are getting started except the OracleXNTNSListener service.
It saying some times below mentioned 1 error or 2 error
1>Windows could not start OracleXETNSListner service on Local Computer.
Error 1067:The process terminated unexpectedly.
OR
2>The OracleXNTNSListener service on Local Computer startred and then stopped.Some services stop automatically if they are not in use by other services or programs.
After some trials the listener got started.
What I did is for this, I have edited the listener.ora file.
In this line intialy HOST = hostname was there, I changed that to localhost ip i.e 127.0.0.1
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
I know its a very old thread but, changing 127.0.0.1 to localhost in both listener.ora and tnsnames.ora helped me.
My listener.ora file was like this
(ADDRESS = (PROTOCOL = TCP)(HOST = my_computer_name)(PORT = 1521))
I changed to
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
and then it worked.
I face this problem, because I have installed Oracle 12c previous, then I try to install Oracle 11g express.
Check this registry key to ensure ORACLE_HOME is configured for the service:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\KEY_XE\ORACLE_HOME
If that doesn't exist, check here:
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_XE\ORACLE_HOME
Also make sure this other key isn't pointing to your old client registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\KEY_XE\ORACLE_HOME_KEY
or
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_XE\ORACLE_HOME_KEY
Check if the system variable ORACLE_HOME is set to C:\oraclexe\app\oracle\product\11.2.0\server (or similar).
this might be caused because you changed your PC-NAME. Make sure in "listener.ora" file HOST = PC-NAME (eg: admin-PC).

Resources