Linux 上简单安装Oracle 11g 客户端

linux 上简单安装Oracle 11g 客户端

2022-5-12

因工作需要在linux上安装oracle客户端,只要使用到sqlplus、exp、imp
不想装完整的包,根据网上资料实践通过,记录如下。
材料:
oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

下载地址:
https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html#license-lightbox

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

1、安装客户端

rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

2、创建tnsname.ora

mkdir -p /usr/lib/oracle/11.2/client64/network/admin/

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

ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = XXXXXXX)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

3、设置环境变量

export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export TNS_ADMIN=ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH

#如果想永久有效,编辑 ~/.bashrc_profile

5、连接数据库测试

sqlplus username/passwd@ORCL

#*** 如果sqlplus 用不起来:
#vi /etc/ld.so.conf 最后加入一行 /usr/lib/oracle/11.2/client64/lib
#idconfig -- 重新链接动态库

6、安装 exp/imp

把server 端的 exp,imp,impus.msb,expus.msb 复制到客户端
server端的位置 $ORACLE_HOME/bin/exp,imp
server端的位置 $ORACLE_HOME/rdbms/mesg/expus.msb,impus.msb
先准备好这4个文件

cp ./exp /usr/lib/oracle/11.2/client64/bin
cp ./imp /usr/lib/oracle/11.2/client64/bin
mkdir -p /usr/lib/oracle/11.2/client64/rdbms/mesg
cp ./impus.msb /usr/lib/oracle/11.2/client64/rdbms/mesg
cp ./expus.msb /usr/lib/oracle/11.2/client64/rdbms/mesg
chmod 755 /usr/lib/oracle/11.2/client64/bin/*
chmod 755 /usr/lib/oracle/11.2/client64/rdbms/mesg/*

END

你可能感兴趣的:(Linux 上简单安装Oracle 11g 客户端)