如何创建自己的InstantClient包
IC介绍 许多人正在使用Oracle Instant Client,它提供一个部署基于OCI、OCCI、JDBC OCI应用容易和快速的方法。 通过添加更多的工具,Instant Client可以变成一个更加强大的工具,如下: 1. tnsping 2. sqlldr 3. tkprf 4. exp/imp 5. OCM 6. 你自己的工具 这
IC介绍
许多人正在使用Oracle Instant Client,它提供一个部署基于OCI、OCCI、JDBC OCI应用容易和快速的方法。
通过添加更多的工具,Instant Client可以变成一个更加强大的工具,如下:
1. tnsping
2. sqlldr
3. tkprf
4. exp/imp
5. OCM
6. 你自己的工具
这样做的主要优点是:
1. 安装是一件轻而易举的事情,只要解压即可完成。
2. 体积小,未压缩100MB到150MB或压缩50MB,它可以安装在USB盘上
3. 不涉及到SA(软件架构)
比较一个完整的Oracle安装需要大量的磁盘空间,而且还涉及到SA。
IC需求
1. 一个带有150MB+磁盘空间的Unix/Linux账号:
hadoop@192.168.8.162:/home/hadoop/oracle
2. 安装Oracle 11gR2的相同平台,一个具有读访问权限的账号:
root@192.168.8.192:/u01/product/oracle/11.2.0/db_1
IC安装
从Oracle官方网址下载安装包,下载网址: http://www.oracle.com/technetwork/cn/database/features/instant-client/index-097480.html
注:请根据操作系统版本下载相应的安装包,这里下载Linux X86-64安装包。
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
注:下载Instant Client时需要创建一个Oracle账号才能下载。
使用SSH客户端使用安装账号登录到服务器,在根目录下创建一个oracle目录:
$mkdir /home/hadoop/oracle
上传所有压缩包或至少basic和sqlplus两个包到你账号的根目录下oracle中。
解压到当前目录下完成安装。
$ 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
解压完毕后会在当前目录下生成一个instantclient_11_2目录。
$ ll /home/hadoop/oracle/instantclient_11_2
IC配置
配置下面的环境变量到你的Shell配置文件中。
$ vi ~/.bashrc
跳到文件的末尾,添加下面这些环境变量:
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
或 $ . ~/.bashrc
注:如果需要让所有用户都能使用,需要把上面的配置添加/etc/profile中。
在$ORACLE_IC_HOME目录下创建一个tnsnames.ora文件:
$ 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)))
或
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
或
$ sqlplus kqi/kqi@orcl
SQL*Plus: Release 11.2.0.4.0 Production onThu Nov 20 14:01:49 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
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:could not resolve theconnect identifier specified
对于这种问题,排除添加的配置格式错误后。可能原因是读取的tnsnames.ora路径根本就不是$ORACLE_HOME/network/admin下。
注:tnsnames.ora文件的查找路径顺序为:
$HOME => $TNS_ADMIN => /etc =>$ORACLE_HOME/network/admin/。
现在我们已经有一个构建自己的Instant Client包的基础了。下面是Instant Client的核心文件(位于/home/hadoop/oracle/instantclient_11_2中):
1. libclntsh.so.11.1:客户端代码库
2. libociei.so:OCI InstantClient数据共享库
3. libnnz11.so:安全库
4. libocci.so.11.1:Oracle C++调用接口库
5. libocijdbc11.so:JDBC OCI库
6. ojdbc6/5.jar:JDBC驱动(OCI和Thin)
7. orai18n.jar:字符集转换和本地支持库
Tnsping
从安装Oracle的服务器上拷贝tnsping过来,执行命令:
$ cd /home/hadoop/oracle/instantclient_11_2
$ scp root@192.168.8.192:/u01/product/oracle/11.2.0/db_1/bin/tnsping./
现在让在IC安装服务器上尝试运行下它:
$ tnsping ora
TNS Ping Utility for Linux: Version11.2.0.4.0 - Production on 20-NOV-2014 14:30:21
Copyright (c) 1997, 2013, 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
运行后tnsping抱怨一些文件丢失,更具体的说一个消息文件丢失。现在,我们把该文件从Oracle安装服务器上拷贝过来,进入到instantclient_11_2目录:
$ mkdir -p network/mesg
$ cd network/mesg/
现在从安装Oracle服务上拷贝tnsus.msb文件到该目录中:
$ scp root@192.168.8.192:/u01/product/oracle/11.2.0/db_1/network/mesg/tnsus.msb ./
让我们再尝试一次tnsping,结果如下:
$ tnsping ora
TNS Ping Utility for Linux: Version11.2.0.4.0 - Production on 20-NOV-2014 14:49:54
Copyright (c) 1997, 2013, 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
本节将添加另外一个工具sqlldr。
首先,我们从安装Oracle的服务器上拷贝sqlldr到IC安装目录instantclient_11_2下。
$ cd /home/hadoop/oracle/instantclient_11_2
$ scproot@192.168.8.192:/u01/product/oracle/11.2.0/db_1/bin/sqlldr ./
尝试运行它:
$ sqlldr
Message 2100 not found; No message file forproduct=RDBMS, facility=ULMessage 2100 not found; No message file forproduct=RDBMS, facility=UL
首先我们需要在instantclient_11_2下创建rdbms/mesg目录。
$ cd /home/hadoop/oracle/instantclient_11_2
$ mkdir -p rdbms/mesg
$ cd rdbms/mesg
把ORACLE安装目录下rdmsb/mesg/ulus.msb拷贝到当前目录。
$ scp root@192.168.8.192:/u01/product/oracle/11.2.0/db_1/rdbms/mesg/ulus.msb./
现在,让我们再次尝试运行它。
$ sqlldr
SQL*Loader: Release 11.2.0.4.0 - Productionon Thu Nov 20 16:40:10 2014
Copyright (c) 1982, 2011, Oracle and/or itsaffiliates. All rights reserved.
Usage: SQLLDR keyword=value[,keyword=value,...]
Valid Keywords:
Exp/imp
从安装Oracle服务器上拷贝二进制文件过来。
$ 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 ./
尝试运行imp和exp,结果如下:
$ imp
Message 100 not found; No message file forproduct=RDBMS, facility=IMP: Release 11.2.0.4.0 - Production on Thu Nov 2017:02:57 2014
Copyright (c) 1982, 2011, 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, 2011, 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
再从安装Oracle服务器上拷贝rdbms/mesg下的expus.msb和ipus.msb过来。
$ 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 ./
再次运行imp/exp工具错误提示消失,可以正常运行。
Tkprof
现在我们继续添加我最喜欢的工具tkprof。
从安装Oracle的服务器拷贝tkprof到instantclient_11_2目录下。
$ 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 ./
使用示例:
$ tkprof test.trc test.out
Instant Client Bundle
现在,我们已经让所有工具都能正常工作。简单的使用工具压缩打包instantclient_11_2目录,这样你就获得你自己的Instant Client包。例如:
$ cd /home/hadoop/oracle
$ tar zcf instantclient_11_2.tar.gzintantclient_11_2
正如你所看到的,打包成的instant client带有tnsping,sqlldr, exp/imp,tkprof工具,这让IC更加的功能强大。
安装自定义的IC包步骤如下:
1. 上传到服务器上解压缩
2. 修改环境变量
$ vi ~/.bashrc
跳到文件的末尾,添加下面这些环境变量:
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
或 $ . ~/.bashrc
3. 添加连接数据库的配置
$ vi $ORACLE_IC_HOME/tnsnames.ora
安装完成,现在就可以使用Instant Client中的工具啦!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Users may have seen the term wapi when using the Internet, but for some people they definitely don’t know what wapi is. The following is a detailed introduction to help those who don’t know to understand. What is wapi: Answer: wapi is the infrastructure for wireless LAN authentication and confidentiality. This is like functions such as infrared and Bluetooth, which are generally covered near places such as office buildings. Basically they are owned by a small department, so the scope of this function is only a few kilometers. Related introduction to wapi: 1. Wapi is a transmission protocol in wireless LAN. 2. This technology can avoid the problems of narrow-band communication and enable better communication. 3. Only one code is needed to transmit the signal

Pubg, also known as PlayerUnknown's Battlegrounds, is a very classic shooting battle royale game that has attracted a lot of players since its popularity in 2016. After the recent launch of win11 system, many players want to play it on win11. Let's follow the editor to see if win11 can play pubg. Can win11 play pubg? Answer: Win11 can play pubg. 1. At the beginning of win11, because win11 needed to enable tpm, many players were banned from pubg. 2. However, based on player feedback, Blue Hole has solved this problem, and now you can play pubg normally in win11. 3. If you meet a pub

This article will interest you if you are interested in using GIMP for pixel art creation on Windows. GIMP is a well-known graphics editing software that is not only free and open source, but also helps users create beautiful images and designs easily. In addition to being suitable for beginners and professional designers alike, GIMP can also be used to create pixel art, a form of digital art that utilizes pixels as the only building blocks for drawing and creating. How to Create Pixel Art in GIMP Here are the main steps to create pixel pictures using GIMP on a Windows PC: Download and install GIMP, then launch the application. Create a new image. Resize width and height. Select the pencil tool. Set the brush type to pixels. set up

i5 is a series of processors owned by Intel. It has various versions of the 11th generation i5, and each generation has different performance. Therefore, whether the i5 processor can install win11 depends on which generation of the processor it is. Let’s follow the editor to learn about it separately. Can i5 processor be installed with win11: Answer: i5 processor can be installed with win11. 1. The eighth-generation and subsequent i51, eighth-generation and subsequent i5 processors can meet Microsoft’s minimum configuration requirements. 2. Therefore, we only need to enter the Microsoft website and download a "Win11 Installation Assistant" 3. After the download is completed, run the installation assistant and follow the prompts to install Win11. 2. i51 before the eighth generation and after the eighth generation

Many friends expressed that they want to know how to create a family in Gree+ software. Here is the operation method for you. Friends who want to know more, come and take a look with me. First, open the Gree+ software on your mobile phone and log in. Then, in the options bar at the bottom of the page, click the "My" option on the far right to enter the personal account page. 2. After coming to my page, there is a "Create Family" option under "Family". After finding it, click on it to enter. 3. Next jump to the page to create a family, enter the family name to be set in the input box according to the prompts, and click the "Save" button in the upper right corner after entering it. 4. Finally, a "save successfully" prompt will pop up at the bottom of the page, indicating that the family has been successfully created.

After updating to the latest win11, many users find that the sound of their system has changed slightly, but they don’t know how to adjust it. So today, this site brings you an introduction to the latest win11 sound adjustment method for your computer. It is not difficult to operate. And the choices are diverse, come and download and try them out. How to adjust the sound of the latest computer system Windows 11 1. First, right-click the sound icon in the lower right corner of the desktop and select "Playback Settings". 2. Then enter settings and click "Speaker" in the playback bar. 3. Then click "Properties" on the lower right. 4. Click the "Enhance" option bar in the properties. 5. At this time, if the √ in front of "Disable all sound effects" is checked, cancel it. 6. After that, you can select the sound effects below to set and click

In iOS17, Apple has added a contact poster feature to its commonly used Phone and Contacts apps. This feature allows users to set personalized posters for each contact, making the address book more visual and personal. Contact posters can help users identify and locate specific contacts more quickly, improving user experience. Through this feature, users can add specific pictures or logos to each contact according to their preferences and needs, making the address book interface more vivid. Apple in iOS17 provides iPhone users with a novel way to express themselves, and added a personalizable contact poster. The Contact Poster feature allows you to display unique, personalized content when calling other iPhone users. you

In Hua Yishan Heart Moon, Lu Shu is an SSR celebrity. He is positioned as a single-target backline player and has a very impressive critical hit rate. Many players don’t know much about Lu Shu. Here’s what I’ve brought you. Come and take a look at the introduction to the skills and attributes of Hua Yishan Heart of the Moon Lu Shu. Celebrity Attributes Celebrity Skills 1. Lu Ming Shuzhong Skill Description: Lu Shu was born in Qiongqihui in Shuzhong. He has practiced martial arts since he was a child and has outstanding martial arts skills. Causes basic attack damage equal to 100% of the enemy's back row attack power, and reduces the target's rage by 10 points. Skill attributes: Level 2: Basic attack damage increased to 105%. Level 2: Basic attack damage is increased to 110%, and the target's rage is reduced by 15 points. Level 2: Basic attack damage increased to 115%. Level 2: Basic attack damage is increased to 120%, and the target's rage is reduced by 20 points. Level 2: Basic attack
