溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Linux監(jiān)聽開啟后無服務怎么辦

發(fā)布時間:2022-01-17 16:54:33 來源:億速云 閱讀:159 作者:iii 欄目:建站服務器

這篇文章主要介紹“Linux監(jiān)聽開啟后無服務怎么辦”,在日常操作中,相信很多人在Linux監(jiān)聽開啟后無服務怎么辦問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Linux監(jiān)聽開啟后無服務怎么辦”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

報錯信息:
[oracle@hp2 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-OCT-2017 00:21:31

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.8.12)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                17-OCT-2017 19:45:26
Uptime                    0 days 4 hr. 36 min. 5 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /app1/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /app1/oracle/diag/tnslsnr/hp2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.8.12)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully


2種方法解決:

一、手工注冊,每次重啟監(jiān)聽都需要手工注冊:

SQL> alter system register;

System altered.

二、修改 listener.ora,一勞永逸解決問題

在LISTENER里添加內容:

SID_LIST_LISTENER =

(SID_LIST =

  (SID_DESC =

  (GLOBAL_DBNAME = orcl)

  (SID_NAME = orcl)

  )

)

另,感覺這是個bug,google下·看到:http://www.askmaclean.com/archives/11gr2-rac-add-listener-static-register.html

原來在11gr2新建和修改監(jiān)聽后,不會自動靜態(tài)注冊,需要退出netca 界面,啟動netmgr界面,為監(jiān)聽加入靜態(tài)注冊的信息:

點選方才創(chuàng)建的監(jiān)聽器,選擇Database Services菜單

填入Global Database Name和本地實例的SID信息,并確認ORACLE HOME Directory(應是Grid Infrastructure的Home目錄)正確后點選Save Network Configuration。

重啟監(jiān)聽即可
重新啟動后狀態(tài):
[oracle@hp admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-OCT-2017 00:04:50

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Starting /app1/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /app1/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /app1/oracle/diag/tnslsnr/hp/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.8.11)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.8.11)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                18-OCT-2017 00:04:50
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /app1/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /app1/oracle/diag/tnslsnr/hp/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.8.11)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "SUNTX" has 1 instance(s).
  Instance "SUNTX", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully


監(jiān)聽狀態(tài)解析
在運行l(wèi)snrctl命令的status時,常會看到如下返回值:

服務“test”包含1個例程。

   例程"mydata",狀態(tài) UNKOWN,包含此服務的一個處理程序。。。

服務"a"包含1個例程。

   例程"mydata",狀態(tài) READY,包含此服務的一個處理程序。。。

這里的,狀態(tài)UNKOWN即表明為靜態(tài)注冊(手動填寫參數(shù));

狀態(tài)為READY的記錄,表明為動態(tài)注冊(listener.ora參數(shù)由PMON進程自動從參數(shù)文件獲?。?;

一、靜態(tài)注冊

監(jiān)聽配置中,數(shù)據(jù)庫服務中的全局數(shù)據(jù)庫名,可以寫任意內容,與數(shù)據(jù)庫無關,只要保證SID正確即可連上數(shù)據(jù)庫。

由于靜態(tài)注冊,參數(shù)是手動靜態(tài)添加,與數(shù)據(jù)庫無關。數(shù)據(jù)庫無法確認監(jiān)聽是否正確配置。因此,lsnrctl中的status顯示狀態(tài)為unkown。即不保證能連通數(shù)據(jù)庫。

注意:靜態(tài)注冊監(jiān)聽,客戶端在配置tnsnames.ora服務命名時,“(Oracle 8i或更高版本)服務名”里填寫內容要與服務端靜態(tài)注冊監(jiān)聽器時的全局數(shù)據(jù)庫名一致。否則,無法連通。

lsnrctl中顯示如下

服務“test”包含1個例程。

   例程“mydata”,狀態(tài)UNKOWN,包含此服務的一個處理程序。。。

test即從監(jiān)聽配置過程,數(shù)據(jù)庫服務中的“全局數(shù)據(jù)庫名”讀到的值(即配置文件中GLOBAL_DBNAME的值),“mydata”是從監(jiān)聽配置中,數(shù)據(jù)庫服務中SID讀到的值(即SID_NAME的值)。

SID_LIST_LISTENER =

 (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = test)

      (ORACLE_HOME = /orahome/oracle/product/10.2.0/db_1)

      (SID_NAME = mydata)

    )

  )

客戶端在配置tnsname時,服務名(SERVICE_NAME)即為test。否則,連接不到數(shù)據(jù)庫。

ABC =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVICE_NAME =
test)

    )

  )

這里的ABC,為服務命名??梢詾槿我庵?,在客戶端連接服務器時,填寫的主機字符串,即為此服務命名ABC。

二、動態(tài)注冊

1、缺省的動態(tài)注冊

pmon在數(shù)據(jù)庫啟動到mount或open時,動態(tài)從參數(shù)文件中讀取service_names值。service_names可以為多個值。

service_names缺省為dbca建立數(shù)據(jù)庫時的全局數(shù)據(jù)庫名。

設置參數(shù)service_names為'a,b,c',命令如下:

alter system set service_names='a,b,c';

則:

lsnrctl狀態(tài)如下:

服務“test”包含1個例程。

   例程"mydata",狀態(tài) UNKOWN,包含此服務的一個處理程序。。。

服務"a"包含1個例程。

   例程"mydata",狀態(tài) READY,包含此服務的一個處理程序。。。

服務"b"包含1個例程。

   例程"mydata",狀態(tài) READY,包含此服務的一個處理程序。。。

服務"c"包含1個例程。

   例程"mydata",狀態(tài) READY,包含此服務的一個處理程序。。。

服務 "mydata.ccddt.cn" 包含一個例程。

   例程"mydata",狀態(tài) READY, 包含此服務的一個處理程序。。。

以上服務名a, b, c, mydata.ccddt.cn都為READY,為動態(tài)注冊。

這里多了最后一條"mydata.ccddt.cn",是PMON缺省動態(tài)注冊到監(jiān)聽器內的。

注意:不管參數(shù)service_names為何值,pmon都會自動以全局數(shù)據(jù)庫名(這里為mydata.ccddt.cn)為服務名,動態(tài)注冊一個監(jiān)聽。

缺省情況下,若啟用動態(tài)注冊監(jiān)聽,端口號必須為1521。若啟用其他端口的動態(tài)監(jiān)聽注冊,必須要做相關配置。

通過查看v$session,狀態(tài)為SYS$USERS的連接為通過靜態(tài)注冊監(jiān)聽連接到服務器。

2、自定義端口的動態(tài)監(jiān)聽注冊

若要啟用非默認端口1521的動態(tài)監(jiān)聽注冊,缺省狀態(tài),Oracle不會進行動態(tài)注冊。要啟用動態(tài)注冊,必須設置local_listener參數(shù)。并在服務端配置tnsnames.ora指定監(jiān)聽參數(shù),或者直接通過修改local_listener指定監(jiān)聽參數(shù)。步驟如下:

1)服務端

netmgr,配置監(jiān)聽程序,監(jiān)聽端口為1525(非默認端口)

Linux監(jiān)聽開啟后無服務怎么辦

保存配置

        2)、指定監(jiān)聽參數(shù)

     (1)法1:直接通過修改local_listener參數(shù)指定

    SQL>alter system set LOCAL_LISTENER='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.23)(PORT=1525))';
    System altered

  SQL>alter system register

  System altered

             (2)法2:

在Oracle服務器端建立$ORACLE_HOME/network/admin/tnsnames.ora。解析文件,位置并填入如下內容

mytest =

(DESCRIPTION =
    (ADDRESS_LIST =
        (ADDRESS=(PROTOCOL=TCP)(HOST = 192.168.1.23)(PORT = 1525))
    )
)


這里的mytest也可以根據(jù)自己需要,修改為其他字符串。如a或b等。

設置參數(shù),指定通過tnsnames.ora內的信息指定監(jiān)聽參數(shù)

SQL>alter system set local_listener=mytest;

System altered

SQL>alter system register;

3、查看監(jiān)聽器狀態(tài)

LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.23)(PORT=1525)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                15-MAR-2011 10:43:47
Uptime                    0 days 0 hr. 0 min. 56 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /orahome/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /orahome/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oraserver)(PORT=1525)))
Services Summary...
Service "a" has 1 instance(s).
  Instance "mydata", status READY, has 1 handler(s) for this service...
Service "b" has 1 instance(s).
  Instance "mydata", status READY, has 1 handler(s) for this service...
Service "c" has 1 instance(s).
  Instance "mydata", status READY, has 1 handler(s) for this service...
Service "mydata" has 1 instance(s).
  Instance "mydata", status READY, has 1 handler(s) for this service...
Service "mydataXDB" has 1 instance(s).
  Instance "mydata", status READY, has 1 handler(s) for this service...
Service "mydata_XPT" has 1 instance(s).
  Instance "mydata", status READY, has 1 handler(s) for this service...
The command completed successfully

到此,關于“Linux監(jiān)聽開啟后無服務怎么辦”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注億速云網站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經查實,將立刻刪除涉嫌侵權內容。

AI