Ubuntu安装Oracleclient远程连接数据库
平时Oracle数据库都安装在本地或者WindowsServer上进行使用,但因为工作需要,领导要求在虚拟机中安装Ubuntu来连接Windows本地安装的数据库,先将操作过程和遇到的问题进行梳理总结
1.先下载oracle的linux版的客户端连接程序包(下载需注册Oracle账户,免费注册下载)
oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm 基本的动态库(oci,bocci,jdbc-oci)
oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm 客户端sqlplus安装包
(至于sdk,jdbc,devel根据需求按安装)
2.安装下载的rpm包(在这里踩很多坑,很无语啊!!!)
坑1.正常使用rpm命令进行安装
rpm -i oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
直接报错:
error:Failed dependencies:
libaio is needed by rpm -i oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
直译:安装rpm -i oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm需要libaio的依赖,就是缺少libaio依赖,无法安装
一波操作走你:
坑1.1 没有libaio依赖,那就装一呗,
命令:sudo apt-get install libaio
直接报错: Unable to locate package libaio
坑1.2 无法定位libaio的程序包,百度一下:需要换一个repository,源不好,更换完源,需要sudo apt-get update
update完之后,再进行安装sudo apt-get install libaio依然报错:E: Unable to locate package libaio
(期间在/etc/apt/source.list 添加过ununtu官方源,aliyun的源,中国科技大的源,163的源)
!!!!深呼吸,电脑没错,再次尝试rmp安装:rpm -i oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
理所当然报错:但这次完整的信息都读了一遍:
报错信息:
rpm:RPM should not be used directly install RPM packages.use Alien instead!
rpm:However assuming you know what are you doing .....
error:Failed dependencies:
libaio is needed by rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
百度:alien:“alien”可以在rpm\dpkg\slackware tgz\deb\slp 格式见进行转换
开始进入正轨:
sudo apt-get install alien 正常
dkpg -i oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm 正常
dkpg -i oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm 正常
3. 默认安装路径为(/usr/lib/oracle/11.2/client64)
新建配置文件文件夹:
mkdir -p /usr/lib/oracle/11.2/client64/network/admin
更改文件的权限
chown -R python:python /usr/lib/oracle/11.2/client64/network/admin
4.添加连接数据库所需要的TNS配置文件
cd /usr/lib/oracle/11.2/client64/network/admin/
vim tnsnames.ora(根据自己所要连接的oracle进行配置)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.169.80.18)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.168.80.6)
)
)
5.配置环境变量
vim /home/python/.bashrc
添加如下内容
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export TNS_ADMIN=$ORACLE_HOME/network/admin
export NLS_LANG='simplified chinese_china'.ZHS16GBK
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
生效环境变量:source /home/python/.bashrc
6.测试:
echo $ORACLE_HOEM 正常
sqlplus sgcc/root@ORCL 正常
posted on 2018-06-01 14:56 mywifelidan 阅读(4614) 评论(1) 编辑 收藏 举报