Linux下ODBC for Oracle驅動的安裝

來源:互聯網
上載者:User

最近做一個項目,在RHEL 5下建立一個Oracle資料庫系統,用於儲存叢集的錄音資料,其中資料庫驅動用的是odbc,這裡簡單的記錄下安裝配置odbc的經過吧。

一、安裝ODBC

從www.unixodbc.org,下載了unixODBC-2.3.0.tar.gz,解壓之:tar zxvf unixODBC-2.3.0.tar.gz

在解壓出的檔案夾下,執行:./configure 然後make,接著make install。

鬱悶的是無論進入/usr/local/bin還是/usr/bin下都找不到ODBCConfig,不行就尋找下吧,find / -name "ODBCConfig",還是沒有。鬱悶,怎麼回事呢?google baidu之,有人說是沒裝gt包的緣故,好吧,先裝吧,下載unixODBC-gui-gtk-2.2.1-i386.rpm和unixODBC-gui-qt-2.2.1-i386.rpm,然後安裝,重新安裝unixODBC,結果還是找不到ODBCConfig,超級鬱悶了。

那是不是unixODBC的版本不對呢,於是從www.unixodbc.org下載了unixODBC-2.2.1.tar.gz,解壓配置make make install之,omg,終於在/usr/local/bin下找到了ODBCConfig。

二、配置ODBC for oracle

2.1安裝oracle instant client用戶端

在www.oracle.com下載oracle instant client的rpm安裝包,zip包也可以:

oracle-instanceclient11.2-basic*.rpm
oracle-instanceclient11.2-devel*.rpm
oracle-instanceclient11.2-odbc*.rpm
oracle-instanceclient11.2-sqlplus*.rpm

由於以前裝過instant client,所以強制安裝,注意順序:rpm --force -ivh *。

安裝的預設位置分別在/usr/share/oracle/11.2/client,/usr/include/oracle/11.2/client,/usr/lib/oracle/11.2/client下,

設定環境變數之前,在/usr/lib/oracle/11.2/client/lib下建立network/admin檔案夾,在此檔案夾下建立tnsnames.ora,其內容入下:

ORCL=

   (DESCRIPTION =

     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1521))

     (CONNECT_DATA =

        (SERVER = DEDICATED)

        (SERVICE_NAME = orcl)

     )

    )

設定環境變數:

#vi ~/.bashrc

在檔案後面加入:

export ORACLE_HOME=/usr/lib/oracle/11.2/client/lib

export ORACLE_SID=orcl

export TNS_ADMIN=$ORACLE_HOME/network/admin

export LD_LIBRARY_PATH=$ORACLE_HOME

export SQLPATH=$ORACLE_HOME

PATH=$PATH:$ORACLE_HOME

export PATH

立即生效#source ~/.bashrc

由於已經在本機上裝好了oracle server,下面測試下用戶端是否安裝成功:

#sqlplus /nolog

SQL>conn test/test@orcl

出現問題ora-12541,解決方案:

因為伺服器沒有開啟監聽,所以登入伺服器,

$lsnrctl start

然後再登:

#sqlplus /nolog

SQL>conn test/test@orcl

OK,instant client安裝成功。

2.2

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.