首页 » ORACLE » 迁移controlfile 从文件系统到ASM

迁移controlfile 从文件系统到ASM

迁移controlfile 从文件系统到ASM

1,查看当前的ControlFile目录

SQL> select * from v$controlfile;

STATUS  NAME                                                         IS_ BLOCK_SIZE FILE_SIZE_BLKS
------- ------------------------------------------------------------ --- ---------- --------------
        /u01/app/oracle/admin/anbob/controlfile/anbob01.ctl          NO       16384            594
        /u01/app/oracle/admin/anbob/controlfile/anbob02.ctl          NO       16384            594

2,查看可用asm diskgroup

SQL> select name,total_mb,free_mb from v$asm_diskgroup;

NAME                                                           TOTAL_MB    FREE_MB
------------------------------------------------------------ ---------- ----------
DATA                                                               9201       4176

3,restart db到nomount状态
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.

4,切到rman复制controlfile,并做两个冗余

RMAN> restore controlfile to '+DATA' from '/u01/app/oracle/admin/anbob/controlfile/anbob01.ctl';

Starting restore at 11-SEP-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: copied control file copy
Finished restore at 11-SEP-12

RMAN> restore controlfile to '+DATA' from '/u01/app/oracle/admin/anbob/controlfile/anbob01.ctl';
RMAN> restore controlfile to '+DATA' from '/u01/app/oracle/admin/anbob/controlfile/anbob01.ctl';

5,切换到ASM OWNER用户,查看生成的controlfile 文件名

[oracle@rac1 controlfile]$ su - grid
[grid@rac1 ~]$ asmcmd
ASMCMD> ls
DATA/

tip:
usage: find [--type ]  

[grid@rac1 ~]$ asmcmd
ASMCMD> find --type controlfile . *
+DATA/ANBOB/CONTROLFILE/current.260.793738081
+DATA/ANBOB/CONTROLFILE/current.261.793738087
+DATA/ANBOB/CONTROLFILE/current.276.793737555
ASMCMD> cd DATA/ANBOB/CONTROLFILE/
ASMCMD> ls -l
Type         Redund  Striped  Time             Sys  Name
CONTROLFILE  HIGH    FINE     SEP 11 18:00:00  Y    current.260.793738081
CONTROLFILE  HIGH    FINE     SEP 11 18:00:00  Y    current.261.793738087
CONTROLFILE  HIGH    FINE     SEP 11 18:00:00  Y    current.276.793737555

6,切到数据库,修改controlfile路径,如果是pfile,用文件编辑工具修改control_files值,如果是用spfile,执行下面的命令

SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA/anbob/spfileanbob.ora
SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      /u01/app/oracle/admin/anbob/co
                                                 ntrolfile/anbob01.ctl, /u01/ap
                                                 p/oracle/admin/anbob/controlfi
                                                 le/anbob02.ctl
control_management_pack_access       string      DIAGNOSTIC+TUNING

SQL> alter system set control_files='+DATA/ANBOB/CONTROLFILE/current.260.793738081','+DATA/ANBOB/CONTROLFILE/current.261.793738087','+DATA/ANBOB/CONTROLFILE/current.276.793737555' scope=spfile;

7,重启打开数据库并验证controlfile 路径

SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  523108352 bytes
Fixed Size                  1337632 bytes
Variable Size             415237856 bytes
Database Buffers          100663296 bytes
Redo Buffers                5869568 bytes
Database mounted.
Database opened.
SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      +DATA/anbob/controlfile/curren
                                                 t.260.793738081, +DATA/anbob/c
                                                 ontrolfile/current.261.7937380
                                                 87, +DATA/anbob/controlfile/cu
                                                 rrent.276.793737555

8,删除原控制文件,已旧
[oracle@rac1 controlfile]$ rm /u01/app/oracle/admin/anbob/controlfile/anbob01.ctl
[oracle@rac1 controlfile]$ rm /u01/app/oracle/admin/anbob/controlfile/anbob02.ctl

打赏

对不起,这篇文章暂时关闭评论。