V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
wsgzao
V2EX  ›  程序员

Install Oracle Instant Client on Linux and Windows

  •  
  •   wsgzao ·
    wsgzao · 2017-08-10 17:57:11 +08:00 · 2028 次点击
    这是一个创建于 2691 天前的主题,其中的信息可能已经有所发展或是发生改变。

    前言

    本篇文章用最简单和快速的方法介绍如何在 Red Hat Enterprise Linux 安装 Oracle Instant Client,该方法同样适用于 Windows,RHEL5/6/7,OEL,CentOS。Oracle Instant Client 是官方免费授权的一种比 Oracle Client 还要简单的数据库管理工具,通过 SQL*Plus 或者其它工具比如 Navicat 等用于快速连接和管理 Oracle 数据库服务器。

    Install Oracle instantclient basic and instantclient sqlplus on Linux and Windows.

    更新记录

    2017 年 08 月 10 日 - 初稿

    阅读原文 - https://wsgzao.github.io/post/oracle-instant-client/

    扩展阅读

    Oracle Instant Client Downloads - http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

    Oracle Instant Client Downloads

    文章内容均已 64 位版本为例,如果客户端有特殊需求请使用 32 位版本兼容

    1. Linux Oracle Instant Client 推荐使用 RPM 方式安装,如果需要定制具体路径可以使用 zip 包手动配置
    2. Windows 和 Linux 类似但需要主要 PATH 环境变量的配置
    3. 实测 12 版本客户端可以向下兼容 11 版本的数据库服务器,Oracle Instant Client 12.2.0.1.0,Oracle Database 11.2.0.3.0

    下载地址 http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

    百度网盘分流 http://pan.baidu.com/s/1slhoZEH

    Linux

    以 RPM 最简方式为例

    Preparation

    Download all the required RPM from the official site and put them on the target system. Current RPMs for 64bit are: oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm

    Install RPMs

    # install as root
    rpm -ivh oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm
    
    # create oracle group and user
    groupadd dba
    useradd -g dba oracle
    echo oracle:oracle | chpasswd
    
    # configure profile
    su - oracle
    vi ~/.bash_profile
    
    export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib
    export TNS_ADMIN=/usr/lib/oracle/12.2/client64/
    export PATH=/usr/lib/oracle/12.2/client64/bin:$PATH
    
    # Connect to Your database with:
    sqlplus system/oracle@oracapdb
    
    # create new tnsnames.ora
    # ORA-12154: TNS:could not resolve the connect identifier specified
    vim /usr/lib/oracle/12.2/client64/tnsnames.ora
    
    oracapdb =
       (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.70.244)(PORT = 1521))
              (CONNECT_DATA =
            (SERVER = DEDICATED)
          (SERVICE_NAME = oracapdb)
       )
    )
    
    # You can also use the Easy Connect connection string format (does not use TNSNAMES):
    sqlplus system/oracle@//172.28.70.244:1521/oracapdb
    

    Windows

    Windows 的配置相比 Linux 差不多简单,注意环境变量尤其是 TNS_ADMIN

    Preparation

    国外一篇图文并茂的文章写的也很详细,有需要可以参考下 Installing Oracle instantclient basic and instantclient sqlplus on win32 http://www.dbatoolz.com/t/installing-oracle-instantclient-basic-and-instantclient-sqlplus-on-win32.html

    Go to Instant Client Downloads for Microsoft Windows download page: http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html

    unzip files

    # 下载解压以下两个包至目录,比如 C:\instantclient_12_2
    instantclient-basic-windows.x64-12.2.0.1.0.zip
    instantclient-sqlplus-windows.x64-12.2.0.1.0.zip
    
    # 设置环境变量
    计算机右键 [属性] ---- [高级系统设置] ---- [环境变量] ---- [系统变量] ---- [ Path ] 
    
    # Setup your system %PATH% and %TNS_ADMIN% variables
    C:\instantclient_12_2
    
    # Connect to Your database with:
    sqlplus system/oracle@oracapdb
    
    # TNS_ADMIN
    # ORA-12154: TNS:could not resolve the connect identifier specified
    Variable Name: TNS_ADMIN
    Variable Value: C:\instantclient_12_2
    
    # create new tnsnames.ora
    C:\instantclient_12_2\tnsnames.ora
    
    oracapdb =
       (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.70.244)(PORT = 1521))
              (CONNECT_DATA =
            (SERVER = DEDICATED)
          (SERVICE_NAME = oracapdb)
       )
    )
    
    # You can also use the Easy Connect connection string format (does not use TNSNAMES):
    sqlplus system/oracle@//172.28.70.244:1521/oracapdb
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2859 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 18ms · UTC 12:48 · PVG 20:48 · LAX 04:48 · JFK 07:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.