Oracle 9i 下的共享服務(wù)器 Shared Server(8i 中的多線程服務(wù)器 MTS )主要用在 OLTP 業(yè)務(wù)中,服務(wù)器進(jìn)程每次處理業(yè)務(wù)只需很短的
Oracle 9i 下的共享服務(wù)器 Shared Server(8i 中的多線程服務(wù)器 MTS )主要用在 OLTP 業(yè)務(wù)中,服務(wù)器進(jìn)程每次處理業(yè)務(wù)只需很短的時(shí)間,大多在空閑狀態(tài),在這種情況下,可以用較少的資源,處理較多的用戶請(qǐng)求。
共享服務(wù)器的配置
1.設(shè)置 DISPATCHERS 參數(shù):
在 pfile 中添加:
*.DISPATCHERS='(PROTOCOL=TCP)(SERVICE=SKYSH)(DISPATCHERS=2)(PROTOCOL=IPC)(DISPATCHERS=1)'
以上方法啟動(dòng)之后,DISPATCHER 的端口是隨機(jī)分配的,如果要固定每個(gè) DISPATCHER 的端口,可以用一下方法:
使用不同端口:
*.DISPATCHERS='(ADDRESS=(PROTOCOL=TCP)(PORT=5000))(DISPATCHERS=1)','(ADDRESS=(PROTOCOL=TCP)(PORT=5001))(DISPATCHERS=1)'
使用相同端口:
*.dispatchers='(ADDRESS=(PROTOCOL=TCP)(PORT=5130))(SERVICE=SKYSHR)(DISPATCHERS=1)'
如果是 spfile 啟動(dòng),先用 create pfile from spfile 創(chuàng)建 pfile,修改好之后,再用 create spfile from pfile 創(chuàng)建 spfile。
注:雖然 DISPATCHERS 是動(dòng)態(tài)參數(shù),但只能用 alter system set DISPATCHERS 來(lái)臨時(shí)添加刪除 dispatcher,重啟之后又恢復(fù)原值,且不能使用 scope 參數(shù)。
其中,SERVICE=SKYSH 參數(shù)可以不指定,如果不指定,則需要指定 service_names 和 instance_name 初始參數(shù),當(dāng) instance 啟動(dòng)時(shí),PMON 會(huì)動(dòng)態(tài)將 SERVICE 或者 service_names 指定的值邦定到 LISTENER,并生成 dispatchers。
DISPATCHERS=2 如果不指定,那么默認(rèn)值是 1。
PROTOCOL:當(dāng)使用 Shared Server 連接時(shí),必須通過(guò) Oracle Net Services,即使客戶端和數(shù)據(jù)庫(kù)在同一臺(tái)機(jī)子上,如果在 Windows NT 上,dispatchers 只能使用 TCP/IP 協(xié)議。
2.設(shè)置客戶端 tnsnames.ora 文件:
SKY3 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.123)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = SKYSH.heysky.net)
(SERVER = SHARED)
)
)
其中,SERVICE_NAME = SKYSH.heysky.net 中的值必須是動(dòng)態(tài)邦定的 service_name.db_domain,否則會(huì)產(chǎn)生 ORA-12523 錯(cuò)誤:
ERROR:
ORA-12523: TNS:listener could not find instance appropriate for the client connection
使用共享服務(wù)器連接,必須指定 (SERVER = SHARED),如果不指定,則作為 DEDICATE 連接。
3.SHARED_SERVERS 參數(shù):
該參數(shù)指定當(dāng) instance 啟動(dòng)時(shí),初始生成的共享服務(wù)器進(jìn)程數(shù)量,如果要使用共享服務(wù)器,該值必須大于 0,否則將產(chǎn)生 ORA-12520 錯(cuò)誤:
ERROR:
ORA-12520: TNS:listener could not find available handler for requested type of server
通過(guò)動(dòng)態(tài)改變?cè)搮?shù),可以增加減少默認(rèn)的共享服務(wù)器進(jìn)程數(shù)量,或者在不停止數(shù)據(jù)庫(kù)的情況下禁止共享服務(wù)器。當(dāng)動(dòng)態(tài)將其設(shè)置為 0 時(shí),共享服務(wù)器進(jìn)程在完成所有工作,并空閑一段時(shí)間之后終止,可以通過(guò)查看 v$shared_server 動(dòng)態(tài)視圖來(lái)查看共享服務(wù)器的狀態(tài)。
4.其他一些相關(guān)參數(shù):
MAX_DISPATCHERS:最大 DISPATCHER 數(shù)量,默認(rèn)值是 5,如果 DISPATCHERS 中設(shè)置的所有 DISPATCHER 數(shù)量之和大于 5,那么 MAX_DISPATCHERS 等于這個(gè)和數(shù)。
MAX_SHARED_SERVERS:最大共享服務(wù)器進(jìn)程,當(dāng)初始分配的 SHARED_SERVERS 不夠時(shí),Oracle 會(huì)繼續(xù)生成共享服務(wù)器,直到這個(gè)最大值,當(dāng)空閑時(shí),Oracle 會(huì)終止空閑的進(jìn)程,直到 SHARED_SERVERS 中指定的值為止。
CIRCUITS:改值一般等于 SESSIONS 的數(shù)量。
SHARED_SERVER_SESSIONS:共享服務(wù)器連接所能用的最大 SESSION 值,一般可以設(shè)置為小于 CIRCUITS and SESSIONS -5 的值,以便給 DEDICATE 連接留下一定的 SESSION 數(shù)。
5.一些注意事項(xiàng):
當(dāng) sysdba 已 shared server 連接時(shí),不能執(zhí)行 start up、shut down 或者 recovery 命令,否則可能出現(xiàn)如下錯(cuò)誤:
ORA-00106: cannot startup/shutdown database when connected to a dispatcher
當(dāng)使用共享服務(wù)器的時(shí)候,需要設(shè)置 LARGE_POOL_SIZE 參數(shù),并且要足夠,因?yàn)椋?dāng)使用共享服務(wù)器的時(shí)候,本來(lái)在 PGA 中的 cursor state、User session data 信息會(huì)放到 LARGE POOL 中,如果 LARGE_POOL_SIZE 沒(méi)有設(shè)置,就會(huì)放到 SHARE POOL 這將會(huì)使 SHARE POOL 產(chǎn)生碎片,影響性能。
6.一些相關(guān)動(dòng)態(tài)視圖:
V$CIRCUIT
V$SHARED_SERVER
V$DISPATCHER
V$SHARED_SERVER_MONITOR
V$QUEUE
V$SESSION
例子:查看使用哪種方式連接數(shù)據(jù)庫(kù)
SQL> select sid from v$mystat where rownum=1;
SID
----------
9
SQL> select server from v$session
2 where sid=9;
SERVER
---------
SHARED
7.查看 listener 信息:
使用 Shared Server 時(shí),當(dāng) Instance 啟動(dòng)時(shí),PMON 會(huì)動(dòng)態(tài)將 service_names 參數(shù),或 DISPATCHERS 中的 SERVICE 參數(shù)設(shè)定的值邦定到 LISTENER,并為該 SERVICE 分配相應(yīng)的 DISPATCHER,這些信息可以通過(guò) LSNRCTL 命令來(lái)獲得:
C:\Documents and Settings\Administrator>lsnrctl
LSNRCTL for 32-bit Windows: Version 9.2.0.3.0 - Production on 17-MAY-2006 23:22:58
Copyright (c) 1991, 2002, Oracle Corporation. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=heysky)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 32-bit Windows: Version 9.2.0.3.0 - Produc
tion
Start Date 17-MAY-2006 21:41:12
Uptime 0 days 1 hr. 46 min. 13 sec
Trace Level off
Security OFF
SNMP OFF
Listener Parameter File E:\oracle\ora92\network\admin\listener.ora
Listener Log File E:\oracle\ora92\network\log\listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=heysky)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC0ipc)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "SKYSHARED.heysky.net" has 1 instance(s).
Instance "sky", status READY, has 4 handler(s) for this service...
Service "SKYTEST" has 1 instance(s).
Instance "SKY", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL> service
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=heysky)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
Service "SKYSHARED.heysky.net" has 1 instance(s).
Instance "sky", status READY, has 4 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
"D002" established:0 refused:0 current:0 max:1002 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=heysky)(PORT=2312))
"D001" established:0 refused:0 current:0 max:1002 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=heysky)(PORT=2311))
"D000" established:0 refused:0 current:0 max:1002 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=heysky)(PORT=2309))
Service "SKYTEST" has 1 instance(s).
Instance "SKY", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
The command completed successfully
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com