Linux安装oracle客户端

oracle客户端下载地址: https://www.oracle.com/database/technologies/instant-client/downloads.html.

Instant Client Installation for Linux x86-64 (64-bit)

Installation of ZIP files:

Download the desired Instant Client ZIP files. All installations require a Basic or Basic Light package.

Unzip the packages into a single directory such as /opt/oracle/instantclient_19_3 that is accessible to your application. For example:

cd /opt/oracle     

unzip instantclient-basic-linux.x64-19.3.0.0.0dbru.zip

cd /opt/oracle    

unzip instantclient-basic-linux.x64-19.3.0.0.0dbru.zip

The various packages install into subdirectories of /usr/lib/oracle, /usr/include/oracle, and /usr/share/oracle.

Prior to version 18.3, create the appropriate links for the version of Instant Client. For example:

cd /opt/oracle/instantclient_12_2
ln -s libclntsh.so.12.1 libclntsh.so
ln -s libocci.so.12.1 libocci.so
cd /opt/oracle/instantclient_12_2
ln -s libclntsh.so.12.1 libclntsh.so
ln -s libocci.so.12.1 libocci.so

Install the operating system libaio package. This is called libaio1 on some Linux distributions. On Oracle Linux 8 prior to Instant Client 21 you also need the libnsl package.
For example, on Oracle Linux, run:

sudo yum install libaio

If Instant Client is the only Oracle Software installed on this system then update the runtime link path, for example:

sudo sh -c "echo /opt/oracle/instantclient_19_3 > \
      /etc/ld.so.conf.d/oracle-instantclient.conf"
  sudo ldconfig
sudo sh -c "echo /opt/oracle/instantclient_19_3 > \
      /etc/ld.so.conf.d/oracle-instantclient.conf"
  sudo ldconfig

Alternatively, set the LD_LIBRARY_PATH environment variable prior to running applications. For example:

export LD_LIBRARY_PATH=/opt/oracle/instantclient_19_3:$LD_LIBRARY_PATH

The variable can optionally be added to configuration files such as ~/.bash_profile and to application configuration files such as /etc/sysconfig/httpd.

If you intend to co-locate optional Oracle configuration files such as tnsnames.ora, sqlnet.ora, ldap.ora, or oraaccess.xml with Instant Client, put them in the network/admin subdirectory. This needs to be created for 12.2 and earlier, for example:

mkdir -p /opt/oracle/instantclient_12_2/network/admin

This is the default Oracle configuration directory for applications linked with this Instant Client.

Alternatively, Oracle configuration files can be put in another, accessible directory. Then set the environment variable TNS_ADMIN to that directory name.

To use binaries such as sqlplus from the SQL*Plus package, unzip the package to the same directory as the Basic package and then update your PATH environment variable, for example:

export PATH=/opt/oracle/instantclient_19_3:$PATH

Start your application.

Installation of RPM files:

Download the desired Instant Client RPM packages. All installations require a Basic or Basic Light RPM.
Install the packages with yum. For example:

sudo yum install oracle-instantclient19.3-basic-19.3.0.0.0-1.x86_64.rpm

Note that from 19.3, by default only one version of the Instant Client RPM libraries can be installed at a time.

Prior to 19.3, if Instant Client is the only Oracle Software installed on this system then update the runtime link path, for example:

sudo sh -c "echo /usr/lib/oracle/18.3/client64/lib > \
      /etc/ld.so.conf.d/oracle-instantclient.conf"
  sudo ldconfig
sudo sh -c "echo /usr/lib/oracle/18.3/client64/lib > \
      /etc/ld.so.conf.d/oracle-instantclient.conf"
  sudo ldconfig

For Instant Client 19.3 RPM packages, these commands are automatically run.

An alternative to using ldconfig for older versions, is to set the LD_LIBRARY_PATH environment variable in each shell prior to running applications. For example:

export LD_LIBRARY_PATH=/usr/lib/oracle/18.3/client64/lib:$LD_LIBRARY_PATH

The variable can optionally be added to configuration files such as ~/.bash_profile and to application configuration files such as /etc/sysconfig/httpd.

If you intend to co-locate optional Oracle configuration files such as tnsnames.ora, sqlnet.ora ldap.ora, or oraaccess.xml with Instant Client, put them in the network/admin subdirectory. This needs to be created for 12.2 and earlier, for example:

sudo mkdir -p /usr/lib/oracle/12.2/client64/lib/network/admin

This is the default Oracle configuration directory for applications linked with this Instant Client.

Alternatively, Oracle configuration files can be put in another, accessible directory. Then set the environment variable TNS_ADMIN to that directory name.

To use binaries from the tools package, use yum to install the package and then update your PATH environment variable, for example:

export PATH=/usr/lib/oracle/19.3/client64/bin:$PATH

Start your application.

参考:OracleClient install on Linux

Centos环境变量设置

利用profile.d文件夹管理环境变量

1.创建oracle.sh文件

export PATH=/usr/lib/oracle/12.2/client64/bin:$PATH
export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib:$LD_LIBRARY_PATH

2.将oracle.sh文件上传至 /etc/profile.d 文件夹中

3.加载环境变量

source /etc/profile

4.查询环境变量

env |grep LD_LIBRARY_PATH
env |grep PATH

参考:Centos 配置JDK,添加环境变量/etc/profile和/etc/profile.d

ubuntu安装oracle客户端

需要将rpm包转为deb包,具体安装方法

posted @ 2021-05-29 20:02  开怀的猫  阅读(880)  评论(0编辑  收藏  举报