【sessions】Oracle中sessions和processes的大小關系(10g和11g不同)
1 BLOG文檔結構圖
2 前言部分
2.1 導讀和注意事項
各位技術愛好者,看完本文后,你可以掌握如下的技能,也可以學到一些其它你所不知道的知識,~O(∩_∩)O~:
① sessions和processes的大小設置,10g和11g不同(重點)
Tips:
① 本文在itpub(http://blog.itpub.net/26736162)、博客園(http://www.cnblogs.com/lhrbest)和微信公眾號(xiaomaimiaolhr)有同步更新。
② 文章中用到的所有代碼,相關軟件,相關資料請前往小麥苗的雲盤下載(http://blog.itpub.net/26736162/viewspace-1624453/)。
③ 若網頁文章代碼格式有錯亂,推薦使用360瀏覽器,也可以下載pdf格式的文檔來查看,pdf文檔下載地址:http://blog.itpub.net/26736162/viewspace-1624453/,另外itpub格式顯示有問題,也可以去博客園地址閱讀。
④ 本篇BLOG中命令的輸出部分需要特別關注的地方我都用灰色背景和粉紅色字體來表示,比如下邊的例子中,thread 1的最大歸檔日志號為33,thread 2的最大歸檔日志號為43是需要特別關注的地方;而命令一般使用黃色背景和紅色字體標注;對代碼或代碼輸出部分的注釋一般采用藍色字體表示。
List of Archived Logs in backup set 11 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- ------------------- ---------- --------- 1 32 1621589 2015-05-29 11:09:52 1625242 2015-05-29 11:15:48 1 33 1625242 2015-05-29 11:15:48 1625293 2015-05-29 11:15:58 2 42 1613951 2015-05-29 10:41:18 1625245 2015-05-29 11:15:49 2 43 1625245 2015-05-29 11:15:49 1625253 2015-05-29 11:15:53 [ZHLHRDB1:root]:/>lsvg -o T_XLHRD_APP1_vg rootvg [ZHLHRDB1:root]:/> 00:27:22 SQL> alter tablespace idxtbs read write; ====》2097152*512/1024/1024/1024=1G |
本文如有錯誤或不完善的地方請大家多多指正,ITPUB留言或QQ皆可,您的批評指正是我寫作的最大動力。
3 session與process的設置關系
session:指定了一個實例中允許的會話數,即能同時登錄到數據庫的並發用戶數。
process: 指定了一個實例在操作系統級別能同時運行的進程數,包括后台進程與服務器進程。
由上面的分析可知,一個后台進程可能同時對應對個會話,因此通常sessions的值是大於processes的值
從官方文檔我們可以查詢到以下的信息:
Property |
Oracle 10g |
Oracle 11g |
Parameter type |
Integer |
Integer |
Default value |
Derived: (1.1 * PROCESSES) + 5 |
Derived: (1.5 * PROCESSES) + 22 |
Modifiable |
No |
No |
Range of values |
1 to 231 |
1 to 216 (which is 1 to 65536) |
Basic |
Yes |
Yes |
SESSIONS specifies the maximum number of sessions that can be created in the system. Because every login requires a session, this parameter effectively determines the maximum number of concurrent users in the system. You should always set this parameter explicitly to a value equivalent to your estimate of the maximum number of concurrent users, plus the number of background processes, plus approximately 10% for recursive sessions.
Oracle uses the default value of this parameter as its minimum. Values between 1 and the default do not trigger errors, but Oracle ignores them and uses the default instead.
The default values of the ENQUEUE_RESOURCES and TRANSACTIONS parameters are derived from SESSIONS. Therefore, if you increase the value of SESSIONS, you should consider whether to adjust the values of ENQUEUE_RESOURCES and TRANSACTIONS as well. (Note that ENQUEUE_RESOURCES is obsolete as of Oracle Database 10g release 2 (10.2).)
In a shared server environment, the value of PROCESSES can be quite small. Therefore, Oracle recommends that you adjust the value of SESSIONS to approximately 1.1 * total number of connections.
3.1 結論
1. sessions的值是根據processes的值計算得到的,一般情況下只需要設置processes的值即可。
2. 在Oracle 10g中,sessions大小的的計算公式為:(1.1 * PROCESSES) + 5;在Oracle 11g中,sessions大小的的計算公式為:(1.5 * PROCESSES) + 22。
3. 若sessions的當前值比計算值大的話,則sessions的值可能保持不變;若sessions的當前值比計算值小的話,則sessions取計算值,即sessions的值總是取MAX(當前值,計算值),但是這個也不是絕對的。
3.2 實驗
SYS@lhrdb> COL NAME FORMAT A10 SYS@lhrdb> COL VALUE FORMAT A10 SYS@lhrdb> SELECT A.NAME, A.VALUE 2 FROM V$PARAMETER A 3 WHERE A.NAME IN ('processes', 'sessions');
NAME VALUE ---------- ---------- processes 100 sessions 176
SYS@lhrdb> alter system set processes=200 scope=spfile;
System altered.
SYS@lhrdb> STARTUP FORCE ORACLE instance started.
Total System Global Area 1720328192 bytes Fixed Size 2247072 bytes Variable Size 503318112 bytes Database Buffers 1207959552 bytes Redo Buffers 6803456 bytes Database mounted. Database opened. SYS@lhrdb> SELECT A.NAME, A.VALUE 2 FROM V$PARAMETER A 3 WHERE A.NAME IN ('processes', 'sessions');
NAME VALUE ---------- ---------- processes 200 sessions 328
SYS@lhrdb> SYS@lhrdb> alter system set processes=50 scope=spfile;
System altered.
SYS@lhrdb> STARTUP FORCE ORACLE instance started.
Total System Global Area 1720328192 bytes Fixed Size 2247072 bytes Variable Size 503318112 bytes Database Buffers 1207959552 bytes Redo Buffers 6803456 bytes Database mounted. Database opened. SYS@lhrdb> SELECT A.NAME, A.VALUE 2 FROM V$PARAMETER A 3 WHERE A.NAME IN ('processes', 'sessions');
NAME VALUE ---------- ---------- processes 50 sessions 176
SYS@lhrdb> SYS@lhrdb> alter system set processes=60 scope=spfile;
System altered.
SYS@lhrdb> STARTUP FORCE ORACLE instance started.
Total System Global Area 1720328192 bytes Fixed Size 2247072 bytes Variable Size 452986464 bytes Database Buffers 1258291200 bytes Redo Buffers 6803456 bytes Database mounted. Database opened. SYS@lhrdb> SELECT A.NAME, A.VALUE 2 FROM V$PARAMETER A 3 WHERE A.NAME IN ('processes', 'sessions');
NAME VALUE ---------- ---------- processes 60 sessions 176 |
3.3 報錯信息
當數據庫連接的並發用戶已經達到這個值時,又有新session連進來,就會報錯
ORA-00018,"maximum number of sessions exceeded"
當Oracle需要啟動新的process而又已經達到processes參數時,就會報錯:
ORA-00020: maximum number of processes (2048) exceeded
如果數據庫上連接被占用完,新的連接過來時,會在客戶端產生:"ORA-12519, TNS:no appropriate service handler found "的報錯信息.
[ZFLHRDB2:oracle]:/oracle>oerr ora 12519 12519, 00000, "TNS:no appropriate service handler found" // *Cause: The listener could not find any available service handlers that // are appropriate for the client connection. // *Action: Run "lsnrctl services" to ensure that the instance(s) have // registered with the listener, and are accepting connections. [ZFLHRDB2:oracle]:/oracle>oerr ora 20 00020, 00000, "maximum number of processes (%s) exceeded" // *Cause: All process state objects are in use. // *Action: Increase the value of the PROCESSES initialization parameter. [ZFLHRDB2:oracle]:/oracle>oerr ora 18 00018, 00000, "maximum number of sessions exceeded" // *Cause: All session state objects are in use. // *Action: Increase the value of the SESSIONS initialization parameter. |
About Me
............................................................................................................................... ● 本文作者:小麥苗,只專注於數據庫的技術,更注重技術的運用 ● 本文在itpub(http://blog.itpub.net/26736162)、博客園(http://www.cnblogs.com/lhrbest)和個人微信公眾號(xiaomaimiaolhr)上有同步更新 ● 本文itpub地址:http://blog.itpub.net/26736162/viewspace-2126128/ ● 本文博客園地址:http://www.cnblogs.com/lhrbest/articles/5950987.html ● 本文pdf版:http://yunpan.cn/cdEQedhCs2kFz (提取碼:ed9b) ● 小麥苗雲盤地址:http://blog.itpub.net/26736162/viewspace-1624453/ ● QQ群:230161599 微信群:私聊 ● 聯系我請加QQ好友(642808185),注明添加緣由 ● 於 2016-10-10 10:00 ~ 2016-10-11 19:00 在中行完成 ● 文章內容來源於小麥苗的學習筆記,部分整理自網絡,若有侵權或不當之處還請諒解! ● 【版權所有,文章允許轉載,但須以鏈接方式注明源地址,否則追究法律責任】 ............................................................................................................................... 手機長按下圖識別二維碼或微信客戶端掃描下邊的二維碼來關注小麥苗的微信公眾號:xiaomaimiaolhr,免費學習最實用的數據庫技術。 |