標籤:
在Ubuntu16.04下安裝oracle資料庫用戶端,使Django項目串連到Oracle資料庫
1.下載oracle用戶端安裝包:
進入官網http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html下載如下所需的三個包。
oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpmoracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpmoracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
2.使用alien安裝
下載alien(alien可以把rpm格式轉為dev格式進行rpm包的安裝):
sudo apt-get install alien
進行安裝
sudo alien -i oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpmsudo alien -i oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpmsudo alien -i oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
安裝所需要的庫:
sudo apt-get install libaio1
3.配置環境
①開啟/etc/ld.so.conf檔案
sudo gedit /etc/ld.so.conf
新增內容: /usr/lib/oracle/11.2/client64/lib/
執行/sbin/ldconfig命令,使其生效
開啟/etc/profile檔案
sudo gedit /etc/profile
②添加如下環境變數
export ORACLE_HOME=/usr/lib/oracle/11.2/client64export ORACLE_BASE=/usr/lib/oracle/11.2export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/libexport PATH=$PATH:$ORACLE_HOME/bin
執行命令source /etc/profile, 使其生效
4.Django串連oracle, 還需要庫cx_oracle.
在Django項目所用的虛擬環境下,安裝cx_oracle
pip install cx_Oracle-5.2.1
至此,Django可以成功串連oracle資料庫。
Ubuntu16.04下安裝oracle用戶端