伺服器:Windows Server 2008

Oracle資料庫版本:Oracle11g

本機系統:Winows 7專業版

虛擬機器:VMware Workstation

虛擬機器系統:CentOs-6.2

step0: 軟體下載

分別下載三個檔案:

或者

step1: 建立3個客戶端安裝目錄

[[email protected] ~]# mkdir -p /opt/oracle/lib

[[email protected] ~]# mkdir -p /opt/oracle/sdk

[[email protected] ~]# mkdir -p /opt/oracle/network/admin

注:建立三個客戶端的安裝目錄,這三個目錄可以自定義,但配置環境變數時,需要一致

step2: 檔案解壓

[[email protected] Downloads]# unzip instantclient-sqlplus-linux.x64-11.2.0.3.0.zip

[[email protected] Downloads]# unzip instantclient-sqlplus-linux.x64-11.2.0.3.0.zip

(注1:這兩個檔案都會預設的解壓到同一個目錄instantclient_11_2下面。)

[[email protected] Downloads]# cp -Rf instantclient_11_2/* /opt/oracle/lib/  #將目錄下的所有檔案拷貝到/opt/oracle/lib/

[[email protected] Downloads]# unzip instantclient-sdk-linux.x64-11.2.0.3.0

(注2:這個檔案也會預設的解壓到同一個目錄instantclient_11_2下面,且解壓後的檔案都在sdk目錄下。)

[[email protected] instantclient_11_2]# cp -Rf sdk/*  /opt/oracle/sdk/  #將目錄下的所有檔案拷貝到/opt/oracle/sdk/

step3: 配置環境變數

 [[email protected] Downloads]vim /etc/profile  #注意,這是針對所有使用者的環境變數,如果你想侷限某使用者,只能配置使用者的配置檔案了。

末尾加入:

export ORACLE_HOME=/opt/oracle

      export LD_LIBRARY_PATH=/opt/oracle/lib

儲存並退出。然後,

[[email protected] tmp]# source /etc/profile         #使配置檔案立刻生效

[[email protected] tmp]# echo $ORACLE_HOME      #檢視一下配置的環境變數是否成功

 /opt/oracle  

step4: 配置監聽器和網路環境

因為本地沒有安裝oracle 資料庫,所以需要從安裝oracle 資料庫的目錄取三個檔案過來。一般位於Oracle資料庫服務端,路徑位於:

*:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN

三個檔名分別為:listener.orasqlnet.oratnsnames.ora

將其放置在:/opt/oracle/network/admin

[[email protected] admin]# pwd

/opt/oracle/network/admin

[[email protected] admin]# ls

  listener.ora  sqlnet.ora  tnsnames.ora       //就這三個檔案,放到這個目錄下

step5: 修改step4中的三個檔案

原檔案格式如下:

[[email protected] admin]#vim listener.ora  ###########  原檔案A

# listener.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = CLRExtProc)

      (ORACLE_HOME = E:\app\Administrator\product\11.2.0\dbhome_1)  

      (PROGRAM = extproc)

      (ENVS = "EXTPROC_DLLS=ONLY:E:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")

    )

  )

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

      (ADDRESS = (PROTOCOL = TCP)(HOST = WIN-V1FEBFA7UA0)(PORT = 1521))

    )

  )

ADR_BASE_LISTENER = E:\app\Administrator

[[email protected] admin]#vim sqlnet.ora         ###########  原檔案B

# sqlnet.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\network\admin\sqlnet.ora

# Generated by Oracle configuration tools.

# This file is actually generated by netca. But if customers choose to

# install "Software Only", this file wont exist and without the native

# authentication, they will not be able to connect to the database on NT.

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

[[email protected] admin]#vim tnsnames.ora          ###########  原檔案C

# tnsnames.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora

# Generated by Oracle configuration tools.

ORCL =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

修改後的檔案如下:

[[email protected] admin]#vim listener.ora     ###########  原檔案A

# listener.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = CLRExtProc)

      (ORACLE_HOME = \opt\oracle)    ## 改動1:改為了剛才配置的$ORACLE_HOME

      (PROGRAM = extproc)

    )                               ## 改動2:刪除的無關部分

  )

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

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

     #10.194.224.110  IP地址, 埠號:1521

    )

  )                                    ## 改動3:刪除的無關部分

[[email protected] admin]#vim sqlnet.ora         ###########  原檔案B(無需改動)

# sqlnet.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\network\admin\sqlnet.ora

# Generated by Oracle configuration tools.

# This file is actually generated by netca. But if customers choose to

# install "Software Only", this file wont exist and without the native

# authentication, they will not be able to connect to the database on NT.

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

[[email protected] admin]#vim tnsnames.ora          ###########  原檔案C

# tnsnames.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora

# Generated by Oracle configuration tools.

ORCL =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

 // 註釋:10.194.224.110  IP地址, 埠號:1521

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

                                   ## 改動4:以下語句到末尾,語句為新增。

EXTPROC_CONNECTION_DATA =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

    )

    (CONNECT_DATA =

      (SID = PLSExtProc)

      (PRESENTATION = RO)

    )

  )

step6:測試。

 [[email protected] lib]# ./sqlplus

SQL*Plus: Release 11.2.0.3.0 Production on Mon Dec 21 00:47:49 2015

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Enter user-name: yuanmin

Enter password:

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Oracle Label Security, OLAP, Data Mining,

Oracle Database Vault and Real Application Testing options……

呼叫成功!