安装oracle客户端连接工具

Posted a121

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装oracle客户端连接工具相关的知识,希望对你有一定的参考价值。

第1章 安装oracle客户端工具

1.1 oracle官网下载两个rpm包放置任意路径下,使用rpm安装:

rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm

 

rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm

 

#默认安装在/usr/lib/oracle/这个路径下。

 

(注:下载前需要注册账号,免费的,可以放心注册)

1.2 配置环境变量oracle客户端)

vim ~/.bash_profile

#oracle客户端连接工具

PATH=$PATH:$HOME/bin

export ORACLE_HOME=/usr/lib/oracle/11.2/client64/

export TNS_ADMIN=$ORACLE_HOME/network/admin

export ORACLE_BASE=/usr/lib/oracle/11.2/

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH

export PATH

 

 

 

退出并保存

1.3 生效环境配置文件(oracle客户端)

source ~/.bash_profile

1.4 创建tnsnames.ora配置文件oracle客户端)

cd  /usr/lib/oracle/11.2/client64/ #cd $ORACLE_HOME

mkdir -p /network/admin(创建这两个目录)

vim /usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora

 

 

 

1 orcl =

 

2   (DESCRIPTION =

 

3     (ADDRESS_LIST =

 

4        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.198.182)(PORT = 1521))

 

5      )

 

6        (CONNECT_DATA =

 

7          (SERVER = DEDICATED)

 

8          (SERVICE_NAME = orcl)

 

9        )

 

10      )

注:

1:自己定义的连接描述符名。

 

4:HOST要远程连接的数据库的IPPORT端口默认1521

 

8:数据库的实例名。

 

(注:查看实例名# ps -ef |grep pmon

 

oracle    3894     1  0 08:30 ?        00:00:00 ora_pmon_orcl

root      5154  4546  0 09:56 pts/1    00:00:00 grep pmon

 

orcl就是实例名)

1.5 修改oracle服务端listener.ora文件

cd /opt/oracle/product/11.2.0/dbhome_1/network/admin/

  vim listener.ora

 

  SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = orcl)

      (ORACLE_HOME = /opt/oracle/product/11.2.0/dbhome_1)

      (SID_NAME = orcl)

    )

  )

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.198.182)(PORT = 1521))

    )

  )

ADR_BASE_LISTENER = /opt/oracle

1.6 修改oracle服务端的tnsnames.ora配置文件

cd /opt/oracle/product/11.2.0/dbhome_1/network/admin/

   vim  tnsnames.ora

 

LISTENER_ORCL =

  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.198.182)(PORT = 1521))

 

 

ORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.198.182)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

 

1.7 测试连接数据库:

 

 sqlplus zabbix/[email protected]

 

SQL*Plus: Release 11.2.0.3.0 Production on Tue Dec 27 11:05:09 2016

 

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL>

连接成功!!

以上是关于安装oracle客户端连接工具的主要内容,如果未能解决你的问题,请参考以下文章

不用安装Oracle客户端,远程连接Oracle数据库

本机不安装Oracle客户端,使用PL/SQL Developer和 Instant Client 工具包连接oracle 11g远程数据库

Oracle 客户端管理软件安装

如何用navicat连接oracle数据库

Oracle配置管理

ORACLE和PLSQL Developer啥关系