oracle共享伺服器配置彙總

靜以致遠√團團發表於2014-09-15

oracle共享伺服器配置彙總
對於共享伺服器的配置進行了彙總,也發現一些隱藏的錯誤
方式一,多種監聽(專用連線有專有連線的監聽,共享服務有共享服務的監聽)
方式二,一種監聽,專有和共享的都設定在一個監聽上
以下,liste1是專有伺服器連線方式,
   liste2是專門的共享伺服器連線方式
   liste3是專有服務和共享服務混合的方式
listener.ora 配置如下。
LISTE1 =
  (ADDRESS_LIST=
       (ADDRESS=(PROTOCOL=tcp)(HOST=oel1.oracle.com)(PORT=1521))
  )
SID_LIST_LISTE1=
   (SID_LIST=
       (SID_DESC=
          (GLOBAL_DBNAME=PROD.oracle.com)
          (SID_NAME=PROD)
          (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
        )
   )
LISTE2 =
  (ADDRESS_LIST=
       (ADDRESS=(PROTOCOL=tcp)(HOST=oel1.oracle.com)(PORT=1529))
  )
SID_LIST_LISTE2=
   (SID_LIST=
       (SID_DESC=
          (GLOBAL_DBNAME=PROD.oracle.com)
          (SID_NAME=PROD)
          (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
        )
   )
LISTE3 =
  (ADDRESS_LIST=
       (ADDRESS=(PROTOCOL=tcp)(HOST=oel1.oracle.com)(PORT=1520))
       (ADDRESS=(PROTOCOL=tcp)(HOST=oel1.oracle.com)(PORT=1530))
  )
SID_LIST_LISTE3=
   (SID_LIST=
       (SID_DESC=
          (GLOBAL_DBNAME=PROD.oracle.com)
          (SID_NAME=PROD)
          (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
        )
   )
tnsnames.ora 檔案配置如下
--配置了多個埠的專用服務連線
PROD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = tcp)(HOST = oel1.oracle.com)(PORT = 1520))
      (ADDRESS = (PROTOCOL = tcp)(HOST = oel1.oracle.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PROD.oracle.com)
    )
  )
--配置了共享服務連線
SPROD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = tcp)(HOST = oel1.oracle.com)(PORT = 1529))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PROD.oracle.com)
      (SERVER=SHARED)
    )
    )
--配置共享服務連線,驗證可以有多個共享伺服器並存
XPROD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = tcp)(HOST = oel1.oracle.com)(PORT = 1530))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PROD.oracle.com)
      (SERVER=SHARED)
    )
    )

--配置dispatcher
SQL> show parameter dispatch
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dispatchers                          string      (protocol=tcp)(service=PROD.or
                                                 acle.com)(dispatchers=2)
max_dispatchers                      integer     2
--根據需要來配置共享服務的引數。當然session,processes也需要相應的設定,如果值太小,共享服務連線就會很慢。
SQL> show parameter shared
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
hi_shared_memory_address             integer     0
max_shared_servers                   integer     2
shared_memory_address                integer     0
shared_pool_reserved_size            big integer 4404019
shared_pool_size                     big integer 0
shared_server_sessions               integer     50
shared_servers                       integer     1
--配置本地監聽
!!!如果配置的共享服務時非預設監聽Listeners,預設埠1521,則需要在local listener中註冊。
因為我建了兩個監聽liste2,liste3,所以把它們的埠資訊都註冊進去
alter system set local_listener='(address_list=(address=(protocol=tcp)(host=oel1.oracle.com)(port=1529))(address=(protocol=tcp)(host=oel1.oracle.com)(port=1530)))';
SQL> show parameter local_lis
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      (address_list=(address=(protoc
                                                 l=tcp)(host=oel1.oracle.com)(
                                                 port=1529))(address=(protocol=
                                                 tcp)(host=oel1.oracle.com)(por
                                                 t=1530)))
-啟動監聽
LSNRCTL> start liste1
LSNRCTL> start liste2

LSNRCTL> start liste3
 
--檢視共享服務是否配置正常。加粗的地方因為起了2個dispatcher,所以有2個D開頭的handlers.
LSNRCTL> service liste3
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=oel1.oracle.com)(PORT=1520))
Services Summary...
Service "PROD.oracle.com" has 2 instance(s).
  Instance "PROD", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
  Instance "PROD", status READY, has 3 handler(s) for this service...
    Handler(s):
      "D001" established:0 refused:0 current:0 max:972 state:ready
         DISPATCHER
         (ADDRESS=(PROTOCOL=tcp)(HOST=oel1.oracle.com)(PORT=46966))
      "D000" established:0 refused:0 current:0 max:972 state:ready
         DISPATCHER
         (ADDRESS=(PROTOCOL=tcp)(HOST=oel1.oracle.com)(PORT=57952))
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "PROD_XPT.oracle.com" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
The command completed successfully

--測試一把
[oracle@oel1 admin]$ sqlplus as sysdba
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
--判斷連線session是否接入了共享服務
[oracle@oel1 admin]$ sqlplus as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Oct 26 20:37:34 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select sid,server from v$session where sid=(select sid from v$mystat where rownum<=1);
       SID SERVER
---------- ---------
       160 SHARED

--使用埠連線來確認Liste1,liste3的兩個埠都可以正常訪問
[oracle@oel1 admin]$ sqlplus as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Oct 26 20:44:38 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

[oracle@oel1 admin]$ sqlplus as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Oct 26 20:45:12 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
--共享伺服器關閉失敗,所以在做data guard等場景時,不適合用共享伺服器模式
SQL> shut immediate
ORA-00106: cannot startup/shutdown database when connected to a dispatcher
SQL>
--復現共享服務繫結監聽錯誤的情況
--把本地監聽設定為空
SQL> alter system set local_listener='';
System altered.

LSNRCTL> service liste1
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=oel1.oracle.com)(PORT=1521))
Services Summary...
Service "PROD.oracle.com" has 2 instance(s).
  Instance "PROD", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:8 refused:0
         LOCAL SERVER
  Instance "PROD", status READY, has 3 handler(s) for this service...
    Handler(s):
      "D001" established:0 refused:0 current:0 max:972 state:ready
         DISPATCHER
         (ADDRESS=(PROTOCOL=tcp)(HOST=oel1.oracle.com)(PORT=46966))
      "D000" established:0 refused:0 current:0 max:972 state:ready
         DISPATCHER
         (ADDRESS=(PROTOCOL=tcp)(HOST=oel1.oracle.com)(PORT=57952))
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "PROD_XPT.oracle.com" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
The command completed successfully
LSNRCTL> service liste2
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=oel1.oracle.com)(PORT=1529))
Services Summary...
Service "PROD.oracle.com" has 1 instance(s).
  Instance "PROD", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully

--看起來好像也影響不大,後臺的共享服務都起來了。但是連庫連不上去。
[oracle@oel1 admin]$ sqlplus as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Oct 26 20:34:44 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
ERROR:
ORA-12523: TNS:listener could not find instance appropriate for the client
connection
所以本地監聽的配置是必須的。

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

相關文章