Oracle 10g RMAN 跨平台迁移
RMAN异构平台迁移 1.实验环境简介 1.1 SOA生产系统 数据库名 comSOA 实例名 Comsoa DBID 4133565260 数据库版本 Windows 32bit 10.2.R2 数据文件目录 E:\ORASOA\ORADATA\COMSOAPfile Initcomsoa.ora 1.2 待恢SOA系统 数据库名 comSOA 实例名 Comsoa DBID 4133565260 数据库版本 Linux 64it 10.2R2 数据文件目录 /U01/ORADATA/COMSOA/ Pfile Initcomsoa.ora 2 备份 2.1 备份注意事项 1. 迁移库只能在同字节顺序平台之间(即ENDIAN_FORMAT相同)且得是ORACLE所支持的平台,可以在V$TRANSPORTABLE_PLATFORM中查看。 2. 传输前需要将源库置为只读。 3. 生成的2个脚本文件要仔细根据需要修改。 2.2 源库操作 2.2.1 将库只读,并检查是否支持迁移 一.将库只读,并检查是否支持迁移 SQL> startup mount SQL> alter database open read only; 2.2.2 检查支持迁移平台 SQL> select * from v$transportable_platform; PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT ----------- -------------------------------- -------------- 2 Solaris[tm] OE (64-bit) Big 7 Microsoft Windows IA (32-bit) Little 10 Linux IA (32-bit) Little 6 AIX-Based Systems (64-bit) Big 4 HP-UX IA (64-bit) Big 11 Linux IA (64-bit) Little 15 HP Open VMS Little 8 Microsoft Windows IA (64-bit) Little 17 rows selected. 2.2.3 利用dbms_tdb 包检查数据库 二.利用dbms_tdb 包检查数据库能否被传输以及列出外部表和DIRECTORY 等无法传输的对象信息,分别在windows平台数据库通过SQLPLUS执行以下两个存储过程 SQL> set serveroutput on SQL> declare 2 db_ready boolean; 3 begin 4 /* db_ready is ignored, but with SERVEROUTPUT set to ON any 5 * conditions preventing transport will be output to console */ 6 db_ready := dbms_tdb.check_db(‘Microsoft Windows IA (32-bit)‘, 7 dbms_tdb.skip_none); 8 end; 9 / PL/SQL procedure successfully completed. SQL> declare 2 external boolean; 3 begin 4 /* value of external is ignored, but with SERVEROUTPUT set to ON 5 * dbms_tdb.check_external displays report of external objects 6 * on console */ 7 external := dbms_tdb.check_external; 8 end; 9 / PL/SQL procedure successfully completed. 2.2.4 RMAN ConvertDB 连接target database 查看数据库打开模式 C:\ Administrator > set oracle_sid=comsoa C:\ Administrator > sqlplus / as sysdba SQL> select open_mode from v$database; OPEN_MODE ---------- READ ONLY 利用RMAN convertDB 转化数据库 C:\ Administrator > rman target / RMAN> convert database new database ‘comsoa‘ 2> transport script ‘f:\transdb.sql‘ 3> to platform ‘Linux IA (64-bit)‘ 4> db_file_name_convert ‘e:\orasoa\oradata\comsoa\‘,‘f:\trans_dir\‘; 注: ‘f:\transdb.sql‘:数据库转化脚本生产位置 ‘Linux IA (64-bit)‘:被转化的平台 e:\orasoa\oradata\comsoa\:源数据库数据文件位置 ‘f:\trans_dir\‘:转化后生成新的数据文件位置 启动 convert 于 08-12月-11 使用目标数据库控制文件替代恢复目录 分配的通道: ORA_DISK_1 通道 ORA_DISK_1: sid=318 devtype=DISK 在数据库中找到目录 SYS.WORK_DIR 在数据库中找到目录 SYS.ADMIN_DIR 在数据库中找到目录 SYS.DATA_PUMP_DIR ……… ………. ……….. 通道 ORA_DISK_1: 数据文件转换完毕, 经过时间: 00:00:01 在目标平台上运行 SQL 脚本 F:\TRANSDB.SQL 以创建数据库 编辑 init.ora 文件 E:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INIT_00MTMNQN_1_0.ORA。 此 PFILE 将用于在目标平台上创建数据库据 要重新编译所有 PL/SQL 模块, 请在目标平台上运行 utlirp.sql 和 utlrp.sql 要更改内部数据库标识符, 请使用 DBNEWID 实用程序 完成 backup 于 03-12月-11 2.2.5 修改pfile参数文件 修改在E:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\INIT_00MTMNQN_1_0.ORA 生成的参数文件并重新命名为initcomsoa.ora # Please change the values of the following parameters: control_files = "/u01/app/oracle/oradata/comsoa/control01.ctl", "/u01/app/oracle/oradata/comsoa/control02.ctl", "/u01/app/oracle/oradata/comsoa/control03.ctl" db_recovery_file_dest = "/u01/app/oracle/flash_recovery_area" db_recovery_file_dest_size= 2147483648 audit_file_dest = "/u01/app/oracle/comsoa/admin/adump" background_dump_dest = "/u01/app/oracle/comsoa/admin/bdump" user_dump_dest = "/u01/app/oracle/comsoa/admin/udump" core_dump_dest = "/u01/app/oracle/comsoa/admin/cdump" db_name = "COMSOA" # Please review the values of the following parameters: __shared_pool_size = 100663296 __large_pool_size = 4194304 __java_pool_size = 4194304 __streams_pool_size = 0 __db_cache_size = 205520896 remote_login_passwordfile= "EXCLUSIVE" db_domain = "" dispatchers = "(PROTOCOL=TCP) (SERVICE=COMSOAXDB)" # The values of the following parameters are from source database: processes = 300 sessions = 335 sga_max_size = 318767104 nls_language = "SIMPLIFIED CHINESE" nls_territory = "CHINA" sga_target = 318767104 db_block_size = 8192 compatible = "10.2.0.1.0" # log_archive_dest_1 = "location=/u01/orasoa/archive/comsoa" db_file_multiblock_read_count= 16 undo_management = "AUTO" undo_tablespace = "UNDOTBS1" job_queue_processes = 10 open_cursors = 300 pga_aggregate_target = 336870912 2.2.6 重建控制文件脚本TRANSDB.SQL 根据linux主机路径修改相应的数据文件目录 -- The following commands will create a new control file and use it -- to open the database. STARTUP NOMOUNT PFILE=‘/u01/app/oracle/product/10.2.0/db_1/dbs/initcomsoa.ora‘ CREATE CONTROLFILE REUSE SET DATABASE "COMSOA" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 ‘/u01/app/oracle/oradata/comsoa/redo01.log‘ SIZE 50M, GROUP 2 ‘/u01/app/oracle/oradata/comsoa/redo02.log‘ SIZE 50M, GROUP 3 ‘/u01/app/oracle/oradata/comsoa/redo03.log‘ SIZE 50M DATAFILE ‘/u01/app/oracle/oradata/comsoa/SYSTEM01.DBF‘, ‘/u01/app/oracle/oradata/comsoa/UNDOTBS01.DBF‘, ‘/u01/app/oracle/oradata/comsoa/SYSAUX01.DBF‘, ‘/u01/app/oracle/oradata/comsoa/USERS01.DBF‘, ‘/u01/app/oracle/oradata/comsoa/TBS_IDX_COMSOA.ORA‘, ‘/u01/app/oracle/oradata/comsoa/TBS_IDX_DXPT.ORA‘, ‘/u01/app/oracle/oradata/comsoa/TBS_IDX_KB.ORA‘, ‘/u01/app/oracle/oradata/comsoa/TBS_IDX_WORKFLOW.ORA‘, ‘/u01/app/oracle/oradata/comsoa/TBS_KB.ORA‘, ‘/u01/app/oracle/oradata/comsoa/TBS_WORKFLOW.ORA‘, ‘/u01/app/oracle/oradata/comsoa/WORKFLOW_MAIN_1.ORA‘, ‘/u01/app/oracle/oradata/comsoa/TBS_COMSOA.ORA‘, ‘/u01/app/oracle/oradata/comsoa/TBS_DXPT.ORA‘, ‘/u01/app/oracle/oradata/comsoa/WORKFLOW_MAIN.ORA‘ CHARACTER SET ZHS16GBK ; -- 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 TBS_TMP_DXPT ADD TEMPFILE ‘/u01/app/oracle/oradata/comsoa/TS-TBS_TMP_DXPT.dbf‘ SIZE 52428800 AUTOEXTEND OFF; ALTER TABLESPACE TBS_TMP_COMSOA ADD TEMPFILE ‘/u01/app/oracle/oradata/comsoa/TS-TBS_TMP_COMSOA.dbf‘ SIZE 52428800 AUTOEXTEND OFF; ALTER TABLESPACE TEMP01 ADD TEMPFILE ‘/u01/app/oracle/oradata/comsoa/TS-TEMP01.dbf‘ SIZE 52428800 AUTOEXTEND OFF; -- End of tempfile additions. -- set echo off prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ prompt * Your database has been created successfully! prompt * There are many things to think about for the new database. Here prompt * is a checklist to help you stay on track: prompt * 1. You may want to redefine the location of the directory objects. prompt * 2. You may want to change the internal database identifier (DBID) prompt * or the global database name for this database. Use the prompt * NEWDBID Utility (nid). prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SHUTDOWN IMMEDIATE STARTUP UPGRADE PFILE=‘/u01/app/oracle/product/10.2.0/db_1/dbs/initcomsoa.ora‘ @@ /u01/app/oracle/product/10.2.0/db_1/rdbms/admin/utlirp.sql SHUTDOWN IMMEDIATE STARTUP PFILE=‘/u01/app/oracle/product/10.2.0/db_1/dbs/initcomsoa.ora‘ -- The following step will recompile all PL/SQL modules. -- It may take serveral hours to complete. @@ /u01/app/oracle/product/10.2.0/db_1/rdbms/admin/utlrp.sql set feedback 6; 注:在此文件中注意Linux目标数据库的路径要保证正确,目录属主权限要正确 2.3 Linux平台主机操作 2.3.1 安装oracle数据库软件,建立相关文件夹 安装好oracle后根据pfile文件内容来创建相关的目录 $mkdir –p /u01/app/oracle/comsoa/admin/adump $mkdir –p /u01/app/oracle/comsoa/admin/bdump $mkdir –p /u01/app/oracle/comsoa/admin/cdump $mkdir –p /u01/app/oracle/comsoa/admin/udump $mkdir –p /u01/app/oracle/flash_recovery_area $mkdir –p /u01/orasoa/archive/comsoa $mkdir –p /u01/app/oracle/oradata/comsoa/ 2.3.2 迁移转化 将在windows环境中生成的文件拷贝到linux主机下包括以下文件 1. f:\trans_dir\目录下的转化后的所有数据文件,还有幻化脚本TRANSDB.SQL拷贝到/u01/app/oracle/oradata/comsoa/目录下, 2. 将修改后的initcomsoa.ora拷贝到/u01/app/oracle/product/10.2.0/db_1/dbs/目录下 2.3.3 创建实例comsoa 执行转化脚本 $cd /u01/app/oracle/oradata/comsoa [oracle@SOA comsoa]$export ORACLE_SID=comsoa [oracle@SOA comsoa]$ sqlplus / as sysdba SQL > @TRANSDB.SQL SQL脚本执行完成后提示以下信息 SQL> Rem ========================================================= SQL> Rem Run component validation procedure SQL> Rem ========================================================== SQL> SET serveroutput on SQL> EXECUTE dbms_registry_sys.validate_components; PL/SQL procedure successfully completed. SQL> set feedback 6; SQL>@utlip.sql 编译无效PLSQL过程 SQL> Rem ================================================= SQL> Rem END utlip.sql SQL> Rem ================================================= 2.4 数据库验证 查看数据库名称 SQL> select name from v$database; NAME --------- COMSOA 查询数据库实例 SQL> select status from v$instance; STATUS ------------ OPEN 查询数据库打开模式 SQL> select open_mode from v$database; OPEN_MODE ---------- READ WRITE 数据库用户登陆验证 SQL> select username from dba_users; USERNAME ------------------------------ DXPT KB WORKFLOW WORKFLOW_YWZY LTWG MONITOR …….. …….. DBSNMP 27 rows selected. 登陆验证 SQL> conn kb/******* Connected. KB用户在经过windows环境迁移Linux主机后可以正常登陆 表空间验证,查询迁移后的表空间 SQL> select tablespace_name,file_id from dba_data_files; TABLESPACE_NAME FILE_ID ------------------------------ ---------- WORKFLOW_MAIN 14 WORKFLOW_MAIN 13 TBS_WORKFLOW 12 TBS_KB 11 TBS_IDX_WORKFLOW 10 TBS_IDX_KB 9 TBS_IDX_DXPT 8 TBS_IDX_COMSOA 7 TBS_DXPT 6 TBS_COMSOA 5 USERS 4 SYSAUX 3 UNDOTBS1 2 SYSTEM 1 14 rows selected. 插入数据验证 SQL> create table test (i int); Table created. SQL> insert into test values (1); 1 row created. SQL> select * from test; I ---------- 1 切换日志测试 SQL> alter system switch logfile; System altered. 2.5 迁移注意事项 1. 确保源库与目标数据库的字符集一致 2. 数据库32bit迁移到64位后要把无效的数据库对象重新编译,确保正确执行utlrp.sql,utlirp.sql 3. 数据库迁移后,确保应用系统用户可以正确连接,登陆有效 4. 监听要重新配置,检查临时表空间的属主与可用性 5. 迁移完成后要立即进行一次全备份
本文出自 “O Record” 博客,请务必保留此出处http://evils798.blog.51cto.com/8983296/1420911
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。