zl程序教程

您现在的位置是:首页 >  系统

当前栏目

linux客户端连接oracle服务器

2023-09-27 14:20:53 时间

环境:

db:12.2.0.1

os:centos 7

 

 1. 下载客户端instant

https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html

 

我这里下载的是12.2.0.1版本的,需要下载如下两个文件

instantclient-basic-linux.x64-12.2.0.1.0.zip

instantclient-sqlplus-linux.x64-12.2.0.1.0.zip

 

2. 上传客户端机器上解压

[root@localhost soft]# pwd

/soft

 

[root@localhost soft]#unzip instantclient-basic-linux.x64-12.2.0.1.0.zip

[root@localhost soft]#unzip instantclient-sqlplus-linux.x64-12.2.0.1.0.zip

 

 

3. 修改环境变量

 

[root@localhost ~]# more .bash_profile

# .bash_profile

 

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

 

# User specific environment and startup programs

export ORACLE_HOME=/soft/instantclient_12_2

export TNS_ADMIN=$ORACLE_HOME

export LD_LIBRARY_PATH=$ORACLE_HOME/:$LD_LIBRARY_PATH

PATH=$PATH:$HOME/bin:$ORACLE_HOME

 

export PATH

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4. 配置tnsnames.ora

在$ORACLE_HOME下创建tnsnames.ora文件,并添加服务器信息

[root@localhost instantclient_12_2]# more tnsnames.ora

ora19c =

    (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = ora19c)

    )

  )

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5. 登录

[root@localhost ~]# sqlplus /nolog

 

SQL*Plus: Release 12.2.0.1.0 Production on Tue Oct 20 09:40:00 2020

 

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

 

SQL> connect hxl/oracle@ora19c

Connected.