在CentOs6.x 安装Cx_oracle5.x
2014-04-01 10:48
295 查看
Setting up anything Oracle related is a huge pain. After hunting the web for info with minimal success, I have decided to create a small tutorial to walk through setting up cx_Oracle to connect to Oracle installations.
Prerequisites
If you do not have a Oracle.com account, you will unfortunately need to create one to be able to download anything. Once you have your account head to the OS Selection page and select the appropriate OS, in my case this will be Linux / AMD64. On the subsequent page you must download the basiclite package as well as the devel package. I chose the RPM files as I am running CentOS 6.x. If you want non-English application support you probably want to install the basic version instead of the basiclite, it has multilingual support built in. You may optionally want to install the sqlplus package to help with debugging and connection issues.Oracle Library Installation
I downloaded the RPM files so ill use the rpm command to install the packages as follows1 2 3 4 5 6 7 | [root@devel ~] # cd oracle_files [root@devel oracle_files]# rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm Preparing... ########################################### [100%] 1:oracle-instantclient11.########################################### [ 33%] 2:oracle-instantclient11.########################################### [ 67%] 3:oracle-instantclient11.########################################### [100%] [root@devel oracle_files]# |
1 | /usr/lib/oracle/11.2/client64/lib |
1 | [root@devel ~] # ldconfig |
1 2 3 4 5 6 | [root@devel ~]#PATH=$PATH:/usr/lib/oracle/11.2/client64/bin # place in ~/.bashrc for a permanent setup [root@devel ~]#sqlplus SQL*Plus: Release 11.2.0.3.0 Production on Mon Jun 11 16:57:40 2012 Copyright (c) 1982, 2011, Oracle. All rights reserved. |
Python Library Installation
With the oracle libraries installed we can now begin installing the python connector cx_Oracle. I will be building a rpm file from the source rpm. If you are not using CentOS, or don't want to build a rpm for whatever reason, then go ahead and grab the source tarball instead.Building and installing from source rpm:
1 2 3 4 5 6 7 8 | [root@devel ~]#rpm -ivh cx_Oracle-5.1.1-1.src.rpm 1:cx_Oracle ########################################### [100%] [root@devel ~]#cd ~/rpmbuild/SPECS [root@devel ~]#yum install rpm-build [root@devel ~]#ORACLE_HOME=/usr/lib/oracle/11.2/client64/ rpmbuild -ba cx_Oracle.spec [root@devel ~]#cd ../RPMS/x86_64 [root@devel ~]#rpm -ivh cx_Oracle-5.1.1-1.x86_64.rpm Preparing... ########################################### [100%] 1:cx_Oracle ########################################### [100%] |
1 2 3 4 | tar xvfz cx_Oracle.tar.gz cd cx_Oracle.tar.gz ORACLE_HOME=/usr/lib/oracle/11.2/client64/ python setup.py build ORACLE_HOME=/usr/lib/oracle/11.2/client64/ python setup.py install |
Verification
To easily test if the installation has succeded run the following 1 liner, if no errors occur then your installation went OK.1 | [root@devel x86_64]# python -c 'import cx_Oracle' |
相关文章推荐
- orcale 存储过程分页时间戳
- orcale存储过程(统计)
- oracle 由于impdp 引起的表统计信息被锁 ORA-20005: object statistics are locked
- Raysoft.Framework.DBUtility.OracleHelper
- 关于ORACLE RAC grid安装中的GNS配置说明
- ORACLE 检查数据库表中是否存在不规范字 段的语句参考.sql
- 能使 Oracle 索引失效的六大限制条件
- Oracle trunc()函数的用法
- oracle database link创建
- 隐式转换带来的麻烦
- oracle 10g CRS voting disk 管理
- oracle 10g RAC [恢复OCR]
- Oracle 创建LinkedServer(不积跬步,无以至千里)
- Oracle 语句优化
- 11g单机
- oracle 行转列 拼接
- Oracle中获取执行计划的几种方法分析
- Oracle 对行进行分组-group by、having
- Oracle 使用连接显示多个表中的数据
- oracle小贱