Need Help To Resolve ORA-12154 - oracle

I installed Oracle 12cR2.
Everything is fine.
Connected as SYS, Successful.
Now, what I did is changed my Container DB i.e. CDB$ROOT to ORCLPDB (Using Alter Session). And Created a User Called demo with password. Granted necessary permissions. Successful.
In that same session, I tried to connect to demo User, but unable to connect to it.
Error Shows as Follow:
ORA-12154: TNS:could not resolve the connect identifier specified.
How can I resolve this issue?
(Note: The user is in PDB)
tnsnames.ora
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SID = orcl)
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

you are trying to connect to Demo/Password#ORCLPDB
there is no alias ORCLPDB in your tnsnames.ora, so Oracle complains that it can't find it
therefore:
connect to Demo/Password#ORCL (as you have ORCL in tnsnames.ora), or
modify the file and
add the new database alias (ORCLPDB) if it is a different database, or
add yet another alias for the same database, e.g. ORCL, ORCLPDB = ...

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 do i set up oracle instant client on ubuntu 18.04?

so I'm trying to monitor oracle database by ODBC on zabbix, but my zabbix server is ubuntu 18.04 and I really confused because oracle is using rpm.
i do this step by step to configure oracle instant client:
https://sudonull.com/post/110401-Monitoring-Oracle-Database-through-ODBC-in-Zabbix
but while im trying to install sqlplus I got confused because of tnsnames.ora,
on tutorial he said to create a connection to the database with the name TESTDB for example, it's look like this:
TESTDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oratestdb)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = testdb)
)
)
so I made it exactly look like above, I do config /etc/hosts too but it got this error "TNS NO LISTENER" while trying to connect sqlplus.
I try to start lsnrctl but apparently it doesn't have lsnrctl.service
my question is,
is it "TESTDB" something that i just made up or it should be the name of database on oracle database?
when you finally try login in "sqlplus example/example#example" is it using user and password from oracle database that you have?
is it "TESTDB" something that i just made up or it should be the name
of database on oracle database?
Taking your own example
TESTDB = -- you can give any name of your wish here
(DESCRIPTION =
(ADDRESS = -- following 3 fields are details of DB server
(PROTOCOL = TCP)
(HOST = oratestdb)
(PORT = 1521)
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = testdb) -- This is the service name of the DB on given server
)
)
when you finally try login in "sqlplus example/example#example" is it
using user and password from oracle database that you have?
Yes this is the password of oracle DB user
sqlplus scott/tiger#TESTDB

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.

Oracle connection unable to connect with SID defined

I have a single database instance and I'm able to connect to it by just using the user and password as such:
sqlplus system/password
However if I try to add an SID to the connection I get the following error:
sqlplus system#db1/password
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
I tried to enter a different incorrect SID to check if I get the same error but I get another error:
sqlplus system#wrongdb/password
ORA-12514: TNS:could not resolve the connect identifier specified
I've used the netcfa to create the listener and the service entry is present in the TNSNAMES.ora file. What is preventing the connection with SID?
EDIT: I'm also able to tnsping the service:
tnsping SCDEMO
Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhos t)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SCDEMO)))
OK (0 msec)
The syntax is wrong, it must be
sqlplus system/password#db1

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.

Resources