2

I want to set the environmental variables for OracleDB and SqlPlus properly. However, they are overriding each other. I'm doing something wrong, and I would like to get a hand finding where I went wrong.

Setup:

Oracle Linux 7

OracleDb 12.1.0.2.0 (12c)

Sqlplus 12.2.0.1.0

Here is my scenario.

Step 1: First, I set the environmental variables for OracleDB in "One" terminal window, as follows

[myuser]$ export ORACLE_HOME=/u02/app/oracle/product/12.1.0.1/dbhome_1
[myuser]$ export ORACLE_SID=o12c
[myuser]$ export LD_LIBRARY_PATH=/usr/lib:$ORACLE_HOME/lib
[myuser]$ export PATH=$ORACLE_HOME/bin:$PATH

Step 2: Second, I set the Environmental Variables for SQLPLUS in the "One" terminal window used in step 1, as follows:

[myuser]$ ORACLE_HOME=/usr/lib/oracle/12.2/client64
[myuser]$ PATH=$ORACLE_HOME/bin:$PATH
[myuser]$ LD_LIBRARY_PATH=$ORACLE_HOME/lib
[myuser]$ export ORACLE_HOME
[myuser]$ export LD_LIBRARY_PATH
[myuser]$ export PATH

Then, I perform the following command.

[myuser]$ sqplus / as sqldba

Which comes back with the following error.

SQL*Plus: Release 12.2.0.1.0 Production on Tue Jun 27 18:57:44 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

ERROR:
ORA-12545: Connect failed because target host or object does not exist

Enter user-name: 

If I enter any user name (currently logged on user included), I get the following error:

Enter user-name: sysdba
Enter password: 
ERROR:
ORA-12545: Connect failed because target host or object does not exist

Lastly, if I try to execute the "nolog" command, I get the following.

[oracle@localhost Desktop]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Tue Jun 27 19:01:10 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

And, I tried to enter the conn / as sysdba command, and I get the following:

SQL> conn / as sysdba
ERROR:
ORA-12545: Connect failed because target host or object does not exist

If I run the command, "env" I get the last Oracle_home variable set. In the scenario described above. It's SQLPlus Oracle_Home.

3
  • 1
    The error comes from a failed TNS connection, but you are specifying a TNS connection. I'd guess you have the env variable TWO_TASK set, which will cause your connect to be interpreted as "conn / as sysdba @$TWO_TASK. Oh, and SYSDBA is not a username.
    – EdStevens
    Commented Jun 28, 2017 at 0:42
  • I guess it is only a typo, but you used role sqldba which is not valid. Also username sysdba would be wrong. And finally I don’t see why you would set variables in step 1 and overwrite them in step 2?
    – eckes
    Commented Apr 28, 2018 at 7:15
  • why do you want to connect with a 12.2 sqlplus to a 12.1 database? This is not supported and not necessary, There is already an sqlplus in the 12,1 database installation. This one you should use to connect to your database.
    – miracle173
    Commented May 29, 2018 at 2:18

1 Answer 1

-1

I found a solution.

I noticed that the path ORACLE_HOME wasn't working properly. I used a deductive method. I determined the error by executing common commands that normally run by supplying the name of the application (Within OracleDB suite). For example:

First I checked the oratab file, as follows:

 vi /etc/oratab

Which gave me the following output:

orcl:/u02/app/db12c/product/12.1.0/dbhome_1:Y

Then, I started executing common commands. For example, I ran the "Listener Controller application" as follows:

lnsrctl status

Which gave me the following error:

bash: /u02/app/db12c/product/12.1.0/dbhome_1/lnsrctl: No such file or directory

Then, I decided to use the command above by stating the path explicitly.

/$ORACLE_HOME/bin/lsnrctl

Which gave me the following:

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 27-JUN-2017 20:28:22

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Welcome to LSNRCTL, type "help" for information.

Then I ran the status of the Lnsrctl, as follows:

LSNRCTL> STATUS

Which gave me the following:

STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                27-JUN-2017 20:28:37
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u02/app/db12c/diag/tnslsnr/{ServerURL}/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST={ServerURL})(PORT=1521)))
The listener supports no services
The command completed successfully

After the above, I was able to run the commands normally. For instance,

sqlplus / as sysdba

Which gave me the familiar screen of:

SQL*Plus: Release 12.1.0.2.0 Production on Tue Jun 27 20:29:11 2017

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.

SQL>

And that was the problem. I'm not really sure if this is a glitch, setup problem, or design feature, but I hope this post can help someone who is going through the same situation. From now on, I have to use the command:

/$ORACLE_HOME/bin/lsnrctl

explicitly.

Thanks for everyone who posted.

1
  • I appreciate that you want share your solution with the other users, but I think there are some wrong observations and therefore wrong conclusions that it is better to ignore this post. Therefore I downvote it. Unfortunately your question didn't get enough attention by this community and therefore wasn't analyzed and answered carefully though I think it is a good question.
    – miracle173
    Commented May 29, 2018 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.