分享交流
合作共赢!

Oracle数据库参数修改方法总结

Oracle中有些参数是可以在session级别修改,有些则必须在system级别修改,有些参数不需要重启就能马上生效,有些参数必须重启才能生效,那么如何知道这些信息呢?可以从v$parameter视图中得出,重点关注这个视图的以下几列:

ISSES_MODIFIABLE VARCHAR2(5) Indicates whether the parameter can be
changed withALTER SESSION(TRUE) or not (FALSE)

ISSYS_MODIFIABLE VARCHAR2(9) Indicates whether the parameter can be
changed withALTER SYSTEMand when the change takes effect:

IMMEDIATE- Parameter can be changed withALTER SYSTEMregardless of
the type of parameter file used to start the instance. The change
takes effect immediately.

DEFERRED- Parameter can be changed withALTER SYSTEMregardless of the type of parameter file used to start the instance. The change takes effect in subsequent sessions.

FALSE- Parameter cannot be changed withALTER SYSTEMunless a server parameter file was used to start the instance. The change takes effect in subsequent instances.

ISSES_MODIFIABLE 这一列标志该参数是否可以在session级别被修改;
ISSYS_MODIFIABLE 这一列标志该参数是否可以在system级别被修改,其中有三个值:
IMMEDIATE表示修改完之后立即生效,DEFERRED表示必须得等下个session才能生效,也就是当前session还是不起作用的,FALSE表示实例重启后才能生效

下面就以4个典型参数做实验:

SQL> select NAME,ISSES_MODIFIABLE,ISSYS_MODIFIABLE from
v$parameter where NAME in
('workarea_size_policy','audit_file_dest','sga_target','sga_max_size');

NAME                           ISSES_MODIFIABLE               ISSYS_MODIFIABLE
------------------------------ ------------------------------ ----------------------------
workarea_size_policy           TRUE                           IMMEDIATE
sga_target                     FALSE                          IMMEDIATE
audit_file_dest                FALSE                          DEFERRED
sga_max_size                   FALSE                          FALSE

1.workarea_size_policy可以alter session修改

查看原来的配置:
SQL> show parameter workarea_size_policy

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------
workarea_size_policy                 string      AUTO

在session级别修改:
SQL> alter session set workarea_size_policy=MANUAL;

Session altered.

在本session查看,可以发现修改已经生效:
SQL> show parameter workarea_size_policy

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------------
workarea_size_policy                 string      MANUAL

2. sga_target在用alter system修改后立即生效

查看原来的配置:
SQL> show parameter sga_target

NAME                                 TYPE        VALUE
------------------------------------ ----------- --------------
sga_target                           big integer 1504M

SQL> alter system set sga_target=1400M;

System altered.
用alter system修改后立即生效:
SQL> show parameter sga_target

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------
sga_target                           big integer 1400M

3. audit_file_dest在用alter system修改后,知道下个session才生效

查看原来的配置:
SQL> show parameter audit_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------------
audit_file_dest                      string      H:\INTEL_DB_DUMPS

注意:后面必须得加关键字deferred,否则会报错。
SQL> alter system set audit_file_dest='H:\INTEL_DB_DUMPS\O02DMS1' deferred;

System altered.

在本session里查询还是原值,没有改变:
SQL> show parameter audit_file

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------------------
audit_file_dest                      string      H:\INTEL_DB_DUMPS

重新开个session,在查询发现已经改为新值了:
SQL> show parameter audit_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------------------
audit_file_dest                      string      H:\INTEL_DB_DUMPS\O02DMS1

4. sga_max_size在用alter system修改后必须重启实例才能生效

查看原来的配置:
SQL> show parameter sga_max_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------
sga_max_size                         big integer 1504M

注意:后面必须得加scope=spfile,否则会报错。
SQL> alter system set sga_max_size=1400 scope=spfile;

System altered.

如果数据库没重启,无论如何还是原来的配置:
SQL> show parameter sga_max_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------
sga_max_size                         big integer 1504M

重启数据库:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 1468006400 bytes
Fixed Size                  1303076 bytes
Variable Size             612371932 bytes
Database Buffers          847249408 bytes
Redo Buffers                7081984 bytes
Database mounted.
Database opened.

再重新查询,就可以看到用的是新值了:

SQL> show parameter sga_max_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------
sga_max_size                         big integer 1400M

附:

5.查看、修改最大连接数processes

select value from v$parameter where name = 'processes';
或
SQL> show parameter processes;

修改最大连接数:

alter system set processes=1500 scope=spfile;
alter system set sessions=1500 scope=spfile;

修改完重启数据库生效!

查看当前进程的最大连接数:

select count(*) from v$process;

查看数据库的并发连接数:

select count(*) from v$session where status='ACTIVE';

查看当前数据库建立的会话情况:

select sid,serial#,username,program,machine,status from v$session;

6.查看资源使用情况

select * from v$resource_limit;

增加processes

alter system set processes=200 scope=spfile;

7.查看数据库参数

SQL> col RESOURCE_NAME for a20
SQL> col LIMIT_VALUE for a20
SQL> select resource_name,MAX_UTILIZATION,LIMIT_VALUE from v$resource_limit where resource_name in ('processes','sessions');

RESOURCE_NAME MAX_UTILIZATION LIMIT_VALUE
-------------------- --------------- --------------------
processes 281 500
sessions 282 792

8.查看每个内存段是属于oracle哪个实例,可以通过oracle命令sysresv

[oracle@rac2 ~]$ sysresv

IPC Resources for ORACLE_SID "orcl" :
Shared Memory:
ID              KEY
41385984        0xb2f44a00
Semaphores:
ID              KEY
16220162        0xb38b1d5c
Oracle Instance alive for sid "orcl"

同版本多实例可以指定实例

sysresv -l sid
删除共享内存段,或者sysresv -f sid删除
[oracle@rac2 trace]$ ipcrm --hlep
usage: ipcrm [ [-q msqid] [-m shmid] [-s semid]
          [-Q msgkey] [-M shmkey] [-S semkey] ... ]
9.
赞(0) 打赏
未经允许不得转载:琼杰笔记 » Oracle数据库参数修改方法总结

评论 抢沙发

评论前必须登录!

 

分享交流,合作共赢!

联系我们加入QQ群

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏