Oracle

偵聽器不支持任何服務 - oracle linux 7 上的 2 個數據庫

  • January 25, 2021

我在 linux oracle 7.9 上執行兩個 12c R2 數據庫我已經安裝了第一個數據庫 (CDB) 和一個偵聽器,它們都執行良好。然後,我在同一系統上安裝了另一個 12c R2 數據庫 (CDB2)。

這些是我的例子:

CDB
CDB2

問題是,如果我只想啟動第二個數據庫(CDB2),然後是監聽器,執行時lsnrctl status LISTENER會說:The listener supports no services

如果我在那之後啟動第一個數據庫(CDB),聽眾會說它支持這兩種服務(CDB 和 CDB2)。

所以,如果我也啟動 CDB,它只支持 CDB2。如果我只啟動 CDB2,它不支持它。

但是,在我啟動 CDB 並且監聽器開始支持這兩種服務之後,如果我關閉 CDB,監聽器仍然支持 CDB2。

所以,作為一個總結:如果我啟動 CDB2 然後監聽器,監聽器不支持任何服務。如果我之後啟動 CDB,則偵聽器支持兩個 dbs。如果我之後關閉 CDB,監聽器只支持我首先想要的 CDB2。

第一步:

[oracle@oel7 ~]$ ps -ef | grep pmon
oracle    4350  2463  0 20:56 pts/0    00:00:00 grep --color=auto pmon
[oracle@oel7 ~]$ ps -ef | grep tns
root        37     2  0 20:37 ?        00:00:00 [netns]
oracle    4458  2463  0 20:57 pts/0    00:00:00 grep --color=auto tns
[oracle@oel7 ~]$

啟動 CDB2 和監聽器:

[oracle@oel7 ~]$ ps -ef | grep pmon
oracle    2547     1  0 20:41 ?        00:00:00 ora_pmon_CDB2
oracle    4498  2463  0 20:58 pts/0    00:00:00 grep --color=auto pmon
[oracle@oel7 ~]$
[oracle@oel7 ~]$ ps -ef | grep tns
root        37     2  0 20:37 ?        00:00:00 [netns]
oracle    4537     1  0 20:58 ?        00:00:00 /u01/app/oracle/product/12.2.0/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle    4563  2463  0 20:59 pts/0    00:00:00 grep --color=auto tns
[oracle@oel7 ~]$

STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                21-JAN-2021 20:42:01
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/               listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/oel7/listener/alert/log.x               ml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oel7.localdomain)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

啟動 CDB 後:

[oracle@oel7 dbhome_1]$ ps -ef | grep pmon
oracle    2351     1  0 20:41 ?        00:00:00 ora_pmon_CDB
oracle    2547     1  0 20:41 ?        00:00:00 ora_pmon_CDB2
oracle    4814  2463  0 21:02 pts/0    00:00:00 grep --color=auto pmon
[oracle@oel7 dbhome_1]$

STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                21-JAN-2021 20:42:01
Uptime                    0 days 0 hr. 0 min. 49 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/               listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/oel7/listener/alert/log.x               ml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oel7.localdomain)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=oel7.localdomain)(PORT=5500))(Secur               ity=(my_wallet_directory=/u01/app/oracle/admin/CDB/xdb_wallet))(Presentation=HTT               P)(Session=RAW))
Services Summary...
Service "CDB.localdomain" has 1 instance(s).
 Instance "CDB", status READY, has 1 handler(s) for this service...
Service "CDB2" has 1 instance(s).
 Instance "CDB2", status READY, has 1 handler(s) for this service...
Service "CDB2XDB" has 1 instance(s).
 Instance "CDB2", status READY, has 1 handler(s) for this service...
Service "CDBXDB.localdomain" has 1 instance(s).
 Instance "CDB", status READY, has 1 handler(s) for this service...
Service "b8c025790af43eafe0536f64a8c04644.localdomain" has 1 instance(s).
 Instance "CDB", status READY, has 1 handler(s) for this service...
Service "cdbpdb1.localdomain" has 1 instance(s).
 Instance "CDB", status READY, has 1 handler(s) for this service...
The command completed successfully

在 CDB 關閉且僅 CDB2 執行後:

STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                21-JAN-2021 20:58:52
Uptime                    0 days 0 hr. 4 min. 55 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/oel7/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oel7.localdomain)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "CDB2" has 1 instance(s).
 Instance "CDB2", status READY, has 1 handler(s) for this service...
Service "CDB2XDB" has 1 instance(s).
 Instance "CDB2", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@oel7 dbhome_1]$

而且,即使我停止並重新啟動偵聽器(僅執行 CDB2 - 關閉 CDB),它也可以正常工作:

STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                21-JAN-2021 20:58:52
Uptime                    0 days 0 hr. 4 min. 55 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/oel7/listener/alert/log.xml
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oel7.localdomain)(PORT=1521)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "CDB2" has 1 instance(s).
 Instance "CDB2", status READY, has 1 handler(s) for this service...
Service "CDB2XDB" has 1 instance(s).
 Instance "CDB2", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@oel7 dbhome_1]$

兩個數據庫在以下位置具有相同的 Oracle Home:/u01/app/oracle/product/12.2.0/dbhome_1

網路文件:

[oracle@oel7 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
 (DESCRIPTION_LIST =
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521))
     (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
   )
 )

[oracle@oel7 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
  
LISTENER_CDB =
 (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521))
   
CDB2 =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521))
   (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = CDB2)
   )
 )

CDB =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521))
   (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = CDB.localdomain)
   )
 )

問題是什麼?為什麼監聽器第一次不支持第二個數據庫(CDB2)而我必須啟動第一個數據庫(CDB)才能支持它們?

謝謝。

完全正常的行為。如果數據庫已經在執行並且之後啟動了偵聽器,則數據庫不會立即在偵聽器中註冊,可能需要幾秒鐘直到數據庫註冊自己。

給它一些時間。如果您不想等待,請登錄 CDB2 並通過以下方式強制註冊:

alter system register; 

當你這樣做時,它也可能會自動發生。

oracle 中稱為 pmon(程序管理器)的主數據庫程序也負責每 60 秒自動向偵聽器註冊服務。

你也可以手動完成

   alter system register;

但總的來說,建議在 listener.ora 文件中為每個數據庫定義兩個單獨的偵聽器。你只有一個。同樣,您在 listener.ora 中定義的每個偵聽器也必須在數據庫伺服器上的 tnsnames.ora 文件中定義,以便數據庫中的 pmon 能夠辨識它。你只註冊了 LISTENER。

嘗試讓您的 listener.ora 文件類似於

     LISTENER_CDB1 =
(DESCRIPTION_LIST =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)) 
   (ADDRESS = (PROTOCOL = TCP)(HOST = myserver.example.com)(PORT = 1521))
 )
)
     LISTENER_CDB2 =
(DESCRIPTION_LIST =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)) 
   (ADDRESS = (PROTOCOL = TCP)(HOST = myserver.example.com)(PORT = 1521))
 )
)

和你的 tnsnames.ora 文件是這樣的:

       LISTENER_CDB1 =
 (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521))
       LISTENER_CDB2 =
 (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521))

CDB2 =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521))
   (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = CDB2)
   )
 )

CDB =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = oel7.localdomain)(PORT = 1521))
   (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = CDB)
   )
 )

您可以並且應該使用 lsnrctl 管理單個偵聽器。例子:

   lsnrctl LISTENER_CDB1 START   

或者

   lsnrctl LISTENER_CDB1 STATUS
    
      
       
   
   
   

引用自:https://dba.stackexchange.com/questions/283809