Oracle ASMM 与AMM之间相互切换

AMM (Automatic Memory Management)自动内存管理 , 它是通过设置MEMORY_TARGET和MEMORY_MAX_TARGET控制的,使用在Oracle 11g release。
ASMM(Automatic shared Memory Management)自动共享内存管理,它是通过设置SGA_TARGET不为0,同时需要参数STATISTICS_LEVEL为TYPICAL 或ALL 实现,使用在oracle 10g中。
通过实验简单的学习一下oracle的AMM和ASMM之间特征以及它们之间相互切换的方式

一、oracle 采用 ASMM 形式显著特征就是SGA_TARGET和PGA_AGGREGATE_TARGET不为0 ,而MEMORY_TARGET和MEMORY_MAX_TARGET 为0

[oracle@mhxy171 ~]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Mon Aug 29 10:12:56 2016

Copyright (c) 1982, 2013, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> show parameter target

NAME                                TYPE                  VALUE
------------------------------------ ---------------------- ------------------------------
archive_lag_target                  integer                0
db_flashback_retention_target        integer                1440
fast_start_io_target                integer                0
fast_start_mttr_target              integer                0
memory_max_target                    big integer            0
memory_target                        big integer            0
parallel_servers_target              integer                32
pga_aggregate_target                big integer            383M
sga_target                          big integer            1152M


通过改变一下静态参数的值,把oracle DB 把ASMM修改为AMM,修改之前备份下spfile文件。重启DB实例,查看参数memory_max_target和memory_target 不为0,表示已经启动AMM


点击(此处)折叠或打开

SQL> show parameter spfile;


NAME                                TYPE                  VALUE
------------------------------------ ---------------------- ------------------------------
spfile                              string                /oracle/database/product/11.2.
                                                            0.4.0/db_1/dbs/spfileyzxd.ora

SQL> create pfile from spfile;

File created.

SQL> alter system set memory_max_target=1535m scope=spfile;

System altered.

SQL>alter system set memory_target=1535m scope=spfile;

System altered.

SQL> alter system set sga_target=0m scope=spfile;

System altered.

SQL> alter system set pga_aggregate_target=0m scope=spfile;

System altered.

SQL> alter system set sga_max_size=0m scope=spfile;

System altered.

SQL> startup force
ORACLE instance started.

Total System Global Area 1202614272 bytes
Fixed Size 2261248 bytes
Variable Size 360713984 bytes
Database Buffers 834666496 bytes
Redo Buffers 4972544 bytes
Database mounted.
Database opened.
SQL> show parameter target

NAME                                TYPE                  VALUE
------------------------------------ ---------------------- ------------------------------
archive_lag_target                  integer                0
db_flashback_retention_target        integer                1440
fast_start_io_target                integer                0
fast_start_mttr_target              integer                0
memory_max_target                    big integer            1536M
memory_target                        big integer            1536M
parallel_servers_target              integer                32
pga_aggregate_target                big integer            0
sga_target                          big integer            0

二、实现oracle 11g 从AMM到ASMM的切换。关闭AMM ,需要把memory_max_target和 memory_target设置为0。
在从AMM切换到ASMM的过程需要通过pfile文件启动,并且把文件中的memory_max_target和memory_target删除。在默认的pfile文件,发现这两个参数值还是0,表示AMM内存管理。
以下是从AMM切换到ASMM的操作步骤:1、修改参数值

SQL> alter system set memory_target=0m scope=spfile;


System altered.

SQL> alter system set memory_max_target=0m scope=spfile;

System altered.

SQL> alter system set pga_aggregate_target=350m scope=spfile;

System altered.

SQL> alter system set sga_target=1186m scope=spfile;

System altered.

SQL> alter system set sga_max_size=1186m scope=spfile;

System altered.

在直接通过spfile启动数据库会提示以下错误,看来是内存参数值冲突

SQL> shutdown immediate

Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORA-00843: Parameter not taking MEMORY_MAX_TARGET into account
ORA-00849: SGA_TARGET 1258291200 cannot be set to more than MEMORY_MAX_TARGET 0.
SQL> startup nomount
ORA-00843: Parameter not taking MEMORY_MAX_TARGET into account
ORA-00849: SGA_TARGET 1258291200 cannot be set to more than MEMORY_MAX_TARGET 0.
SQL> create pfile from spfile;
点击(此处)折叠或打开

[oracle@mhxy171 ~]$ oerr ora 00843
00843, 00000, "Parameter not taking MEMORY_MAX_TARGET into account"
// *Cause: The parameter was larger than MEMORY_MAX_TARGET.
// *Action: Check the other error messages for additional information about the parameter. Set the parameter to a lower value than MEMORY_MAX_TARGET.
[oracle@mhxy171 ~]$
[oracle@mhxy171 ~]$ oerr ora 00849
00849, 00000, "SGA_TARGET %s cannot be set to more than MEMORY_MAX_TARGET %s."
// *Cause: SGA_TARGET value was more than MEMORY_MAX_TARGET value.
// *Action: Set SGA_TARGET to be less than MEMORY_MAX_TARGET.
[oracle@mhxy171 ~]$

2、通过修改pfile文件中参数值,使用pfile文件启动。


SQL> create pfile from spfile;                                #通过spfile生成最新的pfile文件

File created.

[oracle@mhxy171 ~]$ cd $ORACLE_HOME

[oracle@mhxy171 dbs]$ cp inityzxd.ora inityzxd.ora_bak        #备份pfile文件
[oracle@mhxy171 dbs]$ vi inityzxd.ora
*.memory_max_target=0
*.memory_target=0
yzxd.__db_cache_size=897581056
yzxd.__java_pool_size=4194304
yzxd.__large_pool_size=8388608
yzxd.__oracle_base='/oracle/database'#ORACLE_BASE set from environment
yzxd.__pga_aggregate_target=402653184
yzxd.__sga_target=1207959552
yzxd.__shared_io_pool_size=0
yzxd.__shared_pool_size=285212672
yzxd.__streams_pool_size=0
*.audit_file_dest='/oracle/database/admin/yzxd/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_file_record_keep_time=20
*.control_files='/oracle/database/oradata/yzxd/control01.ctl','/oracle/database/fast_recovery_area/yzxd/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='yzxd'
*.db_recovery_file_dest='/oracle/database/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/oracle/database'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=yzxdXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_max_target=0                        #删除memory_max_target 和memory_target 参数
*.memory_target=0
*.open_cursors=300
*.pga_aggregate_target=367001600
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=170
*.sga_max_size=1243611136
*.sga_target=1243611136
*.undo_tablespace='UNDOTBS1'

3、通过pfile文件启动数据库,检查正确后生成最新的spfile文件

[oracle@mhxy171 dbs]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Mon Aug 29 11:12:14 2016

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup pfile=inityzxd.ora
ORACLE instance started.

ORACLE instance started.


Total System Global Area 1252663296 bytes
Fixed Size                  2252824 bytes
Variable Size            402657256 bytes
Database Buffers          838860800 bytes
Redo Buffers                8892416 bytes
Database mounted.
Database opened.

SQL> show parameter target                  #是我们修改后的参数值


NAME                                TYPE                  VALUE
------------------------------------ ---------------------- ------------------------------
archive_lag_target                  integer                0
db_flashback_retention_target        integer                1440
fast_start_io_target                integer                0
fast_start_mttr_target              integer                0
memory_max_target                    big integer            0
memory_target                        big integer            0
parallel_servers_target              integer                32
pga_aggregate_target                big integer            350M
sga_target                          big integer            1200M

SQL> create spfile from pfile;

File created.

SQL> startup force
ORACLE instance started.

Total System Global Area 1252663296 bytes
Fixed Size                  2252824 bytes
Variable Size            402657256 bytes
Database Buffers          838860800 bytes
Redo Buffers                8892416 bytes
Database mounted.
Database opened.

SQL> show parameter target

NAME                                TYPE                  VALUE
------------------------------------ ---------------------- ------------------------------
archive_lag_target                  integer                0
db_flashback_retention_target        integer                1440
fast_start_io_target                integer                0
fast_start_mttr_target              integer                0
memory_max_target                    big integer            0
memory_target                        big integer            0
parallel_servers_target              integer                32
pga_aggregate_target                big integer            350M
sga_target                          big integer            1200M

SQL>

相关推荐