How to create your own InstantClient package

Source: Internet
Author: User
IC introduction many people are using OracleInstantClient, which provides an easy and fast way to deploy applications based on OCI, OCCI, and JDBCOCI. By adding more tools, InstantClient can become a more powerful tool, as follows: 1. tnsping2.sqlldr3. tkprf4.expimp5. OCM6. your own tool

IC introduction many people are using Oracle Instant Client, which provides an easy and fast way to deploy OCI, OCCI, and JDBC-based OCI applications. By adding more tools, the Instant Client can become a more powerful tool, as follows: 1. tnsping 2. sqlldr 3. tkprf 4. exp/imp 5. OCM 6. your own tool

IC Introduction

Many people are using Oracle Instant Client, which provides an easy and fast way to deploy OCI, OCCI, and JDBC-based OCI applications.

By adding more tools, the Instant Client can become a more powerful tool, as shown below:

1. tnsping

2. sqlldr

3. tkprf

4. exp/imp

5. OCM

6. Your own tools

The main advantages of doing so are:

1. installation is easy, as long as you extract it.

2. Small Size, not compressed MB to MB or compressed 50 MB, it can be installed on USB disk

3. SA (Software Architecture) not involved)

Comparing A Complete Oracle Installation requires a lot of disk space, and SA is also involved.

IC requirements

1. A Unix/Linux account with a disk space of 150 MB +:

Hadoop@192.168.8.162:/home/hadoop/oracle

2. Install the same platform of Oracle 11gR2 and an account with read permission:

Root@192.168.8.192:/u01/product/oracle/11.2.0/db_1

IC Installation

Download the installation package from the Oracle official website, download URL: http://www.oracle.com/technetwork/cn/database/features/instant-client/index-097480.html

Note: Please download the corresponding installation package according to the operating system version, here to download the Linux X86-64 installation package.

Instantclient-basic-linux.x64-11.2.0.4.0.zip

Instantclient-jdbc-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

Note: You must create an Oracle account to download the Instant Client.

Use the SSH client to log on to the server with the installation account, and create an oracle directory under the root directory:

$ Mkdir/home/hadoop/oracle

Upload all or at least two packages, basic and sqlplus, to the oracle database under the root directory of your account.

Decompress the package to the current directory to complete installation.

$ Cd/home/hadoop/oracle

$ Unzipinstantclient-basic-linux.x64-11.2.0.4.0.zip

$ Unzipinstantclient-sqlplus-linux.x64-11.2.0.4.0.zip

$ Unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip

$ Unzip instantclient-jdbc-linux.x64-11.2.0.4.0.zip

After decompression, an instantclient_11_2 directory is generated in the current directory.

$ Ll/home/hadoop/oracle/instantclient_11_2

IC Configuration

Configure the following environment variables to your Shell configuration file.

$ Vi ~ /. Bashrc

Jump to the end of the file and add the following environment variables:

Export RACLE_IC_HOME =/home/hadoop/oracle/instantclient_11_2

ExportORACLE_HOME = $ ORACLE_IC_HOME

ExportTNS_ADMIN = $ ORACLE_IC_HOME

ExportPATH = $ PATH: $ ORACLE_IC_HOME

ExportLD_LIBRARY_PATH = $ ORACLE_IC_HOME

ExportCLASSPATH = $ ORACLE_IC_HOME/ojdbc6.jar :./

$ Source ~ /. Bashrc

Or $ .~ /. Bashrc

Note: to make it available to all users, add the configuration above to/etc/profile.

Create a tnsnames. ora file in the $ ORACLE_IC_HOME directory:

$ Vi/home/hadoop/oracle/instantclient_11_2/tnsnames. ora

Orcl= (Description = (address = (protocol = tcp) (host =192.168.8.161) (Port =1521) (Connect_data = (server = dedicated) (service_name =Wcdma)))

Or

Ora = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.8.161) (PORT = 1521) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = wcdma )))

SQL * Plus

$ Sqlplus kqi/kqi@192.168.8.161: 1521/wcdma

Or

$ Sqlplus kqi/kqi @ orcl

SQL * Plus: Release 11.2.0.4.0 Production onThu Nov 20 14:01:49 2014

Copyright (c) 1982,201 3, Oracle. All rights reserved.

Connected:

Oracle Database 11g Enterprise EditionRelease 11.2.0.2.0-64bit Production

With the Partitioning, OLAP, Data Miningand Real Application Testing options

SQL>

ERROR:

ORA-12154: TNS: cocould not resolve theconnect identifier specified

For this problem, exclude the added configuration format error. The possible cause is that the read tnsnames. ora path is not under $ ORACLE_HOME/network/admin.

Note: The Search Path sequence of the tnsnames. ora file is as follows:

$ HOME => $ TNS_ADMIN =>/etc => $ ORACLE_HOME/network/admin /.

Now we have a foundation for building our own Instant Client package. The following is the core file of the Instant Client (in/home/hadoop/oracle/instantclient_11_2 ):

1. libclntsh. so.11.1: client code base

2. libociei. so: OCI InstantClient data sharing Library

3. libnnz11.so: Security Library

4. libocci. so.11.1: Oracle C ++ call interface library

5. libocijdbc11.so: jdbc oci Library

6. ojdbc6/5.jar: JDBC Driver (OCI and Thin)

7. orai18n. jar: Character Set conversion and local support library

Tnsping

Copy tnsping from the server where Oracle is installed and run the following command:

$ Cd/home/hadoop/oracle/instantclient_11_2

$ Scp root@192.168.8.192: // u01/product/oracle/11.2.0/db_1/bin/tnsping ./

Now let's try to run it on the IC Installation server:

$ Tnsping ora

TNS Ping Utility for Linux: Version11.2.0.4.0-Production on 20-NOV-2014 14:30:21

Copyright (c) 1997,201 3, Oracle. All rights reserved.

Message 3511 not found; No message file forproduct = network, facility = TNSMessage 3512 not found; No message file forproduct = network, facility = TNSMessage 3513 not found; No message file forproduct = network, facility = TNSMessage 3509 not found; No message file forproduct = network, facility = TNS

After running, tnsping complained about the loss of some files. More specifically, a message file is lost. Now, we copy the file from the Oracle Installation server and go to the instantclient_11_2 directory:

$ Mkdir-p network/mesg

$ Cd network/mesg/

Now copy the tnsus. msb file from the Oracle Installation service to this directory:

$ Scp root@192.168.8.192:/u01/product/oracle/11.2.0/db_1/network/mesg/tnsus. msb ./

Let's try tnsping again. The result is as follows:

$ Tnsping ora

TNS Ping Utility for Linux: Version11.2.0.4.0-Production on 20-NOV-2014 14:49:54

Copyright (c) 1997,201 3, Oracle. All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.8.161) (PORT = 1521) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = wcdma )))

OK (0 msec)

Sqlldr

This section adds another tool, sqlldr.

First, copy sqlldr from the server where Oracle is installed to the instantclient_11_2 IC installation directory.

$ Cd/home/hadoop/oracle/instantclient_11_2

$ Scproot@192.168.8.192: // u01/product/oracle/11.2.0/db_1/bin/sqlldr ./

Run it:

$ Sqlldr

Message 2100 not found; No message file forproduct = RDBMS, facility = ULMessage 2100 not found; No message file forproduct = RDBMS, facility = UL

First, create the rdbms/mesg directory under instantclient_11_2.

$ Cd/home/hadoop/oracle/instantclient_11_2

$ Mkdir-p rdbms/mesg

$ Cd rdbms/mesg

Copy rdmsb/mesg/ulus. msb from the ORACLE installation directory to the current directory.

$ Scp root@192.168.8.192:/u01/product/oracle/11.2.0/db_1/rdbms/mesg/ulus. msb ./

Now, let's try to run it again.

$ Sqlldr

SQL * Loader: Release 11.2.0.4.0-Productionon Thu Nov 20 16:40:10 2014

Copyright (c) 1982,201 1, Oracle and/or itsaffiliates. All rights reserved.

Usage: SQLLDR keyword = value [, keyword = value,...]

Valid Keywords:

Exp/imp

Copy the binary file from the Oracle server.

$ Cd/home/hadoop/oracle/instantclient_11_2

$ Scp root@192.168.8.192: // u01/product/oracle/11.2.0/db_1/bin/imp ./
$ Scp root@192.168.8.192: // u01/product/oracle/11.2.0/db_1/bin/exp ./

Run imp and exp. The result is as follows:

$ Imp

Message 100 not found; No message file forproduct = RDBMS, facility = IMP: Release 11.2.0.4.0-Production on Thu Nov 2014

Copyright (c) 1982,201 1, Orac

Invalid format of Import utility name

Verify that ORACLE_HOME is properly set

Import terminated unsuccessfully

IMP-00000: Message 0 not found; No messagefile for product = RDBMS, facility = IMP

$ Exp

Message 206 not found; No message file forproduct = RDBMS, facility = EXP: Release 11.2.0.4.0-Production on Thu Nov 20 17: 03: 392014

Copyright (c) 1982,201 1, Orac

Invalid format of Export utility name

Verify that ORACLE_HOME is properly set

Export terminated unsuccessfully

EXP-00000: Message 0 not found; No messagefile for product = RDBMS, facility = EXP

Copy expus. msb and ipus. msb under rdbms/mesg from the Oracle server.

$ Cd rdbms/mesg/

$ Scproot@192.168.8.192:/u01/product/oracle/11.2.0/db_1/rdbms/mesg/impus. msb ./

$ Scproot@192.168.8.192:/u01/product/oracle/11.2.0/db_1/rdbms/mesg/expus. msb ./

Run imp/exp again. The error message disappears.

Tkprof

Now we will continue to add my favorite tool tkprof.

Copy tkprof from the server where Oracle is installed to the instantclient_11_2 directory.

$ Cd/home/hadoop/oracle/instantclient_11_2

$ Scp root@192.168.8.192: // u01/product/oracle/11.2.0/db_1/bin/tkprof ./

$ Mkdir-p oracore/mesg/

$ Cd oracore/mesg/

$ Scproot@192.168.8.192:/u01/product/oracle/11.2.0/db_1/oracore/mesg/lrmus. msb ./

Example:

$ Tkprof test. trc test. out

Instant Client Bundle

Now, we have enabled all tools to work properly. Use a simple tool to compress and package the instantclient_11_2 directory, so that you can get your own Instant Client package. For example:

$ Cd/home/hadoop/oracle

$ Tar zcf instantclient_11_2.tar.gzintantclient_11_2

As you can see, the packaged instant client comes with tnsping, sqlldr, exp/imp, and tkprof tools, which makes the IC more powerful.

To install a custom IC Package, follow these steps:

1. upload to the server for decompression

2. Modify Environment Variables

$ Vi ~ /. Bashrc

Jump to the end of the file and add the following environment variables:

Export ORACLE_IC_HOME = <解压目录> /Instantclient_11_2

Export ORACLE_HOME = $ ORACLE_IC_HOME

Export TNS_ADMIN = $ ORACLE_IC_HOME

Export PATH = $ PATH: $ ORACLE_IC_HOME

Export LD_LIBRARY_PATH = $ ORACLE_IC_HOME

ExportCLASSPATH = $ ORACLE_IC_HOME/ojdbc6.jar :./

$ Source ~ /. Bashrc

Or $ .~ /. Bashrc

3. Add database connection Configuration

$ Vi $ ORACLE_IC_HOME/tnsnames. ora

The installation is complete. Now you can use the tool in the Instant Client!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.