Oracle數(shù)據(jù)庫(kù)的監(jiān)聽(tīng)器是負(fù)責(zé)接收客戶(hù)端請(qǐng)求并將請(qǐng)求傳遞給數(shù)據(jù)庫(kù)實(shí)例的一個(gè)服務(wù)程序,它可以監(jiān)聽(tīng)多個(gè)端口并支持多個(gè)協(xié)議。
在Oracle數(shù)據(jù)庫(kù)中,監(jiān)聽(tīng)器的端口可以在多個(gè)地方進(jìn)行配置,比如在dbconfig中或是在listener.ora文件中,但是,它的位置很關(guān)鍵,它決定了監(jiān)聽(tīng)器能夠監(jiān)聽(tīng)到哪些客戶(hù)端請(qǐng)求。舉個(gè)例子,如果監(jiān)聽(tīng)器所在的主機(jī)位置被限制只能在公司內(nèi)網(wǎng)中被訪(fǎng)問(wèn),那么外部的客戶(hù)端就無(wú)法訪(fǎng)問(wèn)到該Oracle數(shù)據(jù)庫(kù)。
以下是一些常見(jiàn)的Oracle監(jiān)聽(tīng)器位置:
#1.本地監(jiān)聽(tīng)器位置 LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) ) ) #2.主機(jī)本地監(jiān)聽(tīng)器位置 LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = yourHostname)(PORT = 1521)) ) ) #3.遠(yuǎn)程監(jiān)聽(tīng)器位置 LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = yourHostname)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = yourRemoteHostname)(PORT = 1521)) ) ) #4.帶有多個(gè)網(wǎng)絡(luò)接口的服務(wù)器監(jiān)聽(tīng)器位置 LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC)) (ADDRESS = (PROTOCOL = TCP)(HOST = yourHostname)(PORT = 1521)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC)) (ADDRESS = (PROTOCOL = TCP)(HOST = yourOtherHostname)(PORT = 1521)) ) )
本地監(jiān)聽(tīng)器通常運(yùn)行在一個(gè)機(jī)器上,它用來(lái)監(jiān)聽(tīng)指向自身的Oracle數(shù)據(jù)庫(kù)。如果Oracle數(shù)據(jù)庫(kù)安裝在你的機(jī)器上,那么你可以使用本地監(jiān)聽(tīng)器直接連接到它,如第1個(gè)監(jiān)聽(tīng)器位置所示。
如果Oracle數(shù)據(jù)庫(kù)安裝在一臺(tái)使用固定IP地址的遠(yuǎn)程主機(jī)上,那么你可以使用主機(jī)本地監(jiān)聽(tīng)器連接它,如第2個(gè)監(jiān)聽(tīng)器位置所示。
如果Oracle數(shù)據(jù)庫(kù)架構(gòu)中存在多個(gè)主機(jī),那么你可以使用遠(yuǎn)程監(jiān)聽(tīng)器連接它,它可以監(jiān)聽(tīng)數(shù)據(jù)庫(kù)所在的主機(jī)以及其他主機(jī),如第3個(gè)監(jiān)聽(tīng)器位置所示。
如果Oracle數(shù)據(jù)庫(kù)安裝在一個(gè)使用多個(gè)網(wǎng)絡(luò)接口的服務(wù)器上,那么你可以使用帶有多個(gè)網(wǎng)絡(luò)接口的服務(wù)器監(jiān)聽(tīng)器連接它,如第4個(gè)監(jiān)聽(tīng)器位置所示。
總之,Oracle監(jiān)聽(tīng)器位置的選擇應(yīng)該基于你的Oracle數(shù)據(jù)庫(kù)架構(gòu)所需要的功能,例如,將監(jiān)聽(tīng)器位置配置為本地監(jiān)聽(tīng)器可以減少網(wǎng)絡(luò)延遲。