Listener.ora、tnsnames.ora這兩個檔案常常因為格式問題而不好用,我平時都是配置好了留個備份,以後都是拷貝過去改改就好了!嘿嘿~~~
因為平時使用linux的時候較多,所以有時還會遇到sqlnet.ora這個檔案有問題,直接給它刪了就好了~~
有時在windows下裝的oracle的listener服務就啟動不了,遇到這種情況,直接去oracle的bin目錄下面找到lsnrctl.exe那個檔案,直接給它運行,彈出來的視窗不要關閉,就可以了。
Oracle Server端Listener.ora檔案(一個instance):
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL=TCP)(HOST=hostname)(PORT=1521)) //主機名稱或IP及連接埠設定
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = database1) // database1為資料庫instance名
(ORACLE_HOME = /opt/oracle/product/10.1.0) //oracle安裝目錄,根據安裝情況更改
(PROGRAM = extproc)
)
)
Oracle Server端Listener.ora檔案(兩個instance):
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL=TCP)(HOST=hostname)(PORT=1521))
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = database1) // database1為資料庫instance1名
(ORACLE_HOME = /opt/oracle/product/10.1.0)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = database2) // database2為資料庫instance2名
(ORACLE_HOME = /opt/oracle/product/10.1.0)
(PROGRAM = extproc)
)
)
Oracle Server端監聽器啟動、停止、查看狀態命令:
$ lsnrctl start
$ lsnrctl stop
$ lsnrctl status
Oracle Client端Tnsnames.ora檔案:
ORALOCAL = //別名oralocal
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = database1) //database1為SID名
)
)
Oracle Client端檢查監聽器串連狀態用命令:
$ tnsping 別名
例如:用oracle使用者執行命令 $ tnsping oralocal