如何禁掉ASM实例的AMM

先交代一下背景:RedHat 6.3 x86_64上的11.2.0.3的两节点RAC,已经打了GI PSU 11.2.0.3.9Patch:17063116 for 11.2.0.3.7以及Patch:11072246 for 11.2.0.3.9

这里我想配一下Hugepage,但因为HugepageAMM不兼容以及11.2.0.3 RACASM实例默认会启用AMM,所以我得把ASM实例的AMM给禁掉。

 

本来以为是很简单的操作,但出乎我意料的是,一度出现了我怎么都禁不掉ASM实例的AMM的情形。

 

我们来看一下整个操作过程:

在任意一个RAC节点执行如下操作(注意——如下做法是错误的做法,我后面会跟正确的做法):

[oracle@rddb2 ~]$ su – grid

Password:

[grid@rddb2 ~]$ sqlplus ‘/ as sysasm’;

SQL*Plus: Release 11.2.0.3.0 Production on Thu Mar 6 10:29:23 2014

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production

With the Real Application Clusters and Automatic Storage Management options

 

SQL> show parameter target;

 

NAME                                 TYPE                   VALUE

———————————— ———————- ——————————

memory_max_target                    big integer            272M

memory_target                        big integer            272M

pga_aggregate_target                 big integer            0

sga_target                           big integer            0

 

SQL> alter system reset memory_target scope=spfile sid=’*’;

alter system reset memory_target scope=spfile sid=’*’

*

ERROR at line 1:

ORA-32010: cannot find entry to delete in SPFILE

 

SQL> alter system set memory_target=0 scope=spfile sid=’*’;

 

System altered.

 

SQL> alter system set memory_max_target=0 scope=spfile sid=’*’;

 

System altered.

 

SQL> alter system set sga_target=512M scope=spfile sid=’*’;

 

System altered.

 

SQL> alter system set sga_max_size=1G scope=spfile sid=’*’;  

 

System altered.

 

SQL> alter system set shared_pool_size=150M scope=spfile sid=’*’;

 

System altered.

 

停掉数据库:

[grid@rddb2 ~]$ su – oracle

Password:

[oracle@rddb2 ~]$ srvctl stop database -d db112

 

在各个RAC节点依次执行如下操作以重启ASM实例:

RAC节点1GI

[grid@rddb2 ~]$ su – root

Password:

[root@rddb2 ~]# /opt/u01/app/11.2.0.3/grid/bin/crsctl stop crs

CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on ‘rddb2’

CRS-2673: Attempting to stop ‘ora.crsd’ on ‘rddb2’

CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on ‘rddb2’

CRS-2673: Attempting to stop ‘ora.oc4j’ on ‘rddb2’

CRS-2673: Attempting to stop ‘ora.LISTENER_SCAN1.lsnr’ on ‘rddb2’

……省略显示部分内容

CRS-2673: Attempting to stop ‘ora.gpnpd’ on ‘rddb2’

CRS-2677: Stop of ‘ora.gpnpd’ on ‘rddb2’ succeeded

CRS-2793: Shutdown of Oracle High Availability Services-managed resources on ‘rddb2’ has completed

CRS-4133: Oracle High Availability Services has been stopped.

 

RAC节点2GI

[grid@rddb3 ~]$ su – root

Password:

[root@rddb3 ~]# /opt/u01/app/11.2.0.3/grid/bin/crsctl stop crs

CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on ‘rddb3’

CRS-2673: Attempting to stop ‘ora.crsd’ on ‘rddb3’

CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on ‘rddb3’

CRS-2673: Attempting to stop ‘ora.rddb2.vip’ on ‘rddb3’

……省略显示部分内容

CRS-2673: Attempting to stop ‘ora.gpnpd’ on ‘rddb3’

CRS-2677: Stop of ‘ora.gpnpd’ on ‘rddb3’ succeeded

CRS-2793: Shutdown of Oracle High Availability Services-managed resources on ‘rddb3’ has completed

CRS-4133: Oracle High Availability Services has been stopped.

 

启节点1GI

[root@rddb2 ~]# /opt/u01/app/11.2.0.3/grid/bin/crsctl start crs

CRS-4123: Oracle High Availability Services has been started.

 

在节点1等待1分钟执行如下操作检查GI是否已经全部起来了:

[root@rddb2 ~]# /opt/u01/app/11.2.0.3/grid/bin/crsctl check crs

CRS-4638: Oracle High Availability Services is online

CRS-4535: Cannot communicate with Cluster Ready Services

CRS-4529: Cluster Synchronization Services is online

CRS-4534: Cannot communicate with Event Manager

发现这时候CRSD已经起不来了。

 

这里的原因是因为ASM实例起不来,ASM实例启动报错:

SQL> startup

ORA-00843: Parameter not taking MEMORY_MAX_TARGET into account

ORA-00849: SGA_TARGET 1073741824 cannot be set to more than MEMORY_MAX_TARGET 0.

 

SYSASM角色登录后以pfile启动再覆盖spfile可以解决上述问题:

[grid@rddb2 dbs]$ sqlplus ‘/ as sysasm’;

SQL*Plus: Release 11.2.0.3.0 Production on Thu Mar 6 14:47:09 2014

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

Connected to an idle instance.

 

SQL> startup pfile=/opt/u01/app/11.2.0.3/grid/dbs/init+ASM1.ora

ASM instance started

 

Total System Global Area  283930624 bytes

Fixed Size                  2227664 bytes

Variable Size             256537136 bytes

ASM Cache                  25165824 bytes

ASM diskgroups mounted

 

SQL> create spfile from pfile;

create spfile from pfile

*

ERROR at line 1:

ORA-17502: ksfdcre:4 Failed to create file

+SYSTEMDG/rddb-cluster/asmparameterfile/registry.253.840470757

ORA-15177: cannot operate on system aliases

 

看起来是oracle自身的问题,因为当我加上DG名称后即可成功覆盖spfile

SQL> create spfile=’+SYSTEMDG’ from pfile;

 

File created.

 

然后我在节点1重启GI:

[grid@rddb2 dbs]$ su – root

Password:

[root@rddb2 ~]# /opt/u01/app/11.2.0.3/grid/bin/crsctl stop crs

CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on ‘rddb2’

CRS-2673: Attempting to stop ‘ora.crsd’ on ‘rddb2’

……省略显示部分内容

CRS-2677: Stop of ‘ora.gpnpd’ on ‘rddb2’ succeeded

CRS-2793: Shutdown of Oracle High Availability Services-managed resources on ‘rddb2’ has completed

CRS-4133: Oracle High Availability Services has been stopped.

 

[root@rddb2 ~]# /opt/u01/app/11.2.0.3/grid/bin/crsctl start crs

CRS-4123: Oracle High Availability Services has been started.

 

可以看到现在节点1GI已经启起来了:

[root@rddb2 ~]# su – grid

[grid@rddb2 ~]$ crsctl check crs

CRS-4638: Oracle High Availability Services is online

CRS-4537: Cluster Ready Services is online

CRS-4529: Cluster Synchronization Services is online

CRS-4533: Event Manager is online

 

如下才是正确禁掉ASM实例AMM的做法:

特别注意的是——如果要禁掉ASM实例的AMM,就一定不要同时reset memory_targetmemory_max_target,而是应该将memory_target设为0并只reset memory_max_target,但很恶心的是基本上所有的MOS文档都在说要同时reset memory_targetmemory_max_target,所以如果你没有注意到这一点,你会发现你怎么也禁不掉ASM实例的AMM

 

在任意一个RAC节点执行如下操作:

alter system set sga_target=512M scope=spfile sid=’*’;

alter system set pga_aggregate_target=256M scope=spfile sid=’*’;

alter system set shared_pool_size=150M scope=spfile sid=’*’;

alter system set memory_target=0 scope=spfile sid=’*’;

alter system set memory_max_target=0 scope=spfile sid=’*’;

alter system reset memory_max_target scope=spfile sid=’*’;

 

[grid@rddb2 dbs]$ su – grid

Password:

[grid@rddb2 ~]$ sqlplus ‘/ as sysasm’;

SQL*Plus: Release 11.2.0.3.0 Production on Thu Mar 6 15:29:07 2014

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production

With the Real Application Clusters and Automatic Storage Management options

 

SQL> alter system set sga_target=512M scope=spfile sid=’*’;

 

System altered.

 

SQL> alter system set pga_aggregate_target=256M scope=spfile sid=’*’;

 

System altered.

 

SQL> alter system set shared_pool_size=150M scope=spfile sid=’*’;

 

System altered.

 

SQL> alter system set memory_target=0 scope=spfile sid=’*’;

 

System altered.

 

SQL> alter system set memory_max_target=0 scope=spfile sid=’*’;

 

System altered.

 

SQL> alter system reset memory_max_target scope=spfile sid=’*’;

 

System altered.

 

然后在节点1重启GI:

[grid@rddb2 ~]$ su – root

Password:

[root@rddb2 ~]# /opt/u01/app/11.2.0.3/grid/bin/crsctl stop crs

CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on ‘rddb2’

CRS-2673: Attempting to stop ‘ora.crsd’ on ‘rddb2’

CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on ‘rddb2’

CRS-2673: Attempting to stop ‘ora.oc4j’ on ‘rddb2’

CRS-2673: Attempting to stop ‘ora.LISTENER_SCAN1.lsnr’ on ‘rddb2’

……省略显示部分内容

CRS-2673: Attempting to stop ‘ora.gpnpd’ on ‘rddb2’

CRS-2677: Stop of ‘ora.gpnpd’ on ‘rddb2’ succeeded

CRS-2793: Shutdown of Oracle High Availability Services-managed resources on ‘rddb2’ has completed

CRS-4133: Oracle High Availability Services has been stopped.

 

[root@rddb2 ~]# /opt/u01/app/11.2.0.3/grid/bin/crsctl start crs

CRS-4123: Oracle High Availability Services has been started.

 

在节点1等待1分钟后执行如下操作,可以看到现在节点1GI已经启起来了:

[root@rddb2 ~]# /opt/u01/app/11.2.0.3/grid/bin/crsctl check crs

CRS-4638: Oracle High Availability Services is online

CRS-4537: Cluster Ready Services is online

CRS-4529: Cluster Synchronization Services is online

CRS-4533: Event Manager is online

 

从如下查询结果可以看到,现在节点1上的ASM实例的AMM终于被我们禁掉了:

[root@rddb2 ~]# ls -l /dev/shm

total 88

-r——– 1 gdm gdm 67108904 Mar  6 11:15 pulse-shm-3757187464

-r——– 1 gdm gdm 67108904 Mar  6 11:15 pulse-shm-4050473372

 

现在我们再来启节点2GI:

[root@rddb3 ~]# /opt/u01/app/11.2.0.3/grid/bin/crsctl start crs

CRS-4123: Oracle High Availability Services has been started.

 

从如下结果可以看到,两个节点的GI确实已经都起来了:

[root@rddb3 ~]# /opt/u01/app/11.2.0.3/grid/bin/crsctl stat res -t

——————————————————————————–

NAME           TARGET  STATE        SERVER                   STATE_DETAILS      

——————————————————————————–

Local Resources

——————————————————————————–

ora.DATADG1.dg

               ONLINE  ONLINE       rddb2                                       

               ONLINE  ONLINE       rddb3                                       

ora.FRADG.dg

               ONLINE  ONLINE       rddb2                                       

               ONLINE  ONLINE       rddb3                                       

ora.LISTENER.lsnr

               ONLINE  ONLINE       rddb2                                       

               ONLINE  ONLINE       rddb3                                       

ora.SYSTEMDG.dg

               ONLINE  ONLINE       rddb2                                       

               ONLINE  ONLINE       rddb3                                       

ora.asm

               ONLINE  ONLINE       rddb2                    Started            

               ONLINE  ONLINE       rddb3                    Started            

ora.gsd

               OFFLINE OFFLINE      rddb2                                       

               OFFLINE OFFLINE      rddb3                                       

ora.net1.network

               ONLINE  ONLINE       rddb2                                       

               ONLINE  ONLINE       rddb3                                       

ora.ons

               ONLINE  ONLINE       rddb2                                       

               ONLINE  ONLINE       rddb3                                       

——————————————————————————–

Cluster Resources

——————————————————————————–

ora.LISTENER_SCAN1.lsnr

      1        ONLINE  ONLINE       rddb2                                       

ora.cvu

      1        ONLINE  ONLINE       rddb2                                       

ora.db112.db

      1        OFFLINE OFFLINE                               Instance Shutdown  

      2        OFFLINE OFFLINE                               Instance Shutdown  

ora.oc4j

      1        ONLINE  ONLINE       rddb2                                       

ora.rddb2.vip

      1        ONLINE  ONLINE       rddb2                                       

ora.rddb3.vip

      1        ONLINE  ONLINE       rddb3                                       

ora.scan1.vip

      1        ONLINE  ONLINE       rddb2

     

我们再来同时reset一下memory_targetmemory_max_target,设置完后重启GI

SQL> alter system set memory_target=0 scope=spfile sid=’*’;

 

System altered.

 

SQL> alter system reset memory_target scope=spfile sid=’*’;

 

System altered.

 

SQL> alter system set memory_max_target=0 scope=spfile sid=’*’;

 

System altered.

 

SQL> alter system reset memory_max_target scope=spfile sid=’*’;

 

System altered.

 

重启完GI后发现ASMAMM果然被Oracle启用了,MOS上的不靠谱文章太坑爹了啊:

[root@rddb2 ~]# ls -l /dev/shm

total 516808

-rw-r—– 1 grid oinstall  4194304 Mar  7 09:56 ora_+ASM1_2326534_0

-rw-r—– 1 grid oinstall  4194304 Mar  7 09:55 ora_+ASM1_2326534_1

-rw-r—– 1 grid oinstall        0 Mar  7 09:55 ora_+ASM1_2359303_0

……省略显示部分内容

-rw-r—– 1 grid oinstall  4194304 Mar  7 09:55 ora_+ASM1_2359303_95

-rw-r—– 1 grid oinstall  4194304 Mar  7 09:55 ora_+ASM1_2359303_96

-rw-r—– 1 grid oinstall  4194304 Mar  7 09:55 ora_+ASM1_2359303_97

-rw-r—– 1 grid oinstall  4194304 Mar  7 09:55 ora_+ASM1_2359303_98

-rw-r—– 1 grid oinstall  4194304 Mar  7 09:56 ora_+ASM1_2359303_99

-rw-r—– 1 grid oinstall  4194304 Mar  7 09:55 ora_+ASM1_2392072_0

-r——– 1 gdm  gdm      67108904 Mar  6 11:15 pulse-shm-3757187464

-r——– 1 gdm  gdm      67108904 Mar  6 11:15 pulse-shm-4050473372

 

此时memory_targetmemory_max_target已经自动被Oracle设置成了808M

[root@rddb2 ~]# su – grid

[grid@rddb2 ~]$ sqlplus ‘/ as sysasm’;

SQL*Plus: Release 11.2.0.3.0 Production on Fri Mar 7 09:58:00 2014

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production

With the Real Application Clusters and Automatic Storage Management options

 

SQL> show parameter memory;

 

NAME                                 TYPE                   VALUE

———————————— ———————- ——————————

memory_max_target                    big integer            808M

memory_target                        big integer            808M



Leave a Reply

Your email address will not be published. Required fields are marked *