如何为 asm RAC 数据库增加控制文件

来源:互联网 发布:手机淘宝代卖 编辑:程序博客网 时间:2024/05/17 02:33

转自:http://blog.ixpub.net/html/54/29154-2729.html

 

sql> shutdown immediate;
sql> startup nomount;



$ rman nocatalog
RMAN>connect target
RMAN>restore controlfile to '+ASM2/orcl/controlfile/newfile.name' from '+ASM/orcl/controlfile/controlfile.name';


sql> alter system set controlfiles='+ASM/orcl/controlfile.name',
       '+ASM2/orcl/controlfile/newfile.name' scope=spfile;
sql> alter database mount;
sql> alter database open;




Subject:     How to duplicate a controlfile when ASM is involved
      Doc ID:     Note:345180.1     Type:     HOWTO
      Last Revision Date:     16-DEC-2006     Status:     PUBLISHED

In this Document
  Goal
  Solution

Applies to:
Oracle Server - Enterprise Edition - Version: 10.1.0.0 to 10.2.0.0
Information in this document applies to any platform.
Goal
Thisdocument presents different options to duplicate a controlfile inenvironments using ASM.  The procedure applies either to duplicate acontrolfile into ASM using a controlfile stored in file system or toduplicate a controlfile into ASM using a controlfile already stored inASM.
Solution
Duplicating a controlfile into ASM when original controlfile is stored on a file system

On the database instance:

1. Identify the location of the current controlfile:
    SQL> select name from v$controfile;

    NAME
    --------------------------------------------------------------------------------
    /oradata2/102b/oradata/P10R2/control01.ctl'
     

2. Shutdown the database and start the instance:
    SQL> shutdown normal
    SQL> startup nomount

3. Use RMAN to duplicate the controlfile:
    $ rman nocatalog
    RMAN>connect target
    RMAN>restore controlfile to '<DISKGROUP_NAME>' from '<OLD_PATH>';


RMAN> restore controlfile to '+DG1' from '/oradata2/102b/oradata/P10R2/control01.ctl';

Starting restore at 23-DEC-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: copied control file copy
Finished restore at 23-DEC-05


Weare only specifying the name of the diskgroup, so Oracle will create anOMF (Oracle Managed File).  Use ASMCMD or sqlplus to identify the nameassigned to the controlfile

4. On the ASM instance, identify the name of the controlfile:

    Using ASMCMD:
    $ asmcmd
    ASMCMD> cd <DISKGROUP_NAME>
    ASMCMD> find -t controlfile . *


    Changing the current directory to the diskgroup where the controlfile was created will speed the search.

    Output:


        ASMCMD> find -t controlfile . *
        +DG1/P10R2/CONTROLFILE/backup.308.577785757
        ASMCMD>
        

   Note the name assigned to the controlfile. Although the name startswith the backup word, that does not indicate is a backup of the file. This just the name assigned for the identical copy of the currentcontrolfile.

5. On the database side:

        * Modify init.ora or spfile, adding the new path to parameter control_files.

            * if using init<SID>.ora, just modify the control_files parameter and restart the database.

            * If using spfile,

            1) startup nomount the database instance
           2) alter system setcontrol_files='+DG1/P10R2/CONTROLFILE/backup.308.577785757','/oradata2/102b/oradata/P10R2/control01.ctl'scope=spfile;

            For RAC instance:

           alter system setcontrol_files='+DG1/P10R2/CONTROLFILE/backup.308.577785757','/oradata2/102b/oradata/P10R2/control01.ctl'scope=spfile sid='*';

            3) shutdown immediate


        * start the instance.

           Verify that new control file has been recognized. If the newcontrolfile was not used, the complete procedure needs to be repeated.

Duplicating a controlfile into ASM  using a specific name

Itis also possible to duplicate the controlfile using a specific name forthe new controlfile.  In the following example, the controlfile isduplicated into a new diskgroup where   controlfiles have not beencreated before.

On the ASM instance:

A. Create the directory  to store the new controlfile.

     SQL> alter diskgroup <DISKGROUP_NAME> add directory '+<DG_NAME>/<DB_NAME>/CONTROLFILE';

   Note that ASM uses directories to store the files and those are createdautomatically when using OMF files. (just specifying the diskgroupname).  Asumming that other OMF files were created on the diskgroup,the first directory (DB_NAME) already exist, so it is only required tocreate the directory for the controlfile.

    
SQL> alter diskgroup DG1 add directory '+DG1/P10R2/CONTROLFILE';
      ASMCMD can also be used

ASMCMD>cd dg1
ASMCMD>mkdir controlfile
On the database instance:

B. Edit init.ora or spifile and modify parameter control_file:
     control_files='+DG1/P10R2/CONTROLFILE/control02.ctl','/oradata2/102b/oradata/P10R2/control01.ctl'

C. Identify the location of the current controlfile:
  
SQL> select name from v$controfile;
          NAME
          --------------------------------------------------------------------------------
/oradata2/102b/oradata/P10R2/control01.ctl'


D. Shutdown the database and start the instance:
    SQL> shutdown normal
    SQL> startup nomount

E. Use RMAN to duplicate the controlfile:
    $ rman nocatalog
    RMAN>connect target
    RMAN>restore controlfile to '<FULL PATH>' from '<OLD_PATH>';


RMAN> restore controlfile to '+DG1/PROD/controlfile/control02.ctl' from '/oradata2/102b/oradata/P10R2/control01.ctl';

Starting restore at 23-DEC-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: copied control file copy
Finished restore at 23-DEC-05


F. Start the database:
    SQL> alter database mount;
    SQL> alter database open;


Now,using ASMCMD to search for information for the controlfiles,  the find-t contrlfile command will return two records.  That does not indicatethere were created two controlfiles.  The name specified is an aliasname and is only an entry in the ASM metadata (V$ASM_ALIAS). Oraclewill create the alias and the OMF entry when user specifies the filename.

Duplicating a controlfile into ASM when original controlfile is stored on ASM


1) Edit init.ora and add new disk group name or same disk group name for mirroring controlfiles.

Example:

control_files=('+GROUP1','+GROUP2')


(2) Mount the instance

(3) Execute restore command, to duplicate the controlfile using theoriginal location. Presuming, your current controlfile location DISKpath is '+data/V10G/controlfile/Current.260.605208993' , execute:

RMAN> restore controlfile from '+data/V10G/controlfile/Current.260.605208993';

Starting restore at 29-APR-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=317 devtype=DISK

channel ORA_DISK_1: copied controlfile copy
output filename=+GROUP2/v10g/controlfile/backup.268.7
output filename=+GROUP2/v10g/controlfile/backup.260.5
Finished restore at 29-APR-05

(4) Mount and open the database:

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> alter database open;

database opened

RMAN> exit

(5) Verify new mirrored controlfiles via sqlplus

SQL> show parameter control_files

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string +GROUP2/v10g/controlfile/backup.268.7, +GROUP2/v10g/controlfile/backup.260.5

(6) Modify pfile and create new spfile.

Firstmodify the init.ora file and include the full path of the newcontrolfiles, so next time the database is restarted, it will use thenew controlfiles.  If using spfile, recreate the new spfile.