linuxoracle客户端部署

https://www.cnblogs.com/lim-sy/p/16805630.html

1. 下载安装包

​ zip包(免安装):
​ instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
​ instantclient-basic-linux.x64-11.2.0.4.0.zip
​ instantclient-sdk-linux.x64-11.2.0.4.0.zip
​ instantclient-precomp-linux-11.2.0.4.0.zip #PRO*C程序开发用到的预编译工具,即proc程序;

  1. sqlplus、basic、sdk下载地址:
    https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
    precomp下载地址:
    https://www.oracle.com/database/technologies/instant-client/precompiler-downloads.html

image-20230527150720932

2.安装解压缩到/home/oracle目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 解压
unzip instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
unzip instantclient-basic-linux.x64-11.2.0.4.0.zip
unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip
unzip instantclient-precomp-linux-11.2.0.4.0.zip
# 安装必要驱动
apt install -y libaio* (ubuntu)
yum install -y libaio* (centos)
# 创建文件夹 切换到目录
cd /home/oracle/instantclient_11_2 && mkdir -p ./network/admin
# ===============================================================
框内配置可暂且不做配置先看能否远程连接
# 新建tnsnames.ora文件
vi tnsnames.ora
# history_162:数据库sid,host:oracle数据库ip,port:oracle数据库端口,SID:数据库的sidhistory_162 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.131)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID =xxx)
)
)
# ===============================================================

3.配置环境变量

1
2
3
4
5
6
7
8
9
10
# 配置环境变量(可直接写入系统变量:/etc/profile)
vi .bash_profile
export ORACLE_HOME=/home/oracle/instantclient_11_2
export TNS_ADMIN=$ORACLE_HOME/network/admin
# exportNLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME
export PATH=$ORACLE_HOME:$PATH
# 刷新环境变量
source .bash_profile

image-20230626123523549

4.测试数据库连接

1
2
3
# 测试数据库连接
sqlplus username/passwd@sid
sqlplus system/oracle@10.0.0.131:1521/helowin

image-20230527152556143

结语祝好!