使用RMAN迁移文件系统数据库到ASM

--==================================

-- 使用RMAN移文件系统数ASM

--==================================

 

    实际的工作程中,由于ASM管理的便利性,因此很多候需要文件系库迁移到ASM,本文演示了如何文件系统数库迁移到ASM例。

    如何ASM例及ASM管理请参

        ASM例及

        ASM 盘组及磁的管理

        使用 ASMCMD 工具管理ASM

       

一、主要步(假定ASM例已)

    1.算目标数(文件系)的大小

    2.根据目标数的大小,ASM()可用磁

    3.为辅配置初始化参数文件,密文件,建目

    4.备份标数

    5.移目标数

       

二、

    本次移在同一台主机实现,因此采用不同的ORACLE_SID

    境:Oracle Linux 5.4 + Oracle 10g R2

    标数orcl

    orclasm

   

    1.算目标数(文件系)的大小

        SQL> show parameter db_name

       

        NAME                                 TYPE        VALUE

        ------------------------------------ ----------- ------------------------------

        db_name                              string      orcl

       

        SQL> select * from v$version where rownum<2;

       

        BANNER

        ----------------------------------------------------------------

        Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod

   

        SQL> select sum(bytes)/1024/1024 ||'MB' from dba_segments;

       

        SUM(BYTES)/1024/1024||'MB'

        ------------------------------------------

        1195.5MB       

   

    2.为辅可用空,下面DG1中有3016MB可用空,可以移的需要

        ASMCMD> ls -s

        Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name

           512   4096  1048576      6134     6032                0            3016              0  DG1/

           512   4096  1048576      2047     1997                0            1997              0  REV/

       

    3.配置

        a.启动标数并为标数库创pfile

            [oracle@oradb ~]$ echo $ORACLE_SID

            orcl

            [oracle@oradb ~]$ sqlplus / as sysdba

           

            idle> startup

            sys@ORCL> create pfile from spfile;

       

        b.制目标数pfile生成pfile并对行修改

            [oracle@oradb dbs]$ cd $ORACLE_HOME/dbs

            [oracle@oradb dbs]$ cp initorcl.ora initorclasm.ora

           

            修改initorclasm.ora

                文件中所有的orcl使用替命令替换为orclasm(使用vi工具 :%s/orcl/orclasm/g)

                修改控制文件1(DG1使用了normal redundancy),路径为'+DG1/orclasm/controlfile/'--使用ASM注意目录结构

                修改db_recovery_file_dest径为'+REV'

                修改log_archive_dest_1径为'LOCATION=+REV/orclasm'

                修改db_create_file_dest径为'+DG1'

                增加下列参数()

                    *.db_file_name_convert=("orcl","orclasm")

                    *.log_file_name_convert=("orcl","orclasm")

 

            下面列出化的几重要参数

                *.audit_file_dest='/u01/app/oracle/admin/orclasm/adump'

                *.background_dump_dest='/u01/app/oracle/admin/orclasm/bdump'

                *.control_files='+DG1/orclasm/controlfile/control01.ctl'

                *.core_dump_dest='/u01/app/oracle/admin/orclasm/cdump'

                *.db_name='orclasm'

                *.db_recovery_file_dest='+REV/orclasm'

                *.log_archive_dest_1='LOCATION=+REV/orclasm'           

                *.user_dump_dest='/u01/app/oracle/admin/orclasm/udump'

                *.db_create_file_dest='+DG1'

                *.db_file_name_convert=("orcl","orclasm")

                *.log_file_name_convert=("orcl","orclasm")

 

        c.根据刚刚修改参数创建目

            [oracle@oradb ~]$ mkdir -p $ORACLE_BASE/admin/orclasm/{a,b,c,u}dump

            [oracle@oradb ~]$ ls $ORACLE_BASE/admin/orclasm

            adump  bdump  cdump  udump

   

        d.建密文件

            [oracle@oradb dbs]$ orapwd file=$ORACLE_HOME/dbs/orapworclasm password=oracle entries=8

       

    4.备份标数      

        a.标数库应处归档模式下

            SQL> select name,log_mode from v$database;

 

            NAME      LOG_MODE

            --------- ------------

            ORCL      ARCHIVELOG   

       

        b.接到RMAN并进备份,此使用了非catalog方式

            [oracle@oradb ~]$ uniread rman target sys/oracle@orcl nocatalog

 

            RMAN> crosscheck archivelog all;       --验归档日志

 

            RMAN> delete expired archivelog all;   --无效的归档日志

 

            RMAN> report obsolete;

 

            RMAN> delete noprompt obsolete;        --弃的备份

 

            RMAN> show channel;                    --看缺省的备份

 

            RMAN configuration parameters are:

            CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/bk/orcl/data_%d_%U';

 

            RMAN> show controlfile autobackup;    --看控制文件的自动备份启用情

 

            using target database control file instead of recovery catalog

            RMAN configuration parameters are:

            CONFIGURE CONTROLFILE AUTOBACKUP ON;

 

            RMAN> show controlfile autobackup format;   --看控制文件的备份、格式

 

            RMAN configuration parameters are:

            CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/bk/orcl/auto_ctl_%d_%F';

 

            RMAN> run{     --标数库进备份,此备份为0增量包含了归档日志,控制文件spfile动备份

            2> allocate channel ch1 device type disk;

            3> backup as compressed backupset

            4> incremental level 0 database format '/u01/bk/orcl/data_%d_%U'

            5> plus archivelog format '/u01/bk/orcl/bk_lg_%U'

            6> tag='Inc0_log';

            7> release channel ch1;}      

 

    5.移目标数据到ASM

        a.看目标数SEQUENCE10,便于恢复时指定SEQUENCE

            SQL> select * from v$log;  

           

                GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

            ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

                     1          1          9   52428800          1 YES ACTIVE                  520445 30-OCT-10

                     2          1         10   52428800          1 NO  CURRENT                 520585 30-OCT-10

        

        b.看目标数据文件的相息,后需要datafile指定文件名

            RMAN> report schema;

 

            Report of database schema

           

            List of Permanent Datafiles

            ===========================

            File Size(MB) Tablespace           RB segs Datafile Name

            ---- -------- -------------------- ------- ------------------------

            1    480      SYSTEM               ***     /u01/app/oracle/oradata/orcl/system01.dbf

            2    25       UNDOTBS1             ***     /u01/app/oracle/oradata/orcl/undotbs01.dbf

            3    240      SYSAUX               ***     /u01/app/oracle/oradata/orcl/sysaux01.dbf

            4    5        USERS                ***     /u01/app/oracle/oradata/orcl/users01.dbf

            5    100      EXAMPLE              ***     /u01/app/oracle/oradata/orcl/example01.dbf

           

            List of Temporary Files

            =======================

            File Size(MB) Tablespace           Maxsize(MB) Tempfile Name

            ---- -------- -------------------- ----------- --------------------

            1    20       TEMP                 32767       /u01/app/oracle/oradata/orcl/temp01.dbf

 

        c.asm例是否已正常提供服,以及磁状态并启动新的orclasm

            SQL> show parameter instance_name

           

            NAME                                 TYPE        VALUE

            ------------------------------------ ----------- ------------------------------

            instance_name                        string      +ASM

           

            SQL> select group_number,name,state,type,total_mb,free_mb,usable_file_mb from v$asm_diskgroup;

           

            GROUP_NUMBER NAME                           STATE       TYPE     TOTAL_MB    FREE_MB USABLE_FILE_MB

            ------------ ------------------------------ ----------- ------ ---------- ---------- --------------

                       1 DG1                            MOUNTED     NORMAL       6134       6032           3016

                       2 REV                            MOUNTED     EXTERN       2047       1997           1997

       

        d.启动辅nomount状态  

            [oracle@oradb ~]$ export ORACLE_SID=orclasm

            [oracle@oradb ~]$ sqlplus / as sysdba

 

            idle> startup nomount

            ORACLE instance started.

 

        e.使用RMAN接到目标数库来完成

            [oracle@oradb dbs]$ rman auxiliary / target sys/redhat@orcl

            connected to target database: ORCL (DBID=1263182651)

            connected to auxiliary database: ORCLASM (not mounted)

 

            RMAN> run {

            2> allocate auxiliary channel ach1 device type disk;

            3> set until sequence 10 thread 1;

            4> set newname for datafile 1 to '+DG1';

            5> set newname for datafile 2 to '+DG1';

            6> set newname for datafile 3 to '+DG1';

            7> set newname for datafile 4 to '+DG1';

            8> set newname for datafile 5 to '+DG1';

            9> set newname for tempfile 1 to '+DG1';

            10>  duplicate target database to orclasm logfile

            11>  group 1('+DG1') size 5m reuse,

            12>  group 2('+DG1') size 5m reuse;

            13>  }

   

            contents of Memory Script:

            {

               Alter clone database open resetlogs;

            }

            executing Memory Script

           

            database opened

            Finished Duplicate Db at 30-OCT-10

   

    6.续处

        a.库状态并关闭数

            [oracle@oradb ~]$ export ORACLE_SID=orclasm

            [oracle@oradb ~]$ sqlplus / as sysdba

            SQL> select name,open_mode from v$database;

           

            NAME      OPEN_MODE

            --------- ----------

            ORCLASM   READ WRITE

           

            SQL> shutdown immediate;

       

        b.使用vi工具编辑initorclasm.ora   

            除下列参数

            *.db_file_name_convert=("orcl","orclasm")

            *.log_file_name_convert=("orcl","orclasm")

   

        c.启动数库并创spfile

            SQL> startup

               

            SQL> create spfile from pfile;

               

            SQL> startup force;  --如果是生产库shutdown immediate,然后startup

   

    7.验证迁

        SQL> show parameter db_name

       

        NAME                                 TYPE        VALUE

        ------------------------------------ ----------- ------------------------------

        db_name                              string      orclasm

        SQL> col name format a60

        SQL> select name,status from v$datafile;

       

        NAME                                                         STATUS

        ------------------------------------------------------------ -------

        +DG1/orclasm/datafile/system.256.752170937                   SYSTEM

        +DG1/orclasm/datafile/undotbs1.259.752170937                 ONLINE

        +DG1/orclasm/datafile/sysaux.257.752170937                   ONLINE

        +DG1/orclasm/datafile/users.260.752170937                    ONLINE

        +DG1/orclasm/datafile/example.258.752170937                  ONLINE

 

        SQL> select * from v$log;

       

            GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

        ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

                 1          1          5    5242880          2 YES INACTIVE                563716 27-MAY-11

                 2          1          6    5242880          2 NO  CURRENT                 583985 27-MAY-11

                

        SQL> select * from v$logfile;

       

            GROUP# STATUS  TYPE    MEMBER                                             IS_

        ---------- ------- ------- -------------------------------------------------- ---

                 2         ONLINE  +DG1/orclasm/onlinelog/group_2.263.752171103       NO

                 1 STALE   ONLINE  +DG1/orclasm/onlinelog/group_1.262.752171103       NO

                 1 STALE   ONLINE  +REV/orclasm/onlinelog/group_1.256.752171103       YES

                 2         ONLINE  +REV/orclasm/onlinelog/group_2.257.752171105       YES

                

        SQL> select file#,creation_change#, status,enabled,bytes,name from v$tempfile;

       

             FILE# CREATION_CHANGE# STATUS  ENABLED         BYTES NAME

        ---------- ---------------- ------- ---------- ---------- --------------------------------------------------

                 1           464714 ONLINE  READ WRITE   20971520 +DG1/orclasm/tempfile/temp.264.752171113  

       

        --如果在使用duplicate时没有生成tempfile文件,可以使用下面的方式添加tempfile文件。

            alter tablespace temp add tempfile '+DG1' size 100m autoextend off;      

           

        --可以添加归档修改一下归档

        --接到ASM归档

       

        SQL> select instance_name,status from v$instance;

       

        INSTANCE_NAME                  STATUS

        ------------------------------ ------------

        +ASM                           STARTED

       

        SQL> alter diskgroup REV add directory '+REV/orclasm/arch';

        

        Diskgroup altered.

       

        --orclasm例中修改归档

        SQL> select instance_name,status from v$instance;

       

        INSTANCE_NAME    STATUS

        ---------------- ------------

        orclasm          OPEN

       

        SQL> alter system set log_archive_dest_1='LOCATION=+REV/orclasm/arch';

       

        System altered.

       

        SQL> select name from v$archived_log where rownum<2 order by stamp;

       

        NAME

        --------------------------------------------------

        +REV/orclasm/1_1_752171102.arc

 

三、快捷参考


性能请参

    Oracle 硬解析与软解析

    共享池的与优(Shared pool Tuning)

    Buffer cache 与优(一)

    Oracle (caching table)的使用

 

ORACLE体系结构请参

    Oracle 表空间与数据文件

    Oracle 文件

    Oracle 参数文件

    Oracle 机重做日志文件(ONLINE LOG FILE)

    Oracle 控制文件(CONTROLFILE)

    Oracle 归档日志

    Oracle (ROLLBACK)和撤(UNDO)

    Oracle 库实启动关闭过

    Oracle 10g SGA 的自化管理

    Oracle 例和Oracle(Oracle体系结构)

 

关闪回特性请参

    Oracle 回特性(FLASHBACK DATABASE)

    Oracle 回特性(FLASHBACK DROP & RECYCLEBIN)

    Oracle 回特性(Flashback Query、Flashback Table)

    Oracle 回特性(Flashback Version、Flashback Transaction)

 

基于用管理的备份备份请参

    Oracle 备份

    Oracle 热备份

    Oracle 备份复概

    Oracle 例恢

    Oracle 基于用管理恢(详细描述了介及其)

    SYSTEM 表空管理及备份

    SYSAUX表空管理及恢

 

RMAN备份复与管理请参

    RMAN 述及其体系结构

    RMAN 配置、管理

    RMAN 备份详

    RMAN

    RMAN catalog 建和使用

    基于catalog RMAN脚本

    基于catalog 的RMAN 备份与

    RMAN 备份困惑(使用plus archivelog)

 

ORACLE故障请参

    ORA-32004 错误处

    ORA-01658 错误

    CRS-0215 错误处

    ORA-00119,ORA-00132 错误处

    又一例SPFILE错误导无法启动

    对参数FAST_START_MTTR_TARGET = 0 解及

    SPFILE 错误导无法启动(ORA-01565)

 

ASM请参

    ASM例及ASM

    ASM 、目的管理

    使用 ASMCMD 工具管理ASM及文件

 

SQL/PLSQL请参

    SQLPlus 常用命令

    替代SQL*Plus

    使用Uniread实现SQLplus功能

    SQL -->SELECT 查询

    SQL --> NEW_VALUE 的使用

    SQL --> 集合(UNION UNION ALL)

    SQL --> 常用函

    SQL --> 视图(CREATE VIEW)

    SQL --> 建和管理表

    SQL --> 多表查询

    SQL --> 过滤和排序

    SQL --> 查询

    SQL --> 组与

    SQL --> 次化查询(START BY ... CONNECT BY PRIOR)

    SQL --> ROLLUPCUBE算符实现数汇总

    PL/SQL -->

    PL/SQL --> (Exception)

    PL/SQL --> 言基

    PL/SQL --> 流程控制

    PL/SQL --> PL/SQL记录

    PL/SQL --> 包的管理

    PL/SQL --> 式游(SQL%FOUND)

    PL/SQL --> 包重、初始化

    PL/SQL --> DBMS_DDL包的使用

    PL/SQL --> DML 触发

    PL/SQL --> INSTEAD OF 触发

    PL/SQL --> 储过

    PL/SQL -->

    PL/SQL --> 动态SQL

    PL/SQL --> 动态SQL的常见错误

 

ORACLE特性

    Oracle 常用目录结构(10g)

    使用OEM,SQL*Plus,iSQL*Plus 管理Oracle

    日志记录模式(LOGGING 、FORCE LOGGING 、NOLOGGING)

    表段、索引段上的LOGGINGNOLOGGING

    Oralce OMF 功能

    Oracle 限、系统权  

    Oracle 角色、配置文件

    Oracle

    Oracle 外部表

    使用外部表管理Oracle 告警日志(ALAERT_$SID.LOG)

    簇表及簇表管理(Index clustered tables)

    EXPDP 出工具的使用

    IMPDP 入工具的使用

    Oracle

    SQL*Loader使用方法

    用用户进程跟踪

    配置非默端口的动态

    配置ORACLE 接到

    system sys,sysoper sysdba 区别

    ORACLE_SID、DB_NAME、INSTANCE_NAME、DB_DOMIAN、GLOBAL_NAME

    Oracle 丁全集 (Oracle 9i 10g 11g Path)

    Oracle 10.2.0.1 10.2.0.4

    Oracle kill session


 

 

                            

posted @ 2011-05-30 08:40  生活不是用来挥霍的  阅读(331)  评论(0编辑  收藏  举报