Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

42

积分

0

好友

0

主题
1#
发表于 2012-1-11 21:21:10 | 查看: 8030| 回复: 8
How to duplicate a controlfile when ASM is involved [ID 345180.1]
很奇怪AIX6.1+ORACLE10.2.0.4建库完成后,查询v$controlfile只有一个控制文件,平时都是3个的,所以手工想复制几个出来,但是根据官方的这个文档操作完成后,只能复制出一个,也就是说加上原有的只有两个,无论多次运行命令还是一样效果,最终放弃了,用两个控制文件算了,反正多了也没啥用,不知道各位有何见解:
---------------------------------开始在ASM里复制控制文件---------------- [ID 345180.1]节选---------------------------------------
Duplicating a controlfile into ASM when original controlfile is stored on ASM

If using spfile to start the instance:

1. Modify the spfile specifically the parameter control_files. In this example, a second controlfile
is going to be created on same diskgroup DATA1.

sql> alter system set control_files='+DATA1/v102/controlfile/current.261.637923577','+DATA1'
scope=spfile sid='*';


2. Start the instance in NOMOUNT mode.

3. From rman, duplicate the controlfile
$ rman nocatalog
RMAN>connect target
RMAN> restore controlfile from '+DATA1/v102/controlfile/current.261.637923577';


The output for the execution is like:

Starting restore at 08-NOV-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=147 instance=V1021 devtype=DISK

channel ORA_DISK_1: copied control file copy
output filename=+DATA1/v102/controlfile/current.261.637923577
output filename=+DATA1/v102/controlfile/current.269.638120375
Finished restore at 08-NOV-07

Note that the command prints the name of the new created file: +DATA1/v102/controlfile/current.269.638120375

4. Modify the control_file parameter with the complete path of the new file:


sql> alter system set control_files='+DATA1/v102/controlfile/current.261.637923577','+DATA1/v102/controlfile/current.269.638120375'
scope=spfile sid='*';



5. Mount and Open the database

RMAN> sql 'alter database mount';
RMAN> sql 'alter database open';


6. Validate both controlfiles are present
SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
+DATA1/v102/controlfile/current.261.637923577
+DATA1/v102/controlfile/current.269.638120375



Next time instance are restarted, will pick both files.


---------------------------------结束在ASM里复制控制文件-----------------------------------------------------

我多次RMAN运行restore controlfile from '+DATA1/v102/controlfile/current.261.637923577'; 或restore controlfile from '+DATA1/v102/controlfile/current.269.638120375‘ 它反复 重复复制相同名字的控制文件,而不会产生第三个不同编号的,所以没搞懂难道这也有限制?
9#
发表于 2012-1-21 18:18:43
今天mount 实验环境的 11gR2 RAC时出现了ORA-01104: number of control files (3) does not equal 2错误:



SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-01105: mount is incompatible with mounts by other instances
ORA-01104: number of control files (3) does not equal 2


[oracle@vrh2 ~]$ oerr ora 1104
01104, 00000, "number of control files (%s) does not equal %s"
// *Cause:  The number of control files used by this instance disagrees with
//         the number of control files in an existing instance.
// *Action: Check to make sure that all control files are listed.


主要RAC各节点之间的control_files 参数必须一致


instance 1:
control_files                        string      +DATA/vprod/controlfile/curren
                                                 t.261.766620025, +DATA/vprod/c
                                                 ontrolfile/current.260.7666200
                                                 25


instance 2:

control_files                        string      +DATA/vprod/controlfile/curren
                                                 t.261.766620025, +DATA/vprod/c
                                                 ontrolfile/current.260.7666200
                                                 25, +DATA/vprod/controlfile/cu
                                                 rrent.maclean


这样就可能引发ORA-01104 ,  记以录之

回复 只看该作者 道具 举报

8#
发表于 2012-1-11 22:03:17
原帖由 lhl1212 于 2012-1-11 21:57 发表
在mount状态下使用ALTER DATABASE BACKUP CONTROLFILE TO filename对控制文件进行备份到dg,然后再改control_files参数,再重启。


这倒是个好思路,但是我就没搞明白官方的文档,为什么复制不出第三个,太神奇了

回复 只看该作者 道具 举报

7#
发表于 2012-1-11 21:57:11
在mount状态下使用ALTER DATABASE BACKUP CONTROLFILE TO filename对控制文件进行备份到dg,然后再改control_files参数,再重启。

回复 只看该作者 道具 举报

6#
发表于 2012-1-11 21:55:13
原帖由 caihuazhg 于 2012-1-11 21:36 发表
1. Modify the spfile specifically the parameter control_files. In this example, a second controlfile
is going to be created on same diskgroup DATA1.
sql> alter system set control_files='+DATA1/v102/co ...


我没看到那里可以配置三个啊,事实上我复制完第二个后,我猜想这样做才能复制出第三个来,但是如何也不行
alter system set control_files='+DATA1/v102/controlfile/current.261.637923577', ’+DATA1/v102/controlfile/current.269.638120375‘,'+DATA1' scope=spfile sid='*';
做完上面语句,然后再rman去复制,我想着应该产生第三个
restore controlfile from '+DATA1/v102/controlfile/current.261.637923577';
但是还是来回在两个中间相互复制循环,并不产生第三个新的
难道我应该:restore controlfile from '+DATA1/v102/controlfile/current.261.637923577',+DATA1/v102/controlfile/current.269.638120375‘;才能产生第三个?
我还是没搞明白那里设置不对?

回复 只看该作者 道具 举报

5#
发表于 2012-1-11 21:52:05
if there is no cp command available , try DBMS_FILE_TRANSFER in 10g
http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_ftran.htm

回复 只看该作者 道具 举报

4#
发表于 2012-1-11 21:41:06
As we demonstrate:
  1.                                                                                                  
  2. SQL> show parameter control_files

  3. NAME                                 TYPE        VALUE
  4. ------------------------------------ ----------- ------------------------------
  5. control_files                        string      +DATA/vprod/controlfile/curren
  6.                                                  t.261.766620025, +DATA/vprod/c
  7.                                                  ontrolfile/current.260.7666200
  8.                                                  25

  9. shutdown immediate;
  10. startup mount;


  11. su - grid
  12. [grid@vrh2 ~]$ asmcmd
  13. ASMCMD> cd data
  14. ASMCMD> ls
  15. ASM/
  16. VPROD/
  17. data1.bak
  18. ASMCMD> cd VPROD
  19. ASMCMD> cd control
  20. ASMCMD-8002: entry 'control' does not exist in directory '+data/VPROD/'
  21. ASMCMD> cd controlfile
  22. ASMCMD> ls
  23. Backup.393.772331479
  24. Backup.394.772331417
  25. Backup.481.769484083
  26. Current.260.766620025
  27. Current.261.766620025
  28. ASMCMD> cp Current.260.766620025 Current.maclean      
  29. copying +data/VPROD/controlfile/Current.260.766620025 -> +data/VPROD/controlfile/Current.maclean
  30. ASMCMD> ls
  31. Backup.393.772331479
  32. Backup.394.772331417
  33. Backup.481.769484083
  34. Current.260.766620025
  35. Current.261.766620025
  36. Current.maclean



  37. SQL>  alter system set control_files='+DATA/vprod/controlfile/current.261.766620025','+DATA/vprod/controlfile/current.260.766620025','+DATA/vprod/controlfile/current.maclean' scope=spfile;

  38. System altered.

  39. SQL> startup force mount;
  40. ORACLE instance started.

  41. Total System Global Area 1043886080 bytes
  42. Fixed Size                  2234960 bytes
  43. Variable Size             784336304 bytes
  44. Database Buffers          251658240 bytes
  45. Redo Buffers                5656576 bytes
  46. Database mounted.                                                                                                 
  47.                                                                                                  
  48.                                                                                                  
  49. SQL> show parameter control_files

  50. NAME                                 TYPE        VALUE
  51. ------------------------------------ ----------- ------------------------------
  52. control_files                        string      +DATA/vprod/controlfile/curren
  53.                                                  t.261.766620025, +DATA/vprod/c
  54.                                                  ontrolfile/current.260.7666200
  55.                                                  25, +DATA/vprod/controlfile/cu
  56.                                                  rrent.maclean
复制代码

回复 只看该作者 道具 举报

3#
发表于 2012-1-11 21:36:19
1. Modify the spfile specifically the parameter control_files. In this example, a second controlfile
is going to be created on same diskgroup DATA1.
sql> alter system set control_files='+DATA1/v102/controlfile/current.261.637923577','+DATA1'
scope=spfile sid='*';

2. Start the instance in NOMOUNT mode.
3. From rman, duplicate the controlfile
$ rman nocatalog
RMAN>connect target
RMAN> restore controlfile from '+DATA1/v102/controlfile/current.261.637923577';

metelink上的改control_files 指定了2个控制文件,所以
restore完成后是
output filename=+DATA1/v102/controlfile/current.261.637923577
output filename=+DATA1/v102/controlfile/current.269.638120375


你再修改control_files 指定了几个控制文件

回复 只看该作者 道具 举报

2#
发表于 2012-1-11 21:26:38
完整的官方How to duplicate a controlfile when ASM is involved [ID 345180.1]

How to duplicate a controlfile when ASM is involved [ID 345180.1]
      修改时间 08-NOV-2011     类型 HOWTO     状态 PUBLISHED      

In this Document
  Goal
  Solution
  References

Applies to:
Oracle Server - Enterprise Edition - Version: 10.1.0.2 to 11.1.0.7 - Release: 10.1 to 11.1
Information in this document applies to any platform.
Checked for relevance on 04-May-2009
Goal

This document presents different options to duplicate a controlfile in environments using ASM.  The procedure applies either to duplicate a controlfile into ASM using a controlfile stored in file system or to duplicate a controlfile into ASM using a controlfile already stored in ASM.

For standby set up, refer to MOS Doc ID 734862.1
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$controlfile;

    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


We are only specifying the name of the diskgroup, so Oracle will create an OMF (Oracle Managed File).  Use ASMCMD or sqlplus to identify the name assigned 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 starts with the backup word, that does not indicate is a backup of the file.  This just the name assigned for the identical copy of the current controlfile.

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 set control_files='+DG1/P10R2/CONTROLFILE/backup.308.577785757','/oradata2/102b/oradata/P10R2/control01.ctl' scope=spfile;

            For RAC instance:

            alter system set control_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 new controlfile was not used, the complete procedure needs to be repeated.

Duplicating a controlfile into ASM  using a specific name

It is also possible to duplicate the controlfile using a specific name for the new controlfile.  In the following example, the controlfile is duplicated into a new diskgroup where   controlfiles have not been created 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 created automatically when using OMF files. (just specifying the diskgroup name).  Asumming that other OMF files were created on the diskgroup, the first directory (DB_NAME) already exist, so it is only required to create 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 indicate there were created two controlfiles.  The name specified is an alias name and is only an entry in the ASM metadata (V$ASM_ALIAS). Oracle will create the alias and the OMF entry when user specifies the file name.

-----------------------------这里才是适用我环境的情况---------begin--------------------------------------------------
Duplicating a controlfile into ASM when original controlfile is stored on ASM

If using spfile to start the instance:

1. Modify the spfile specifically the parameter control_files. In this example, a second controlfile
is going to be created on same diskgroup DATA1.

sql> alter system set control_files='+DATA1/v102/controlfile/current.261.637923577','+DATA1'
scope=spfile sid='*';


2. Start the instance in NOMOUNT mode.

3. From rman, duplicate the controlfile
$ rman nocatalog
RMAN>connect target
RMAN> restore controlfile from '+DATA1/v102/controlfile/current.261.637923577';


The output for the execution is like:

Starting restore at 08-NOV-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=147 instance=V1021 devtype=DISK

channel ORA_DISK_1: copied control file copy
output filename=+DATA1/v102/controlfile/current.261.637923577
output filename=+DATA1/v102/controlfile/current.269.638120375
Finished restore at 08-NOV-07

Note that the command prints the name of the new created file: +DATA1/v102/controlfile/current.269.638120375

4. Modify the control_file parameter with the complete path of the new file:


sql> alter system set control_files='+DATA1/v102/controlfile/current.261.637923577','+DATA1/v102/controlfile/current.269.638120375'
scope=spfile sid='*';



5. Mount and Open the database

RMAN> sql 'alter database mount';
RMAN> sql 'alter database open';


6. Validate both controlfiles are present
SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
+DATA1/v102/controlfile/current.261.637923577
+DATA1/v102/controlfile/current.269.638120375



Next time instance are restarted, will pick both files.


-----------------------------这里才是适用我环境的情况---------end--------------------------------------------------
When using init.ora file:


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

Example:

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


(2) Start the instance in NOMOUNT mode.

(3)  Execute restore command, to duplicate the controlfile using the original location. Presuming, your current controlfile location DISK path 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




References
NOTE:390416.1 - How to move a datafile from ASM to the file system
NOTE:944831.1 - How to Copy Archivelog Files From ASM to Filesystem and vice versa

[ 本帖最后由 javaio 于 2012-1-11 21:27 编辑 ]

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-12-23 23:50 , Processed in 0.051793 second(s), 22 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569