Linux 免安装Oracle客户端软件 连接 Oracle数据库
1、mkdir -p /opt/oracle
2、cd /opt/oracle
3、去oracle官网下载如下三个压缩包(最好下载与orcale服务器对应版本的)
然后传到/opt/oracle目录
oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.zip
oracle-instantclient11.2-sqlplus-11.2.0.1.0-1.x86_64.zip
oracle-instantclient11.2-sdk-11.2.0.1.0-1.x86_64.zip
官方地址如下:
(32位)
(64位)
下载需要oracle账户,没有就免费注册一个吧。
4、将如下内容,复制粘贴到install.sh
#!/bin/bash
#author loopeelee
yum install -y libaio*
#不装这个包,连接的时候会报错如下:
#/opt/oracle/lib/sqlplus: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
cd /opt/oracle
unzip oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.zip > /dev/null 2>&1
unzip oracle-instantclient11.2-sqlplus-11.2.0.1.0-1.x86_64.zip > /dev/null 2>&1
mv instantclient_11_2/ lib
unzip oracle-instantclient11.2-sdk-11.2.0.1.0-1.x86_64.zip > /dev/null 2>&1
mv instantclient_11_2/ sdk
mkdir -p /opt/oracle/network/admin
cd /opt/oracle/network/admin
#下面的HOST = 和SERVICE_NAME = 需要根据自己值修改
echo 'wcsracdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.22.8)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = uerdb)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)' > tnsnames.ora
echo 'export ORACLE_HOME=/opt/oracle
export LD_LIBRARY_PATH=/opt/oracle/lib'>> /etc/profile
echo "Done"
5、chmod u+x install.sh
6、./install.sh
7、使环境变量立即生效
source /etc/profile
或者直接执行如下两条命令更好:
export ORACLE_HOME=/opt/oracle
export LD_LIBRARY_PATH=/opt/oracle/lib
8、测试:
/opt/oracle/lib/sqlplus
也可以这样/opt/oracle/lib/sqlplus user/password@wcsracdb
--------------------------------------分割线 --------------------------------------
rlwrap - 解决Linux下SQLPLUS退格、上翻键乱码问题
通过设置SQLPLUS ARRAYSIZE(行预取)加快SQL返回速度
--------------------------------------分割线 --------------------------------------