处于某种原因,我们可能需要调小SESSIONS参数,但是在重启数据库后,我们发现参数并没有生效。
这是因为这个参数来源于参数processes,以下是联机文档对于session参数的描述:
Property
|
Description
|
Parameter type
|
Integer
|
Default value
|
Derived: (1.1 * PROCESSES) + 5
|
Modifiable
|
No
|
Range of values
|
1 to 231
|
Basic
|
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 andTRANSACTIONS 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.
SESSION参数的大小默认是: (1.1 * PROCESSES) + 5,如果只调小SESSIONS参数而不调小PROCESSES参数,
那么在重启数据库后,SESSIONS参数将会被重新计算,如下:
SQL> show parameter sessions
NAME TYPE VALUE
------------------------------------ ---------------------- -------------------
java_max_sessionspace_size integer 0
java_soft_sessionspace_limit integer 0
license_max_sessions integer 0
license_sessions_warning integer 0
logmnr_max_persistent_sessions integer 1
sessions integer 2205
shared_server_sessions integer
SQL> show parameter process
NAME TYPE VALUE
------------------------------------ ---------------------- -------------------
aq_tm_processes integer 0
db_writer_processes integer 1
gcs_server_processes integer 0
job_queue_processes integer 10
log_archive_max_processes integer 2
processes integer 2000
SQL> alter system set sessions=1000 scope=spfile;
系统已更改。
SQL> startup force nomount
ORACLE 例程已经启动。
Total System Global Area 1300234240 bytes
Fixed Size 1250668 bytes
Variable Size 864029332 bytes
Database Buffers 427819008 bytes
Redo Buffers 7135232 bytes
SQL> show parameter sessions
NAME TYPE VALUE
------------------------------------ ---------------------- -------------------
----------
java_max_sessionspace_size integer 0
java_soft_sessionspace_limit integer 0
license_max_sessions integer 0
license_sessions_warning integer 0
logmnr_max_persistent_sessions integer 1
sessions integer 2205
shared_server_sessions integer
SQL>
如果调大是没问题的:
SQL> alter system set sessions=3000 scope=spfile;
系统已更改。
SQL> startup force nomount
ORACLE 例程已经启动。
Total System Global Area 1300234240 bytes
Fixed Size 1250668 bytes
Variable Size 864029332 bytes
Database Buffers 427819008 bytes
Redo Buffers 7135232 bytes
SQL> show parameter processes
NAME TYPE VALUE
------------------------------------ ---------------------- -----------------
aq_tm_processes integer 0
db_writer_processes integer 1
gcs_server_processes integer 0
job_queue_processes integer 10
log_archive_max_processes integer 2
processes integer 2000
SQL> show parameter sessions
NAME TYPE VALUE
------------------------------------ ---------------------- -----------------
java_max_sessionspace_size integer 0
java_soft_sessionspace_limit integer 0
license_max_sessions integer 0
license_sessions_warning integer 0
logmnr_max_persistent_sessions integer 1
sessions integer 3000
shared_server_sessions integer
不过仅仅调大SESSIONS数,而不调大PROCESSES的话,对于dedicated server,还是会遇到问题的,
因为无法创建新的SERVER PROCESSES了。
因此在调整参数SESSIONS的时候,也要考虑PROCESSES参数的值。
在加大PROCESSES参数的时候,还可能会遇到如下的问题。
ORA-00371: not enough shared pool memory, should be atleast 832273203 bytes
ORA-00064: object is too large to allocate on this O/S (1,19985080)
还有一点需要注意的是,如果调整了processes后,通过(1.1 * PROCESSES) + 5计算出来的SESSIONS数比当前的小,
那么SESSIONS不会改变,只有比原来大才会用新计算的值。
SQL> select name,value from v$parameter where name in ('processes','sessions');
NAME VALUE
-------------------- --------------------
processes 100
sessions 115
SQL> alter system set processes=90 scope=spfile;
系统已更改。
SQL> startup force nomount
ORACLE 例程已经启动。
Total System Global Area 1300234240 bytes
Fixed Size 1250668 bytes
Variable Size 864029332 bytes
Database Buffers 427819008 bytes
Redo Buffers 7135232 bytes
SQL> select name,value from v$parameter where name in ('processes','sessions');
NAME VALUE
-------------------- --------------------
processes 90
sessions 115
SQL> alter system set processes=110 scope=spfile;
系统已更改。
SQL> startup force nomount
ORACLE 例程已经启动。
Total System Global Area 1300234240 bytes
Fixed Size 1250668 bytes
Variable Size 864029332 bytes
Database Buffers 427819008 bytes
Redo Buffers 7135232 bytes
SQL> select name,value from v$parameter where name in ('processes','sessions');
NAME VALUE
-------------------- --------------------
processes 110
sessions 126
SQL> select 1.1*110+5 from dual;
1.1*110+5
----------
126
如果只调整SESSION参数,那么只有调的比(1.1 * PROCESSES)计算出来的大才会生效,否则还是原来的值。