Download ZIP files :-
from here : Oracle RPMs for linux
You have to download following ZIP files :- (I installed for 64 bit). There are two ways to install instantclient :- first by zip files and second by rpms.
by zip :-
download following zips :-
instantclient-basic-linux.x64-11.2.0.4.0.zip
instantclient-jdbc-linux.x64-11.2.0.4.0.zip
instantclient-odbc-linux.x64-11.2.0.4.0.zip
instantclient-sdk-linux.x64-11.2.0.4.0.zip
instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
instantclient-tools-linux.x64-11.2.0.4.0.zip
unzip in folder /opt/oracle
then
Download all files in a folder ( I've downloaded here : /opt/software/) , Then UNZIP all files :- like this
# unzip instantclient-basic-linux.x64-11.2.0.4.0.zip
# unzip instantclient-jdbc-linux.x64-11.2.0.4.0.zip
# unzip instantclient-odbc-linux.x64-11.2.0.4.0.zip
# unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip
# unzip instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
# unzip instantclient-tools-linux.x64-11.2.0.4.0.zip
and place that unzipped directory(instantclient_11_2) to (as I saved in)" /opt/oracle/instantclient_11_2"
open gedit as root user and open file "/etc/profile". Add following lines at the end of file :
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/oracle/instantclient_11_2
export PATH=$PATH:/opt/oracle/instantclient_11_2
export TNS_ADMIN=/opt/oracle/instantclient_11_2/network/admin
export ORACLE_HOME=/opt/oracle/instantclient_11_2
export CLASSPATH=$CLASSPATH:/opt/oracle/instantclient_11_2
export JAVA_HOME=/usr/java/jdk1.8.0_211-amd64
Here must installed jdk1.8 at least may be by rpm. You may download it via it's website.
save and close profile file.
remember that java version should be java 8.
Now open Text editor as root and create following file :-
named tnsnames.ora and add following lines :-
-----------------------------------------------
ora11gr2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = oel11gr2.oraclehomenet.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ora11gr2)
)
)
-------------------------------------------------
Alias for database name :-
<alias> =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <ip>)(PORT = <port>))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = <dbname>)
)
)
-------------------------------------------------
Because this file is created manually so you need to consider these things :
ora11gr2 is name of SID which is alias to Global Database Name and may be same as in server side file.
oel11gr2.oraclehomenet.com which is fully qualified domain name of host named oel11gr2 ( here I gave oel for oracle enterprise linux ) where oracle database server is installed.
save this tnsnames.ora file to "/opt/oracle/instantclient_11_2/network/admin"
sqlnet.ora file:-
# sqlnet.ora Network Configuration File: /opt/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
----------------------------------------------------------------------
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
ADR_BASE = /opt/oracle/instantclient_11_2
----------------------------------------------------------------------
listner.ora file :-
# listener.ora Network Configuration File: /opt/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
---------------------------------------------------------------------
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = server1.db.net)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /opt/oracle/instantclient_11_2/network/admin
------------------------------------------------------------------
put all these 3 files in /opt/oracle/instantclient_11_2/network/admin
You may copy these three files from database server from path
"/opt/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/"
and paste here in " /opt/oracle/instantclient_11_2/network/admin/" and modify some parts of files.
if there is no "network/admin/" directory then create them in /opt/oracle/instantclient_11_2/
now open terminal and give following command to get sql prompt :-
$ sqlplus scott@ora11gr2
Password : <Enter password for oracle database user scott and press enter>
SQL>
Done.
if sqlplus is not working, it may be because of permissions. To set it, set permission of sqlplus and files do this :-
# chmod -R 777 /opt/oracle
or
# chmod -R 775 /opt/oracle
where "/opt/oracle" is parent directory of "instantclient_11_2". And here give all permissions to all or for user and group. Add users in this group to protect from others.
place this file named "login.sql" in location :
"/opt/oracle/instantclient_11_2/network/sqlplus/admin"
if it is not present, then create it with path.
and set this path to "SQLPATH" enviornment variabe in "/etc/profile" along with other environment variables. As :
export SQLPATH=/opt/oracle/instantclient_11_2/network/sqlplus/admin
if there is no such directory in that path then create it as given above with path.
create and name the file as "login.sql" in above path of directory and its content should be :
"define _editor=gedit"
OR
define _editor=/usr/bin/vim
# of course without quotes, note :- there is space between "define" and "_editor" and not in both side of "=" .
command to get editor in sqlplus is :-
SQL> ed file1.sql
or
SQL> ed file1
execute as :-
SQL> @ file1 "press Enter Here"
or
SQL> @ file1.sql "press Enter here"
or with path to sql file as :-
SQL>ed /opt/sql-scripts/a
SQL>@/opt/sql-scripts/a
and now here is your output.
if oracle sqlplus doesn't connect then open firewall settings and add user defined ports : 1158 & 1521 both in oracle server and oracle instant client PC and as with permanent option choosen.
as follows :
No comments:
Post a Comment