Linux – Environmental Variables for OracleDB 12 in Oracle Linux are Overriding Each Other with SQLPlus Variables

linuxoracleoracle-12c

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.

Best Answer

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.