[20211020]奇怪lsnrctl status顯示.txt

lfree發表於2021-10-20

[20211020]奇怪lsnrctl status顯示.txt

--//這幾天一直在收尾同事配置dg的問題。生產系統安全問題比較複雜,透過測試環境演示該問題。

SYS@book> alter system register;
System altered.

$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 20-OCT-2021 10:10:00
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                20-OCT-2021 10:09:07
Uptime                    0 days 0 hr. 0 min. 52 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/11.2.0.4/dbhome_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "booK" has 1 instance(s).
  Instance "book", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

SYS@book> alter system register;
System altered.

--//lsnrctl status 狀態僅僅顯示一個booK服務,而且是靜態註冊的。
--//我在listener.ora配置如下:
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SDU = 32767)
      (GLOBAL_DBNAME = booK)
      (ARGV0 = myapp0)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/dbhome_1)
      (SID_NAME = book)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

--//簡單說明一下ARGV0 = myapp0,GLOBAL_DBNAME = booK(大小寫混用也是測試目的),以前的測試我都忘了。
$ rlsql scott/book@127.0.0.1:1521/boOK
SCOTT@127.0.0.1:1521/boOK> @ spid
       SID    SERIAL# PROCESS                  SERVER    SPID       PID  P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
        44       4465 42539                    DEDICATED 42541       27        177 alter system kill session '44,4465' immediate;

sqlplus scott/book@192.168.100.78:1521/Book
sqlplus scott/book
--//獲取程式號略。

$ ps -fp 42541,42556,42549
UID        PID  PPID  C STIME TTY          TIME CMD
oracle   42541     1  0 10:15 ?        00:00:00 myapp0 (DESCRIPTION=(LOCAL=NO)(SDU=32767))
oracle   42549     1  0 10:17 ?        00:00:00 myapp0 (DESCRIPTION=(LOCAL=NO)(SDU=32767))
oracle   42556 42555  0 10:17 ?        00:00:00 oraclebook (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
--//相當於這時無論我本地或者遠端透過網路登入,使用的都是靜態服務。裡面的ARGV0 = myapp0相當於改了引數0.

SYS@book> show parameter dispatchers
NAME        TYPE   VALUE
----------- ------ ---------------------------------
dispatchers string (PROTOCOL=TCP) (SERVICE=bookXDB)

--//同時共享服務名也沒有顯示。

# netstat -tnlp | grep -v sshd
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:1521                0.0.0.0:*                   LISTEN      42335/tnslsnr
tcp        0      0 0.0.0.0:514                 0.0.0.0:*                   LISTEN      9290/rsyslogd
tcp        0      0 0.0.0.0:963                 0.0.0.0:*                   LISTEN      4173/rpc.statd
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      4136/portmap
tcp        0      0 :::11794                    :::*                        LISTEN      57352/ora_d000_book
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tcp        0      0 :::514                      :::*                        LISTEN      9290/rsyslogd
--//ora_d000_book存在。
--//後面檢查發現在/etc/hostse檔案中沒有配置主機名。

# grep 78  /etc/hosts
# 192.168.100.78   xxxxdg4.com xxxxdg4

--//取消註解後
SCOTT@127.0.0.1:1521/boOK> alter system register;
System altered.

$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 20-OCT-2021 10:31:04
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                20-OCT-2021 10:28:22
Uptime                    0 days 0 hr. 2 min. 41 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/11.2.0.4/dbhome_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "BOOKSHARE" has 1 instance(s).
  Instance "book", status READY, has 1 handler(s) for this service...
Service "booK" has 2 instance(s).
  Instance "book", status UNKNOWN, has 1 handler(s) for this service...
  Instance "book", status READY, has 1 handler(s) for this service...
Service "bookXDB" has 1 instance(s).
  Instance "book", status READY, has 1 handler(s) for this service...
The command completed successfully

--//問題解決。很奇怪新版本使用centos 7.9 , 新的hostnamectl命令並不會修改/etc/hosts檔案。

$ sqlplus scott/book@192.168.100.78:1521/book
       SID    SERIAL# PROCESS                  SERVER    SPID                     PID  P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
        30       2327 6268:4120                DEDICATED 43112                     26         76 alter system kill session '30,2327' immediate;

# ps -fp 43112
UID        PID  PPID  C STIME TTY          TIME CMD
oracle   43112     1  0 11:13 ?        00:00:00 oraclebook (LOCAL=NO)
--//可以發現在動態,靜態服務註冊的情況下,優先使用註冊的動態服務名。怎麼能在這種情況下使用靜態的服務名呢?

$ sqlplus  scott/book@"(DESCRIPTION=(ARGV0=xxxxxx)(ENABLE=BROKEN)(CONNECT_DATA=(ARGV0=yyyyy)(SERVICE_NAME=book)(SERVER = DEDICATED))(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.78)(PORT=1521)))"
SCOTT@book> @ spid
       SID    SERIAL# PROCESS                  SERVER    SPID                     PID  P_SERIAL# C50
---------- ---------- ------------------------ --------- -------------------- ------- ---------- --------------------------------------------------
        30       2329 4108:7656                DEDICATED 43120                     26         77 alter system kill session '30,2329' immediate;

# ps -fp 43120
UID        PID  PPID  C STIME TTY          TIME CMD
oracle   43120     1  0 11:14 ?        00:00:00 oraclebook (LOCAL=NO)
        
--//不行,放棄!!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2838378/,如需轉載,請註明出處,否則將追究法律責任。

相關文章