Sqlplus remote Oracle access tutorial in Linux, sqlplusoracle
Step 1: Download instantclient
Instantclient-basic-linux.x64-12.1.0.2.0.zip // required
Instantclient-sqlplus-linux.x64-12.1.0.2.0.zip // required
Instantclient-odbc-linux.x64-12.1.0.2.0.zip // This is not required, the package to be used for unixODBC connection
Decompress the above two zip packages to any location, such as/opt/oracle/instantclient_12_1.
The following is an official oracle document.
3. Create the appropriate libclntsh. so and libocci. so links for the version of Instant Client. For example:
Cd/opt/oracle/instantclient_12_1
Ln-s libclntsh. so.12.1 libclntsh. so
Ln-s libocci. so.12.1 libocci. so
4. Install the libaio package, for example on Oracle Linux, run this as the root user: // note that I have not installed the libaio package
Yum install libaio
On some Linux distributions the package is called libaio1.
Step 2:
Configure environment variables:
Export LD_LIBRARY_PATH =/opt/oracle/instantclient_12_1: $ LD_LIBRARY_PATH
Export PATH =/opt/oracle/instantclient_12_1: $ PATHNLS_LANG = "AMERICAN_AMERICA.AL32UTF8"
Query the database service name in the database
select value from v$parameter where name='service_names'
Logon: sqlplus username/passwd @ IP: port/servicename // note that the port is servicename instead of instance name.
Step 3: Access oracle by configuring tnsnames. ora
Configure Environment Variables
Export TNS_ADMIN =/opt/oracle/instantclient_12_1
Create a tnsnames. ora file under TNS_ADMIN
Content:
Oracledb = // login SID (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.103.20.) (PORT = 1521 )) // IP address and port number (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orc9i) // you need to connect to the database servicename ))
Log on to sqlplus username/passwd @ oracledb