变态的windows的ERR: ORA-27100 shared memory realm already exists

变态的windows----OERR: ORA-27100 shared memory realm already exists

引言:

ORA-27101: shared memory realm does not exist

ORA-27100: shared memory realm already exists

shared memory realm指的是进程内存中的共享内存段?还是指SGA?

难道pga和sga等oracle申请的内存总和只会不断扩张,不会缩小吗?只有通过关闭oracle实例对应的Windows服务来把oracle.exe进程关闭掉而释放它占用的内存?

         昨天晚上帮一个朋友调oracle内存参数,环境是在windows 2008下的oracle 10.2.0.1.0 ,是HA集群,一台主机上装了三个数据库,另一台是装了一个库做HA。 中间碰到了几个比较变态的问题,1、存储的文件突然变成只读了,这个好解决,更要命令的是windows下的服务太变态了。。。当我用alter system set命令改好sga_target等参数后,再重启,发生了下面的故事。。。
    
   操作步骤是:
    (1)先重启windows的Oracle服务。
    (2)在DOS命令窗口设Orcle环境变量set ORACLE_SID=orcl1
    (3)sqlplus sys/oracle as sysdba
    (4)startup pfile='E:\pfile.ora' nomount;
        报错:OERR: ORA-27100 shared memory realm already exists 

   开始尝试如下操作:
    shutdown abort;
    startup pfile='E:\pfile.ora'   nomount;

    依然报错:OERR: ORA-27100 shared memory realm already exists 


     网上搜索提到:sga_max_size,sga_target内存设的太大了,也会报错,于是手工把他改小改成:sga_max_size=800M,sga_target=800M;重启依然报错。。。。。


    主机上装了三个数据库,是不是因为其它库的原因呢,于是把其它库全部关闭掉。再次登录
    set ORACLE_SID=orcl1
    sqlplus sys/oracle as sysdba
    startup pfile='E:\pfile.ora'   nomount;

    OERR: ORA-27100 shared memory realm already exists 


    操,还是报错,到底什么原因呢?在LINUX几乎没碰到这样的错误。。。。
    好吧,我把当前的spfile给转出来:
    create pfile='E:\gyj.ora' from spfile;
    发现里面的db_name='xxxxxx',而不是orcl1,我明明手功设置了实例的环境 set ORACLE_SID=orcl1,

    为啥转出的spfile的db_name是其它库的名称而并非orcl1呢?而且细看其它参数也都是描述数据库'xxxxx'的信息。


    百思不得其解,难道手功设的环境变量没生效:set ORACLE_SID=orcl1
    接下来,去查了查metalink ,搜索ORA-27100

  

第二参考文档:

Applies to:

Oracle Server - Enterprise Edition - Version: 9.2.0.6 to 11.2.0.3 - Release: 9.2 to 11.2
z*OBSOLETE: Microsoft Windows Server 2003
***Checked for relevance on 19-Dec-2011***

Symptoms

ORA-27100 is reported during a manual startup of the database .

C:\> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Dec 19 09:29:20 2011
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to an idle instance.

SQL> startup
ORA-27100: shared memory realm already exists

SQL> shutdown immediate
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SQL>

Restarting the service, the same error is encountered.
Rebooting the server does not help as well (because that also restarts the service).

Changes

The parameter sga_max_size was increased, e.g. from 2GB to 3GB.

Cause

Changing the parameter sga_max_size (from OEM or directly on the SQL prompt) will make the change in the spfile.

ORA-27100 is received as a result of changes made to parameters affecting the SGA size.
The service was created to start with an spfile.
When the service is restarted, it will use the spfile and the error occurs due to the SGA parameter change.

Test Case:

--  Check the current value of sga_max_size

SQL> show parameter sga_max_size

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

--  Save the spfile to a pfile in order to restore the original values
SQL> create pfile from spfile;
--  Increase sga_max_size to a value that is actually too large for the system, e.g.
SQL> alter system set sga_max_size=3G scope=spfile;
SQL> shutdown immediate
SQL> exit
--  Now restart the service that is configured to automatically start
--  the instance/database using the (default) spfile
--  Note that the servcie startup is now very quick as compared to
--  successful attempts where the SGA is actually created
--  Trying to start (and shutdown) the database now from the SQL prompt
--  shows the error messages:
C:\> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Dec 19 09:29:20 2011
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup
ORA-27100: shared memory realm already exists

SQL> shutdown immediate
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SQL>
The actual root cause is in fact the limitation of physical memory.
When the service is not restarted but the instance is stopped and restarted after increasing sga_max_size, the next errors can be observed:

SQL> startup
ORA-27102: out of memory
OSD-00022: additional error information
O/S-Error: (OS 8) Not enough storage is available to process this command.
SQL>

Solution

To be able to start the instance/database again, please use the next steps:

C:\> sqlplus / as sysdba
...
Connected to an idle instance.
SQL> create pfile from spfile;
--  Edit the pfile to correct the too large sga_max_size value
--  to a value fitting the available physical memory
SQL> create spfile from pfile;
--  Restart the service
--  This uses the corrected spfile to automatically start the instance
--  (with ORA_<SID>_AUTOSTART=TRUE in the Windows Registry)



第二参考文档:

Problem Description: 
==================== 
 
You are trying to start an Oracle instance when ORA-27100 is reported.

    ORA-27100: shared memory realm already exists 
        Cause: Tried to start duplicate instances, or tried to restart an 
               instance that had not been properly shutdown 
       Action: Use a different instance name, or cleanup the failed instance's 
               SGA 


The instance does not come up successfully and instance recovery is required. 
However, instance recovery cannot complete because the instance is requiring 
too much memory and will not start.

Bringing the database up in stages reveals ORA-27102 during a startup nomount.


Solution Description: 
===================== 

The size of the SGA must be reduced so the instance can startup or the new 
software must be removed. 

To determine if the problem is memory related:

1. Start svrmgr30 or connect as the internal SYSDBA user.

SVRMGR> Connect as internal/userpassword@SID
SVRMGR> shutdown immediate
SVRMGR> startup nomount pfile=C:\ORANT\DATABASE\initSID.ora

or with 9i and 10g

sqlplus /nolog
SQL> connect / as sysdba
SQL> shutdown immediate
SQL> startup nomount pfile='C:\ORANT\DATABASE\initiSID.ora'

ORA-27102 will be reported if the problem is memory related. The instance 
cannot start. Proceed to step 2.

2. shutdown immediate

Reduce one or more of the following initSID.ora parameter values using a text 
editor:   

shared_pool_size   (affects the library and data dictionary cache)
db_block_buffers   (affects the database buffer cache)
log_buffer         (affects the redo log buffer area)

3. Return to Server Manager or SQL*Plus and try to start the instance again.

SVRMGR> startup nomount pfile=C:\ORANT\DATABASE\initSID.ora

or 

SQL>  startup nomount pfile='C:\ORANT\DATABASE\initSID.ora'

If the instance startup still fails with ORA-27102 repeat steps 1-3 
until the instance starts. Once it starts proceed to step 4.

4. At the Server Manager prompt or in SQL*Plus issue:

alter database mount
alter database open

If you are on a unix machine, you can clean up from last shutdown.

1) Delete $ORACLE_HOME/dbs/sgadef<sid>.dbf files (only applicable for
   versons prior to 8.1.x).

2) Delete $ORACLE_HOME/dbs/lk<sid> files

3) If more than one instance on this box, need to identify only the
   semaphores and shared memory associtated with that instance.
   a) SVRMGR>connect internal
   b) SVRMGR>oradebug ipc  (This will list all shared memory and semaphores
                            for this instance)

or on 9i and 10g

   a) sqlplus /nolog
   b) connect / as sysdba
   c) oradebug ipc

4) Remove shared memory and semaphores for this instance.
   a) ipcs (Lists all Interprocesses)
   b) ipcrm -m <id> (Removes Shared Memory Processes)
   c) ipcrm -s <id> (Removes Semaphores)

After these steps the database should be able to startup without
any errors and without reducing the size of the SGA.


Explanation: 
============ 

ORA-27100 is received as a result of changes made to initSID.ora parameters 
affecting the SGA size, or a new software was recently installed on the 
database server which requires additional memory.

Reducing the size of the SGA allows the instance to start and recover. The 
database can then be mounted and opened successfully.

 
References: 
=========== 

Administrators Guide
Reference Guide
Concepts Guide



参考了metalink也没有找到很有用的价值。于是只能静下心来,好好理一下思路。


        OERR: ORA-27100 shared memory realm already exists ,从这个错误上来看,是实例没有完全关闭,但是我已用了shutdown abort了,

 为啥oralce还一直不释放内存呢?


        是不是Oracle的服务有问题,但我服务也关闭了,这操蛋的windows,在LINUX不会发生这样的事,我用命令startup pfile='E:\pfile.ora'   nomount;报错,同时换成startup nomount;一样也报同样的借误。这个命令的启动只会去读参数文件,我去查了查参数文件到$ORACLE_HOME\database\,看到了initorcl1.ora,initorcl1.ora就是pfile里面只有一条记录spfile='E:\oracle10.2.1.0\db_1\dbs\spfileorcl1.ora'。

    

       我查了查spfileorcl1.ora'里面的sga_max_size=10G,sga_target=8G ,难道我用startup pfile='E:\pfile.ora'   nomount;命令启动数据库,Oracle去调'E:\oracle10.2.1.0\db_1\dbs\spfileorcl1.ora',而导致的?

       一台主机上有三个库(主机的CPU是16个,内存是16G),是不是sga_max_size=10G,sga_target=8G作怪呢》是不是这个原因呢?


      下面来验证一下,我把'E:\oracle10.2.1.0\db_1\dbs\spfileorcl1.ora'文件给移走了,然后startup pfile='E:\pfile.ora'   nomount;  成功了!!!


       缺省安装时,oracle在windows服务启动时会自动启动实例,每次启动服务都会自动用默认的错误(spfileorcl1.ora'里面的sga_max_size=10G,sga_target=8G)的spfile('E:\oracle10.2.1.0\db_1\dbs\spfileorcl1.ora)启动实例,导至内存错误。

参见:

在Windows上调整SGA大小遭遇ORA-27100、ORA-27102错误的处理方法


       OERR: ORA-27100 shared memory realm already exists 对这个错误先做个笔记。。。以后碰到windows的oracle千成要注意一下!


       startup pfile='E:\pfile.ora'   nomount;不好使,不管怎么样,问题终于找到原因!  呵呵仅供参考。


     (下图的)  参数的启动顺序只合适于LINUX,我再也不相信windows了:

  变态的windows的ERR: ORA-27100 shared memory realm already exists_第1张图片


参考:

在Windows上调整SGA大小遭遇ORA-27100、ORA-27102错误的处理方法

ORA-27102: out of memory 解决实例


你可能感兴趣的:(变态的windows的ERR: ORA-27100 shared memory realm already exists)