天天看点

Oracle 12.2简易客户端安装配置

下面来看安装步骤:

1、下载安装包,我这里把所有的都下载下来了

instantclient-basic-linux.x64-12.2.0.1.0.zip

instantclient-basiclite-linux.x64-12.2.0.1.0.zip

instantclient-jdbc-linux.x64-12.2.0.1.0.zip

instantclient-odbc-linux.x64-12.2.0.1.0-2.zip

instantclient-sdk-linux.x64-12.2.0.1.0.zip

instantclient-sqlplus-linux.x64-12.2.0.1.0.zip

instantclient-tools-linux.x64-12.2.0.1.0.zip

2、unzip解压

解压出来一个目录instantclient_12_2

3、配置环境变量

export ORACLE_HOME=/home/tst1/instantclient_12_2

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME

export PATH=$ORACLE_HOME:$PATH

4、配置tns

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>mkdir</code> <code>-p network</code><code>/admin</code>

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cd</code> <code>network</code><code>/admin/</code>

<code>[tst1@rhel7 admin]$ </code><code>cat</code> <code>tnsnames.ora </code>

<code>ora11g =</code>

<code>  </code><code>(DESCRIPTION = </code>

<code>    </code><code>(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.22)(PORT = 1521))</code>

<code>    </code><code>(CONNECT_DATA =</code>

<code>      </code><code>(SERVER = DEDICATED)</code>

<code>      </code><code>(SERVICE_NAME = ora11g)</code>

<code>    </code><code>)</code>

<code>  </code><code>)</code>

5、测试sqlplus,成功

<code>[tst1@rhel7 admin]$ sqlplus zx</code><code>/zx</code><code>@ora11g</code>

<code>SQL*Plus: Release 12.2.0.1.0 Production on Thu Nov 16 12:48:33 2017</code>

<code>Copyright (c) 1982, 2016, Oracle.  All rights reserved.</code>

<code>Connected to:</code>

<code>Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production</code>

<code>With the Partitioning, OLAP, Data Mining and Real Application Testing options</code>

<code>SQL&gt;</code>

6、安装sqlldr,我安装的这个版本的简易客户端中有sqlldr,如果没有的话需要从其他客户端或服务端中拷贝,但是我测试执行sqlldr报错:

<code>[tst1@rhel7 instantclient_12_2]$ sqlldr</code>

<code>Message 2100 not found; No message </code><code>file</code> <code>for</code> <code>product=RDBMS, facility=ULMessage 2100 not found; No message </code><code>file</code> <code>for</code> <code>product=RDBMS, facility=UL[tst1@rhel7 instantclient_12_2]$</code>

因为缺少mesg文件,从服务端把rdbms/mesg下的文件全部拷贝

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>mkdir</code> <code>-p rdbms</code><code>/mesg</code>

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/rdbms/mesg/</code><code>* rdbms</code><code>/mesg/</code>

再次执行sqlldr成功

7、安装oerr,简易客户端中没有oerr命令,需要从服务端拷贝

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/oerr</code> <code>./</code>

<code>[tst1@rhel7 instantclient_12_2]$ oerr</code>

<code>/home/tst1/instantclient_12_2/oerr</code><code>: line 29: </code><code>/home/tst1/instantclient_12_2/perl/bin/perl</code><code>: No such </code><code>file</code> <code>or directory</code>

执行报错,说明缺少文件,从服务端拷贝

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>-r </code><code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/perl/</code><code>* ./</code>

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>-r </code><code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/perl/</code><code>* .</code><code>/perl/</code>

<code>[tst1@rhel7 instantclient_12_2]$ oerr ora 1</code>

<code>Can't </code><code>open</code> <code>perl script </code><code>"/home/tst1/instantclient_12_2/bin/oerr.pl"</code><code>: (null)</code>

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>mkdir</code> <code>bin</code>

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>scp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/oerr</code><code>.pl .</code><code>/bin/</code>

<code>Could not </code><code>open</code> <code>facilities list </code><code>file</code><code>: </code><code>/home/tst1/instantclient_12_2/lib/facility</code><code>.lis</code>

<code>2</code>

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>mkdir</code> <code>lib</code>

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/lib/facility</code><code>.lis .</code><code>/lib/</code>

<code>00001, 00000, </code><code>"unique constraint (%s.%s) violated"</code>

<code>//</code> <code>*Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.</code>

<code>//</code>         <code>For Trusted Oracle configured </code><code>in</code> <code>DBMS MAC mode, you may see</code>

<code>//</code>         <code>this message </code><code>if</code> <code>a duplicate entry exists at a different level.</code>

<code>//</code> <code>*Action: Either remove the unique restriction or </code><code>do</code> <code>not insert the key.</code>

注意:oerr也使用到了rdbms/mesg目录下的文件,只不过第6步把整个目录都拷贝过来了,这里就省事了。

8、安装tnsping,简易安装包里也没有这个工具,需要从服务端拷贝

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/tnsping</code> <code>./</code>

<code>[tst1@rhel7 instantclient_12_2]$ tnsping</code>

<code>TNS Ping Utility </code><code>for</code> <code>Linux: Version 12.2.0.1.0 - Production on 16-NOV-2017 13:09:12</code>

<code>Copyright (c) 1997, 2016, Oracle.  All rights reserved.</code>

<code>TNS-03502: Message 3502 not found; No message </code><code>file</code> <code>for</code> <code>product=network, facility=TNS</code>

执行报错,因为缺少mesg文件

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>-r </code><code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/network/mesg/</code> <code>.</code><code>/network/</code>

<code>[tst1@rhel7 instantclient_12_2]$ tnsping 192.168.56.22:1521</code><code>/ora11g</code>

<code>TNS Ping Utility </code><code>for</code> <code>Linux: Version 12.2.0.1.0 - Production on 16-NOV-2017 13:11:04</code>

<code>Used parameter files:</code>

<code>Used HOSTNAME adapter to resolve the </code><code>alias</code>

<code>Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=ora11g))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.22)(PORT=1521)))</code>

<code>OK (10 msec)</code>

安装成功。

9、安装exp、imp、expdp、impdp,安装包中没有,直接从服务端拷贝

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/imp</code> <code>./</code>

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/exp</code> <code>./</code>

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/impdp</code> <code>./</code>

<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/expdp</code> <code>./</code>

imp和exp测试没有问题,但expdp和impdp报错:

<code>[tst1@rhel7 instantclient_12_2]$ expdp</code>

<code>Segmentation fault</code>

<code>[tst1@rhel7 instantclient_12_2]$ impdp</code>

查询MOS找到解决方法,在环境变量中添加export NLS_LANG=American_America.ZHS16GBK

问题解决。

至此,简单客户端安装完成,可以把整个目录打个包,给其他机器安装时直接解压,配置环境变量就可以使用了。比安装客户端方便的多。

备注:

如果在使用某个工具报缺少库文件时可以使用ldd命令查看该命令缺少哪个库文件,如下所示:

<code>[root@host77 instantclient_11_2]</code><code># ldd sqlldr</code>

<code>    </code><code>linux-vdso.so.1 =&gt;  (0x00007fffe63fe000)</code>

<code>    </code><code>libclntsh.so.11.1 =&gt; not found</code>

<code>    </code><code>libnnz11.so =&gt; not found</code>

<code>    </code><code>libpthread.so.0 =&gt; </code><code>/lib64/libpthread</code><code>.so.0 (0x00007f014b85c000)</code>

<code>    </code><code>libdl.so.2 =&gt; </code><code>/lib64/libdl</code><code>.so.2 (0x00007f014b658000)</code>

<code>    </code><code>libm.so.6 =&gt; </code><code>/lib64/libm</code><code>.so.6 (0x00007f014b355000)</code>

<code>    </code><code>libnsl.so.1 =&gt; </code><code>/lib64/libnsl</code><code>.so.1 (0x00007f014b13c000)</code>

<code>    </code><code>libc.so.6 =&gt; </code><code>/lib64/libc</code><code>.so.6 (0x00007f014ad7b000)</code>

<code>    </code><code>/lib64/ld-linux-x86-64</code><code>.so.2 (0x00007f014ba8b000)</code>

从上面的输出可以看出缺少libclntsh.so.11.1和libnnz11.so这两个文件,从服务端拷贝即可。

      本文转自hbxztc 51CTO博客,原文链接http://blog.51cto.com/hbxztc/1982318:,如需转载请自行联系原作者