centos系统远程访问oracle(oracle instantclient 客户端的安装和配置)

   
1:下载rpm软件包

网站:  http://www.oracle.com/technetwork/topics/linuxsoft-082809.html
oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm      基本的动态库(oci,bocci,jdbc-oci)
oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm    客户端sqlplus安装包
oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm      API接口文件

2:RPM安装(默认路径/usr/lib/oracle/11.2/client64)
rpm -ivh oracle-instantclient-basic-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient-sqlplus-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient-devel-11.2.0.4.0-1.x86_64.rpm

3:创建network/admin目录
mkdir -p /usr/lib/oracle/11.2/client64/network/admin

4:创建TNS(TNS是oracle数据库连接的客户端的一个工具)
cd /usr/lib/oracle/11.2/client64/network/admin
vi tnsnames.ora

添加以下代码:


ydbakdb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.1.1.1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = yadb)
    )
  )


注意:host是要远程服务器ip地址,SERVICE_NAME为远程数据库的sid

5:配置环境变量
vi .bash_profile

添加下面内容到环境变量

 

export  ORACLE_HOME=/usr/lib/oracle/11.2/client64
export  TNS_ADMIN=$ORACLE_HOME/network/admin
export  NLS_LANG='simplified chinese_china'.ZHS16GBK
export  LD_LIBRARY_PATH=$ORACLE_HOME/lib 
export  PATH=$ORACLE_HOME/bin:$PATH

6:生效环境变量
source .bash_profile
echo $OARCLE_HOME


 

你可能感兴趣的:(Python,SQL,Linux)