设为首页 收藏本站
查看: 605|回复: 0

[经验分享] 将oracle数据库从32位平台迁移到64位

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-11-7 09:34:35 | 显示全部楼层 |阅读模式
客户的32位oracle数据库系统磁盘出现损坏,庆幸的是oracle数据库完好无损。客户要求将数据库迁移到新购的设备上,新设备内存为64G,系统REDHAT 6.2 64位,直接拷贝数据文件肯定是不行的,因为oracle 的存储过程在32位和64位平台下的wordsize不同,虽然用户的存储过程可以在使用时自行完成重新编译,但oracle的系统存储过程确需要我们来手工转换。

总结,迁移过程如下:

1:备份oracle数据库

2:备份控制文件到trace(以备需要新建控制文件)



    SQL> alter database backup controlfile to trace;  
      
    Database altered.  
      
    SQL> oradebug setmypid  
    Statement processed.  
    SQL> oradebug tracefile_name  
    /u01/app/admin/easy/udump/easy_ora_18830.trc  
    SQL> host cat /u01/app/admin/easy/udump/easy_ora_18830.trc  
    ......  
    --  
    --     Set #1. NORESETLOGS case  
    --  
    -- The following commands will create a new control file and use it  
    -- to open the database.  
    -- Data used by Recovery Manager will be lost.  
    -- Additional logs may be required for media recovery of offline  
    -- Use this only if the current versions of all online logs are  
    -- available.  
    -- After mounting the created controlfile, the following SQL  
    -- statement will place the database in the appropriate  
    -- protection mode:  
    --  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE  
    STARTUP NOMOUNT  
    CREATE CONTROLFILE REUSE DATABASE "EASY" NORESETLOGS  NOARCHIVELOG  
        MAXLOGFILES 16  
        MAXLOGMEMBERS 3  
        MAXDATAFILES 100  
        MAXINSTANCES 8  
        MAXLOGHISTORY 292  
    LOGFILE  
      GROUP 1 '/oradata/easy/redo01.log'  SIZE 11200K,  
      GROUP 2 '/oradata/easy/redo02.log'  SIZE 11200K  
    -- STANDBY LOGFILE  
    DATAFILE  
      '/oradata/easy/system01.dbf',  
      '/oradata/easy/undotbs01.dbf',  
      '/oradata/easy/sysaux01.dbf',  
      '/oradata/easy/users01.dbf'  
    CHARACTER SET ZHS16GBK  
    ;  
    -- Commands to re-create incarnation table  
    -- Below log names MUST be changed to existing filenames on  
    -- disk. Any one log file from each branch can be used to  
    -- re-create incarnation records.  
    -- ALTER DATABASE REGISTER LOGFILE '/u01/app/flash_recovery_area/EASY/archivelog/2014_11_05/o1_mf_1_1_%u_.arc';  
    -- ALTER DATABASE REGISTER LOGFILE '/u01/app/flash_recovery_area/EASY/archivelog/2014_11_05/o1_mf_1_1_%u_.arc';  
    -- Recovery is required if any of the datafiles are restored backups,  
    -- or if the last shutdown was not normal or immediate.  
    RECOVER DATABASE  
    -- Database can now be opened normally.  
    ALTER DATABASE OPEN;  
    -- Commands to add tempfiles to temporary tablespaces.  
    -- Online tempfiles have complete space information.  
    -- Other tempfiles may require adjustment.  
    ALTER TABLESPACE TEMP ADD TEMPFILE '/oradata/easy/temp01.dbf'  
         SIZE 20971520  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;  
    -- End of tempfile additions.  
    --  
    --     Set #2. RESETLOGS case  
    --  
    -- The following commands will create a new control file and use it  
    -- to open the database.  
    -- Data used by Recovery Manager will be lost.  
    -- The contents of online logs will be lost and all backups will  
    -- be invalidated. Use this only if online logs are damaged.  
    -- After mounting the created controlfile, the following SQL  
    -- statement will place the database in the appropriate  
    -- protection mode:  
    --  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE  
    STARTUP NOMOUNT  
    CREATE CONTROLFILE REUSE DATABASE "EASY" RESETLOGS  NOARCHIVELOG  
        MAXLOGFILES 16  
        MAXLOGMEMBERS 3  
        MAXDATAFILES 100  
        MAXINSTANCES 8  
        MAXLOGHISTORY 292  
    LOGFILE  
      GROUP 1 '/oradata/easy/redo01.log'  SIZE 11200K,  
      GROUP 2 '/oradata/easy/redo02.log'  SIZE 11200K  
    -- STANDBY LOGFILE  
    DATAFILE  
      '/oradata/easy/system01.dbf',  
      '/oradata/easy/undotbs01.dbf',  
      '/oradata/easy/sysaux01.dbf',  
      '/oradata/easy/users01.dbf'  
    CHARACTER SET ZHS16GBK  
    ;  
    -- Commands to re-create incarnation table  
    -- Below log names MUST be changed to existing filenames on  
    -- disk. Any one log file from each branch can be used to  
    -- re-create incarnation records.  
    -- ALTER DATABASE REGISTER LOGFILE '/u01/app/flash_recovery_area/EASY/archivelog/2014_11_05/o1_mf_1_1_%u_.arc';  
    -- ALTER DATABASE REGISTER LOGFILE '/u01/app/flash_recovery_area/EASY/archivelog/2014_11_05/o1_mf_1_1_%u_.arc';  
    -- Recovery is required if any of the datafiles are restored backups,  
    -- or if the last shutdown was not normal or immediate.  
    RECOVER DATABASE USING BACKUP CONTROLFILE  
    -- Database can now be opened zeroing the online logs.  
    ALTER DATABASE OPEN RESETLOGS;  
    -- Commands to add tempfiles to temporary tablespaces.  
    -- Online tempfiles have complete space information.  
    -- Other tempfiles may require adjustment.  
    ALTER TABLESPACE TEMP ADD TEMPFILE '/oradata/easy/temp01.dbf'  
         SIZE 20971520  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;  
    -- End of tempfile additions.  
    --  

3: 查看当前的数据库状态



    SQL> select count(*) from dba_objects where status ='INVALID';  
      
      COUNT(*)  
    ----------  
         0  
      
    SQL> select comp_name,status from dba_registry;  
      
    COMP_NAME                STATUS  
    ---------------------------------------- ----------------------  
    Oracle Database Catalog Views        VALID  
    Oracle Database Packages and Types   VALID  
    Oracle Workspace Manager         VALID  
    JServer JAVA Virtual Machine         VALID  
    Oracle XDK               VALID  
    Oracle Database Java Packages        VALID  
    Oracle Expression Filter         VALID  
    Oracle Data Mining           VALID  
    Oracle Text              VALID  
    Oracle XML Database          VALID  
    Oracle Rules Manager             VALID  
      
    COMP_NAME                STATUS  
    ---------------------------------------- ----------------------  
    Oracle interMedia            VALID  
    OLAP Analytic Workspace          VALID  
    Oracle OLAP API              VALID  
    OLAP Catalog                 VALID  
    Spatial                  VALID  
    Oracle Enterprise Manager        VALID  
      
    17 rows selected.  

        4:拷贝参数文件,控制文件,数据文件,日志文件到64位数据库

        5:在64位系统上创建相应目录,如udmp  adump等,要和32位系统一致

        6:如果数据库的数据文件目录发生变化,则需要新建控制文件,(最好保持源库和目标库的一致,减少工作量和错误发生率)

        7:将数据库中的存储过程等置为失效,UTLIRP脚本会将存储过程等置为失效



    <span style="white-space:pre">    </span>--如果迁移的是oracle9i的数据库,执行如下命令:  
        SQL> STARTUP MIGRATE   
      
        --如果是Oracle10g或11g,执行如下命令:  
        SQL> STARTUP UPGRADE   
         
        SQL> SPOOL EASY.log;  
        SQL> @$ORACLE_HOME/rdbms/admin/utlirp.sql   
        SQL> SPOOL OFF;     

8: 重新启动数据库,

9: 如果数据库有OLAP组件,则删除OLAP,以sys用户执行如下脚本



    SQL> conn / as sysdba  
      
    ----> Remove OLAP Catalog  
    SQL> @?/olap/admin/catnoamd.sql  
      
    ----> Remove OLAP API  
    SQL> @?/olap/admin/olapidrp.plb  
    SQL> @?/olap/admin/catnoxoq.sql  
      
    ----> Deinstall APS - OLAP AW component  
    SQL> @?/olap/admin/catnoaps.sql  
    SQL> @?/olap/admin/cwm2drop.sql   ---只需要在11g中执行。在10g中,catnoamd.sql 脚本中已经包含了该脚本,所以不用执行  
      
    You could getsome invalid objects under SYS and PUBLIC owner, and they are the old duplicate OLAPSYS objects copied under these schemas when Olap has been installedpreviously.  
    Generally, theOlap objects are named with context like %OLAP%, %AWM%, or other Olap word keys intheir "object_name" field, however, if it needs a help to recognizethem, then please contact Oracle  Support and create a Service Request toget assistance for this question.  
      
    Note that catnoadm.sql could fail from 10.1.0.5 to 11.1.0.7release.   
      
    Due to the factthat it refers to three scripts which don't get shipped until 11.2 this scriptwill fail.  
    Besides that itwill error on 7 non-existing synonyms to drop.  
      
    Prior 11.2, execute these three dropsynonym statements:  
      
    SQL> drop public synonym OlapFactView;  
    SQL> drop public synonym OlapDimView;  
    SQL> drop public synonym DBMS_ODM;  


10:编译失效对象



    SQL> @?/rdbms/admin/utlrp.sql  

此时会有错误,这是因为olap没有安装,下面安装olap,然后重新编译

11:添加OLAP



    SQL> @?/olap/admin/olap.sql SYSAUX TEMP;  



    <pre name="code" class="sql">SQL> @?/rdbms/admin/utlrp.sql    --这次会非常快  

12.  验证无效对象和组件状态



    SQL> l  
      1* select count(*) from dba_objects where status<>'VALID'  
    SQL> col comp_name for a40  
    SQL> select comp_name,status from dba_registry;  
      
    COMP_NAME                STATUS  
    ---------------------------------------- ----------------------  
    Oracle Database Catalog Views        VALID  
    Oracle Database Packages and Types   VALID  
    Oracle Workspace Manager         VALID  
    JServer JAVA Virtual Machine         VALID  
    Oracle XDK               VALID  
    Oracle Database Java Packages        VALID  
    Oracle Expression Filter         VALID  
    Oracle Data Mining           VALID  
    Oracle Text              VALID  
    Oracle XML Database          VALID  
    Oracle Rules Manager             VALID  
      
    COMP_NAME                STATUS  
    ---------------------------------------- ----------------------  
    Oracle interMedia            VALID  
    OLAP Analytic Workspace          VALID  
    Oracle OLAP API              VALID  
    OLAP Catalog                 VALID  
    Spatial                  VALID  
    Oracle Enterprise Manager        VALID  


11:重新编译java对象



    <pre name="code" class="sql">begin  
      update obj$ set status=5 where obj#=(select obj# from obj$,javasnm$ where owner#=0 and type#=29 and short(+)=name and nvl(longdbcs,name)='oracle/aurora/rdbms/Compiler');  
      commit;  
      declare  
        cursor C1 is select 'DROP JAVA DATA "'||u.name||'"."'||o.name||'"' from obj$ o,user$ u where o.type#=56 and u.user#=o.owner#;  
        ddl_statement varchar2(200);  
        iterations number;  
        previous_iterations number;  
        loop_count number;  
        my_err     number;  
      begin  
        previous_iterations := 10000000;  
        loop  
          select count(*) into iterations from obj$ where type#=56;  
          exit when iterations=0 or iterations >= previous_iterations;  
          previous_iterations := iterations;  
          loop_count := 0;  
          open C1;  
          loop  
            begin  
              fetch C1 into ddl_statement;  
              exit when C1%NOTFOUND or loop_count > iterations;  
            exception when others then  
               my_err := sqlcode;  
               if my_err = -1555 then  
                 exit;  
               else  
                 raise;  
               end if;  
            end;  
            initjvmaux.exec(ddl_statement);  
            loop_count := loop_count + 1;  
          end loop;  
          close C1;  
        end loop;  
      end;  
      commit;  
      initjvmaux.drp('delete from java$policy$shared$table');  
      update obj$ set status=1 where obj#=(select obj# from obj$,javasnm$ where owner#=0 and type#=29 and short(+)=name and nvl(longdbcs,name)='oracle/aurora/rdbms/Compiler');  
      commit;  
    end;  
    /  



    create or replace java system  
    /  


It may be necessary to recompilethe Java objects with ncomp:i.e.   % ncomp-user scott/tiger Hello.class




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-27319-1-1.html 上篇帖子: Oracle中表列由VARCHAR2类型改成CLOB 下篇帖子: oracle_常用分组函数 oracle 数据库
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表