Answers:
首先,您需要下载 Instant Client Downloads。安装外来软件包,以便您可以通过在终端中键入以下命令来安装rpm软件包。
sudo apt-get install alien
完成后,转到rpm文件所在的文件夹,然后执行以下操作:
sudo alien -i oracle-instantclient*-basic*.rpm
sudo alien -i oracle-instantclient*-sqlplus*.rpm
sudo alien -i oracle-instantclient*-devel*.rpm
您需要安装libaio.so
。键入以下命令来执行此操作:
sudo apt-get install libaio1
创建Oracle配置文件:
sudo sensible-editor /etc/ld.so.conf.d/oracle.conf
将此行放在该文件中:
/usr/lib/oracle/<your version>/client/lib/
注意-对于64位安装,路径为:
/usr/lib/oracle/<your version>/client64/lib/
通过运行以下命令来更新配置:
sudo ldconfig
尝试使用以下方法进行连接:
sqlplus username/password@//dbhost:1521/SID
要么:
sqlplus testuser/password
请注意,如果您安装了64位版本,则客户端称为sqlplus64
。
由于以下原因,外星人的东西不起作用:
Error: cannot open Name index using db5 - Permission denied (13)
因此,我采用了一个简单的解决方案:从Oracle(基本和sqlplus)下载zip文件,解压缩它们,然后将文件夹放在放置程序文件的位置(例如)。然后在设置变量后创建一个运行可执行文件的脚本,以便找到库:/usr/share
LD_LIBRARY_PATH
#!/bin/bash
DIR=/usr/share/instantclient_12_2 # <------- adjust this to the path you use
export LD_LIBRARY_PATH="$DIR"
"$DIR"/sqlplus "$@"
调用它sqlplus
,使其可执行(chmod 755 sqlplus
)并将其放入您的目录PATH
(例如/usr/bin/
),以便bash找到它。
像这样运行
sqlplus user/password@host:port/service
如果你得到
error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
使用安装库 sudo apt-get install libaio1
我认为此链接会有所帮助。它非常具有描述性。确保遵循所有步骤。仍然,如果您有任何问题,请随时发表评论。
当然,正确的安装来自上述官方软件包(请下载Instant Client Downloads),但是仅通过复制这些文件即可获得完整的sqlplus(可以在安装了oracle客户端的任何计算机上找到它),并且某些msb是可选的:
./sqlplus
./sqlplus/mesg
./sqlplus/mesg/sp1zhs.msb
./sqlplus/mesg/sp2zhs.msb
./sqlplus/mesg/sp2ptb.msb
./sqlplus/mesg/sp2us.msb
./sqlplus/mesg/sp1us.msb
./sqlplus/mesg/sp1ptb.msb
./sqlplus/mesg/cpyja.msb
./sqlplus/mesg/sp1ja.msb
./sqlplus/mesg/cpyus.msb
./sqlplus/mesg/cpyzhs.msb
./sqlplus/mesg/cpyptb.msb
./sqlplus/mesg/sp2ja.msb
./sqlplus/sqlplus
./README
./lib
./lib/libaio.so.1
./lib/libclntsh.so.11.1
./lib/libsqlplus.so
./lib/libnnz11.so
./lib/libociei.so
作为附加的依赖,我确实包括了libaio.so
-可以使用sudo apt-get install libaio1
因此,示例用法可以是:
cd <PATH_OF_FILES>
ORACLE_HOME=$PWD LD_LIBRARY_PATH=$PWD/lib ./sqlplus/sqlplus user/pw@server:PORT/
就像@Ketan Patel出色答案的附录一样:
这个简单的脚本与下载的rpm文件一起保留了进一步安装的过程:
#!/usr/bin/env sh
# /ubuntu//a/207145/585248
CURRDIR="$(pwd)";
cd $(dirname "${0}");
# Tools and dependencies:
sudo apt-get update
sudo apt-get install alien libaio1
# Oracle Packages:
echo "Installing instantclient-basic..."
sudo alien -i oracle-instantclient*-basic*.rpm
echo "Installing instantclient-sqlplus..."
sudo alien -i oracle-instantclient*-sqlplus*.rpm
echo "Installing instantclient-devel..."
sudo alien -i oracle-instantclient*-devel*.rpm
echo "Configuring LD path..."
# LD config:
echo /usr/lib/oracle/*/client64/lib \
| sort -V \
| tail -n 1 \
| sudo tee /etc/ld.so.conf.d/oracle.conf \
;
sudo ldconfig
cd "${CURRDIR}"
echo "DONE!!";
注意:它至少在Ubuntu中安装
libaio1
了libaio的名称(我也认为在Debian中)。其他发行版可能需要将此软件包名称调整为“ libaio”或相应的软件包名称。
编辑:这是带有readline包装的高级版本(此帖子的 Credists ):
#!/usr/bin/env sh
# /ubuntu//a/207145/585248
CURRDIR="$(pwd)";
cd $(dirname "${0}");
# Tools and dependencies:
sudo apt-get update
sudo apt-get install alien libaio1 rlwrap
# Oracle Packages:
echo "Installing instantclient-basic..."
sudo alien -i oracle-instantclient*-basic*.rpm
echo "Installing instantclient-sqlplus..."
sudo alien -i oracle-instantclient*-sqlplus*.rpm
echo "Installing instantclient-devel..."
sudo alien -i oracle-instantclient*-devel*.rpm
# LD config:
echo "Configuring LD path..."
echo /usr/lib/oracle/*/client64/lib \
| sort -V \
| tail -n 1 \
| sudo tee /etc/ld.so.conf.d/oracle.conf \
;
sudo ldconfig
# Readline wrapping:
echo "Configuring readline wrapping..."
echo "WARNING: You need to manually execute this command or re-read /etc/profile"
echo "if you want readline wrapped 'sqlplus' alias to work in current session".
(cat | sudo tee /etc/profile.d/sqlplus_rlwrap.sh) <<!EOF
alias sqlplus="rlwrap -i -f ~/.sqlplus_history -H ~/.sqlplus_history -s 30000 sqlplus64"
!EOF
touch ~/.sqlplus_history
cd "${CURRDIR}"
echo "DONE!!";
它仍然是甲骨文,但至少使痛苦更加可忍...
sudo alien -i