码迷,mamicode.com
首页 > 数据库 > 详细

安装oracle客户端连接工具

时间:2019-03-19 16:33:18      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:mes   connected   实例名   测试   定义   path   glob   add   变量   

第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/123456@orcl

 

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客户端连接工具

标签:mes   connected   实例名   测试   定义   path   glob   add   变量   

原文地址:https://www.cnblogs.com/A121/p/10559376.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!