RMAN同字节序跨平台跨版本迁移数据库

在目标平台执行数据文件转换
将32位windows平台上的数据库jingyong(10.2.0.1)迁移到32位的Linux平台上(10.2.0.5)在目标平台上执行RMAN的convert database操作的步骤如下:
1.将源数据库以只读模式打开
C:UsersAdministrator>sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 – Production on 星期二 3月 31 20:30:23 2015Copyright (c) 1982, 2005,
Oracle. All rights reserved.连接到:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – ProductionWith the Partitioning, OLAP and Data Mining optionsSQL> shutdown immediate数据库已经关闭。已经卸载数据库。ORACLE 例程已经关闭。SQL> startup mountORACLE 例程已经启动。Total System Global
Area 419430400 bytesFixed Size 1249320 bytesVariable Size 125833176 bytesDatabase Buffers 285212672 bytesRedo Buffers 7135232 bytes数据库装载完毕。SQL> alter database open read only;数据库已更改。
2.对源数据库执行dbms_tdb.check_db检查
SQL> set serveroutput onSQL> declare 2 db_ready boolean; 3 begin 4 db_ready :=dbms_tdb.check_db(‘Linux IA (32-bit)’,dbms_tdb.skip_readonly);
5 end; 6 /PL/SQL procedure successfully completed
3.对源数据库执行dbms_tdb.check_external来识别外部对象
SQL> set serveroutput on;SQL> declare 2 external boolean; 3 begin 4 external:=dbms_tdb.check_external; 5 end; 6 /The following external
tables exist in the database:SH.SALES_TRANSACTIONS_EXTThe following directories exist in the database:SYS.TEST_DUMP, SYS.SUBDIR, SYS.XMLDIR, SYS.MEDIA_DIR, SYS.LOG_FILE_DIR, SYS.DATA_FILE_DIR, SYS.WORK_DIR, SYS.ADMIN_DIR, SYS.DATA_PUMP_DIRThe following BFILEs
exist in the database:PM.PRINT_MEDIAPL/SQL procedure successfully completed
4.在源平台上执行convert database命令并指定on target platform参数。
C:UsersAdministrator>rman target/恢复管理器: Release 10.2.0.1.0 – Production on 星期二 3月 31 21:05:58 2015Copyright (c) 1982, 2005, Oracle.
All rights reserved.连接到目标数据库: JINGYONG (DBID=3213417256)RMAN> convert database on target platform2> convert script ‘E:oradataconvertconvertscript.rman’3> transport script ‘E:oradataconverttransportscript.sql’4> new database ‘cs’5> format ‘E:oradataconvert%U’;启动
convert 于 31-3月 -15使用目标数据库控制文件替代恢复目录分配的通道: ORA_DISK_1通道 ORA_DISK_1: sid=152 devtype=DISK在数据库中找到外部表 SH.SALES_TRANSACTIONS_EXT在数据库中找到目录 SYS.TEST_DUMP在数据库中找到目录 SYS.SUBDIR在数据库中找到目录 SYS.XMLDIR在数据库中找到目录 SYS.MEDIA_DIR在数据库中找到目录 SYS.LOG_FILE_DIR在数据库中找到目录 SYS.DATA_FILE_DIR在数据库中找到目录
SYS.WORK_DIR在数据库中找到目录 SYS.ADMIN_DIR在数据库中找到目录 SYS.DATA_PUMP_DIR在数据库中找到 BFILE PM.PRINT_MEDIA在口令文件中找到用户 SYS (具有 SYSDBA and SYSOPER 权限)通道 ORA_DISK_1: 开始检查数据文件输入数据文件 fno=00001 name=E:ORADATAJINGYONGDATAFILEO1_MF_SYSTEM_BKLLOT8Z_.DBF通道 ORA_DISK_1: 数据文件检查完毕,
用时: 00:00:00通道 ORA_DISK_1: 开始检查数据文件输入数据文件 fno=00003 name=E:ORADATAJINGYONGDATAFILEO1_MF_SYSAUX_BKLLOTFL_.DBF通道 ORA_DISK_1: 数据文件检查完毕, 用时: 00:00:01通道 ORA_DISK_1: 开始检查数据文件输入数据文件 fno=00005 name=E:ORADATAJINGYONGDATAFILEO1_MF_EXAMPLE_BKLLRKG2_.DBF通道 ORA_DISK_1:
数据文件检查完毕, 用时: 00:00:00通道 ORA_DISK_1: 开始检查数据文件输入数据文件 fno=00006 name=E:ORADATAJINGYONGTSPITR01.DBF通道 ORA_DISK_1: 数据文件检查完毕, 用时: 00:00:00通道 ORA_DISK_1: 开始检查数据文件输入数据文件 fno=00007 name=E:ORADATAJINGYONGTEST01.DBF通道 ORA_DISK_1: 数据文件检查完毕, 用时: 00:00:00通道 ORA_DISK_1:
开始检查数据文件输入数据文件 fno=00002 name=E:ORADATAJINGYONGDATAFILEO1_MF_UNDOTBS1_BKLLOTM0_.DBF通道 ORA_DISK_1: 数据文件检查完毕, 用时: 00:00:00通道 ORA_DISK_1: 开始检查数据文件输入数据文件 fno=00004 name=E:ORADATAJINGYONGDATAFILEO1_MF_USERS_BKLLOTM6_.DBF通道 ORA_DISK_1: 数据文件检查完毕, 用时: 00:00:01在目标平台上运行
SQL 脚本 E:ORADATACONVERTTRANSPORTSCRIPT.SQL 以创建数据库编辑 init.ora 文件 E:ORADATACONVERTINIT_00Q3836C_1_0.ORA。此 PFILE 将用于在目标平台上创建数据库据在目标平台上运行 RMAN 脚本 E:ORADATACONVERTCONVERTSCRIPT.RMAN 以转换数据文件要重新编译所有 PL/SQL 模块, 请在目标平台上运行 utlirp.sql 和 utlrp.sql要更改内部数据库标识符,
请使用 DBNEWID 实用程序完成 backup 于 31-3月 -15
与在源平台执行convert database命令一样,convert database on target platform会生成可以在目标平台上创建新数据库的传输脚本和包含与源数据库有相同参数设置的PFILE参数文件。convert database on target
platform也会生成一个包含对源数据库每个数据文件执行convert datafile命令的转换脚本。源数据库的数据文件必须在不被转换的情况下传输到目标主机相应的目录中,并对转换脚本做相应的修改,转换脚本内容如下:
RUN { CONVERT DATAFILE ‘E:ORADATAJINGYONGDATAFILEO1_MF_SYSTEM_BKLLOT8Z_.DBF’ FROM PLATFORM ‘Microsoft Windows IA (32-bit)’ FORMAT
‘E:ORADATACONVERTDATA_D-JINGYONG_I-3213417256_TS-SYSTEM_FNO-1_08Q3836D’; CONVERT DATAFILE ‘E:ORADATAJINGYONGDATAFILEO1_MF_SYSAUX_BKLLOTFL_.DBF’ FROM PLATFORM ‘Microsoft Windows IA (32-bit)’ FORMAT ‘E:ORADATACONVERTDATA_D-JINGYONG_I-3213417256_TS-SYSAUX_FNO-3_09Q3836D’;
CONVERT DATAFILE ‘E:ORADATAJINGYONGDATAFILEO1_MF_EXAMPLE_BKLLRKG2_.DBF’ FROM PLATFORM ‘Microsoft Windows IA (32-bit)’ FORMAT ‘E:ORADATACONVERTDATA_D-JINGYONG_I-3213417256_TS-EXAMPLE_FNO-5_0AQ3836E’; CONVERT DATAFILE ‘E:ORADATAJINGYONGTSPITR01.DBF’
FROM PLATFORM ‘Microsoft Windows IA (32-bit)’ FORMAT ‘E:ORADATACONVERTDATA_D-JINGYONG_I-3213417256_TS-TSPITR_FNO-6_0BQ3836E’; CONVERT DATAFILE ‘E:ORADATAJINGYONGTEST01.DBF’ FROM PLATFORM ‘Microsoft Windows IA (32-bit)’ FORMAT ‘E:ORADATACONVERTDATA_D-JINGYONG_I-3213417256_TS-TEST_FNO-7_0CQ3836E’;
CONVERT DATAFILE ‘E:ORADATAJINGYONGDATAFILEO1_MF_UNDOTBS1_BKLLOTM0_.DBF’ FROM PLATFORM ‘Microsoft Windows IA (32-bit)’ FORMAT ‘E:ORADATACONVERTDATA_D-JINGYONG_I-3213417256_TS-UNDOTBS1_FNO-2_0DQ3836E’; CONVERT DATAFILE ‘E:ORADATAJINGYONGDATAFILEO1_MF_USERS_BKLLOTM6_.DBF’
FROM PLATFORM ‘Microsoft Windows IA (32-bit)’ FORMAT ‘E:ORADATACONVERTDATA_D-JINGYONG_I-3213417256_TS-USERS_FNO-4_0EQ3836F’;}
5.在源数据库为只读状态时将数据文件与传输脚本,转换脚本与PFILE参数文件复制到目标主机对应的目录中。
ftp> put CONVERTSCRIPT.RMAN200 PORT command successful. Consider using PASV.150 Ok to send data.226 File receive OK.ftp: 发送 1462 字节,用时
0.00秒 1462000.00千字节/秒。ftp> put INIT_00Q3836C_1_0.ORA200 PORT command successful. Consider using PASV.150 Ok to send data.226 File receive OK.ftp: 发送 1309 字节,用时 0.00秒 1309.00千字节/秒。ftp> TRANSPORTSCRIPT.SQL无效命令。ftp> put TRANSPORTSCRIPT.SQL200 PORT command successful.
Consider using PASV.150 Ok to send data.226 File receive OK.ftp: 发送 2739 字节,用时 0.00秒 2739.00千字节/秒。ftp> lcd E:oradataJINGYONG目前的本地目录 E:oradataJINGYONG。ftp> bin200 Switching to Binary mode.ftp> put TEST01.dbf200 PORT command successful. Consider using PASV.150
Ok to send data.226 File receive OK.ftp: 发送 52436992 字节,用时 2.55秒 20555.47千字节/秒。ftp> put TSPITR01.dbf200 PORT command successful. Consider using PASV.150 Ok to send data.226 File receive OK.ftp: 发送 52436992 字节,用时 6.71秒 7819.41千字节/秒。ftp> lcd E:oradataJINGYONGDATAFILE目前的本地目录
E:oradataJINGYONGDATAFILE。ftp> bin200 Switching to Binary mode.ftp> put O1_MF_SYSTEM_BKLLOT8Z_.O1_MF_SYSTEM_BKLLOT8Z_.: ftp> DBF无效命令。ftp> put O1_MF_EXAMPLE_BKLLRKG2_.DBF200 PORT command successful. Consider using PASV.150 Ok to send data.226 File receive
OK.ftp: 发送 104865792 字节,用时 12.16秒 8620.29千字节/秒。ftp> put O1_MF_SYSAUX_BKLLOTFL_.DBF200 PORT command successful. Consider using PASV.150 Ok to send data.226 File receive OK.ftp: 发送 251666432 字节,用时 25.59秒 9835.71千字节/秒。ftp> put O1_MF_SYSTEM_BKLLOT8Z_.DBF200 PORT
command successful. Consider using PASV.150 Ok to send data.226 File receive OK.ftp: 发送 503324672 字节,用时 60.46秒 8325.06千字节/秒。ftp> put O1_MF_UNDOTBS1_BKLLOTM0_.DBF200 PORT command successful. Consider using PASV.150 Ok to send data.226 File receive OK.ftp: 发送
31465472 字节,用时 6.67秒 4718.17千字节/秒。ftp> put O1_MF_USERS_BKLLOTM6_.DBF200 PORT command successful. Consider using PASV.150 Ok to send data.226 File receive OK.ftp: 发送 5251072 字节,用时 0.42秒 12355.46千字节/秒。[oracle@oracle11g cs]$ ls -lrttotal 978980-rwxrwxrwx 1 oracle
oinstall 1462 Mar 31 21:22 CONVERTSCRIPT.RMAN-rwxrwxrwx 1 oracle oinstall 1309 Mar 31 21:22 INIT_00Q3836C_1_0.ORA-rwxrwxrwx 1 oracle oinstall 2739 Mar 31 21:22 TRANSPORTSCRIPT.SQL-rwxrwxrwx 1 oracle oinstall 52436992 Mar 31 21:23 TEST01.DBF-rwxrwxrwx 1 oracle
oinstall 52436992 Mar 31 21:23 TSPITR01.DBF-rwxrwxrwx 1 oracle oinstall 104865792 Mar 31 21:24 O1_MF_EXAMPLE_BKLLRKG2_.DBF-rwxrwxrwx 1 oracle oinstall 251666432 Mar 31 21:25 O1_MF_SYSAUX_BKLLOTFL_.DBF-rwxrwxrwx 1 oracle oinstall 503324672 Mar 31 21:26 O1_MF_SYSTEM_BKLLOT8Z_.DBF-rwxrwxrwx
1 oracle oinstall 31465472 Mar 31 21:27 O1_MF_UNDOTBS1_BKLLOTM0_.DBF-rwxrwxrwx 1 oracle oinstall 5251072 Mar 31 21:27 O1_MF_USERS_BKLLOTM6_.DBF
6.创建新数据库cs相关目录,并修改PFILE参数文件,传输脚本与转换脚本中的相关路径信息,因为convert database on target platform命令并不会生成转换后的数据文件副本。当目标主机数据文件存储路径与源数据库数据文件存储路径完全相同时,可以直接执行转换脚本,但这里由于目标主机存储数据文件的路径与源数据库存储数据文件的路径不相同,需要对转换脚本做相应修改,也需要对用来创建新数据库的传输脚本做修改。
创建相关目录
[oracle@oracle11g dbs]$ mkdir -p /u01/app/oracle/admin/cs/adump[oracle@oracle11g dbs]$ mkdir -p /u01/app/oracle/admin/cs/bdump[oracle@oracle11g
dbs]$ mkdir -p /u01/app/oracle/admin/cs/cdump[oracle@oracle11g dbs]$ mkdir -p /u01/app/oracle/admin/cs/udump[oracle@oracle11g dbs]$ chmod -R 777 /u01/app/oracle/admin/cs*
修改PFILE参数文件
[oracle@oracle11g cs]$ mv INIT_00Q3836C_1_0.ORA initcs.ora[oracle@oracle11g cs]$ vi initcs.ora __shared_pool_size = 113246208 __large_pool_size
= 4194304 __java_pool_size = 4194304 __streams_pool_size = 4194304 __db_cache_size = 285212672 remote_login_passwordfile= "EXCLUSIVE" db_domain = "" db_create_file_dest = "E:ORADATACONVERToradata"# Please change the values of the following parameters: audit_file_dest
= ‘/u01/app/oracle/admin/cs/adump’ background_dump_dest = ‘/u01/app/oracle/admin/cs/bdump’ user_dump_dest = ‘/u01/app/oracle/admin/cs/udump’ core_dump_dest = ‘/u01/app/oracle/admin/cs/cdump’ db_name = "CS" control_files=’/u02/cs/control01.ctl’# Please review
the values of the following parameters: dispatchers = "(PROTOCOL=TCP) (SERVICE=csXDB)"# The values of the following parameters are from source database: processes = 150 nls_language = "SIMPLIFIED CHINESE" nls_territory = "CHINA" sga_target = 130M db_block_size
= 8192 compatible = "10.2.0.1.0" db_file_multiblock_read_count= 16 undo_management = "AUTO" undo_tablespace = "UNDOTBS1" job_queue_processes = 10 open_cursors = 300 pga_aggregate_target = 32M"initcs.ora" 48L, 990C written[oracle@oracle11g cs]$ cp initcs.ora
$ORACLE_HOME/dbs
修改转换脚本
[oracle@oracle11g cs]$ vi CONVERTSCRIPT.RMANRUN { CONVERT DATAFILE ‘/u02/cs/O1_MF_SYSTEM_BKLLOT8Z_.DBF’ FROM PLATFORM ‘Microsoft Windows
IA (32-bit)’ FORMAT ‘/u02/cs/datafiles/system01.dbf’; CONVERT DATAFILE ‘/u02/cs/O1_MF_SYSAUX_BKLLOTFL_.DBF’ FROM PLATFORM ‘Microsoft Windows IA (32-bit)’ FORMAT ‘/u02/cs/datafiles/sysaux01.dbf’; CONVERT DATAFILE ‘/u02/cs/O1_MF_EXAMPLE_BKLLRKG2_.DBF’ FROM PLATFORM
‘Microsoft Windows IA (32-bit)’ FORMAT ‘/u02/cs/datafiles/example01.dbf’; CONVERT DATAFILE ‘/u02/cs/TSPITR01.DBF’ FROM PLATFORM ‘Microsoft Windows IA (32-bit)’ FORMAT ‘/u02/cs/datafiles/tspitr01.dbf’; CONVERT DATAFILE ‘/u02/cs/TEST01.DBF’ FROM PLATFORM ‘Microsoft
Windows IA (32-bit)’ FORMAT ‘/u02/cs/datafiles/test01.dbf’; CONVERT DATAFILE ‘/u02/cs/O1_MF_UNDOTBS1_BKLLOTM0_.DBF’ FROM PLATFORM ‘Microsoft Windows IA (32-bit)’ FORMAT ‘/u02/cs/datafiles/undotsb1.dbf’; CONVERT DATAFILE ‘/u02/cs/O1_MF_USERS_BKLLOTM6_.DBF’
FROM PLATFORM ‘Microsoft Windows IA (32-bit)’ FORMAT ‘/u02/cs/datafiles/users01.dbf’;}
修改用来创建新数据库的传输脚本
[oracle@oracle11g cs]$ vi TRANSPORTSCRIPT.SQL– 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 PERFORMANCESTARTUP NOMOUNT PFILE=’/u01/app/oracle/10.2.0/db/dbs/initcs.ora’– Create SPFILECREATE SPFILE FROM PFILE = ‘/u01/app/oracle/10.2.0/db/dbs/initcs.ora’;STARTUP
FORCE NOMOUNTCREATE CONTROLFILE REUSE SET DATABASE "CS" RESETLOGS NOARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292LOGFILE GROUP 1 ‘/u02/cs/datafiles/redo01.log’ SIZE 50M, GROUP 2 ‘/u02/cs/datafiles/redo02.log’ SIZE
50M, GROUP 3 ‘/u02/cs/datafiles/redo03.log’ SIZE 50MDATAFILE ‘/u02/cs/datafiles/system01.dbf’, ‘/u02/cs/datafiles/sysaux01.dbf’, ‘/u02/cs/datafiles/example01.dbf’, ‘/u02/cs/datafiles/tspitr01.dbf’, ‘/u02/cs/datafiles/test01.dbf’, ‘/u02/cs/datafiles/undotsb1.dbf’,
‘/u02/cs/datafiles/users01.dbf’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 TEMP ADD TEMPFILE ‘/u02/cs/datafiles/temp01.dbf’ SIZE 50M AUTOEXTEND OFF;– End of tempfile additions.–set echo offprompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~prompt * Your database has
been created successfully!prompt * There are many things to think about for the new database. Hereprompt * 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 theprompt * NEWDBID Utility (nid).prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~SHUTDOWN IMMEDIATESTARTUP UPGRADE@@ ?/rdbms/admin/utlirp.sqlSHUTDOWN
IMMEDIATESTARTUP– The following step will recompile all PL/SQL modules.– It may take serveral hours to complete.@@ ?/rdbms/admin/utlrp.sql
7.在目标主机上执行转换脚本
[oracle@oracle11g admin]$ rman target/Recovery Manager: Release 10.2.0.5.0 – Production on Tue Mar 31 21:55:50 2015Copyright (c) 1982,
2007, Oracle. All rights reserved.connected to target database: JINGYONG (DBID=3213417256)RMAN> run2> {3> CONVERT DATAFILE ‘/u02/cs/O1_MF_SYSTEM_BKLLOT8Z_.DBF’4> FROM PLATFORM ‘Microsoft Windows IA (32-bit)’5> FORMAT ‘/u02/cs/datafiles/system01.dbf’;6>7> CONVERT
DATAFILE ‘/u02/cs/O1_MF_SYSAUX_BKLLOTFL_.DBF’8> FROM PLATFORM ‘Microsoft Windows IA (32-bit)’9> FORMAT ‘/u02/cs/datafiles/sysaux01.dbf’;10>11> CONVERT DATAFILE ‘/u02/cs/O1_MF_EXAMPLE_BKLLRKG2_.DBF’12> FROM PLATFORM ‘Microsoft Windows IA (32-bit)’13> FORMAT
‘/u02/cs/datafiles/example01.dbf’;14>15> CONVERT DATAFILE ‘/u02/cs/TSPITR01.DBF’16> FROM PLATFORM ‘Microsoft Windows IA (32-bit)’17> FORMAT ‘/u02/cs/datafiles/tspitr01.dbf’;18>19> CONVERT DATAFILE ‘/u02/cs/TEST01.DBF’20> FROM PLATFORM ‘Microsoft Windows IA
(32-bit)’21> FORMAT ‘/u02/cs/datafiles/test01.dbf’;22>23> CONVERT DATAFILE ‘/u02/cs/O1_MF_UNDOTBS1_BKLLOTM0_.DBF’24> FROM PLATFORM ‘Microsoft Windows IA (32-bit)’25> FORMAT ‘/u02/cs/datafiles/undotsb1.dbf’;26>27> CONVERT DATAFILE ‘/u02/cs/O1_MF_USERS_BKLLOTM6_.DBF’28>
FROM PLATFORM ‘Microsoft Windows IA (32-bit)’29> FORMAT ‘/u02/cs/datafiles/users01.dbf’;30> }Starting backup at 31-MAR-15using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: sid=160 devtype=DISKchannel
ORA_DISK_1: starting datafile conversioninput filename=/u02/cs/O1_MF_SYSTEM_BKLLOT8Z_.DBFconverted datafile=/u02/cs/datafiles/system01.dbfchannel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:55Finished backup at 31-MAR-15Starting backup at
31-MAR-15using channel ORA_DISK_1channel ORA_DISK_1: starting datafile conversioninput filename=/u02/cs/O1_MF_SYSAUX_BKLLOTFL_.DBFconverted datafile=/u02/cs/datafiles/sysaux01.dbfchannel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:25Finished
backup at 31-MAR-15Starting backup at 31-MAR-15using channel ORA_DISK_1channel ORA_DISK_1: starting datafile conversioninput filename=/u02/cs/O1_MF_EXAMPLE_BKLLRKG2_.DBFconverted datafile=/u02/cs/datafiles/example01.dbfchannel ORA_DISK_1: datafile conversion
complete, elapsed time: 00:00:15Finished backup at 31-MAR-15Starting backup at 31-MAR-15using channel ORA_DISK_1channel ORA_DISK_1: starting datafile conversioninput filename=/u02/cs/TSPITR01.DBFconverted datafile=/u02/cs/datafiles/tspitr01.dbfchannel ORA_DISK_1:
datafile conversion complete, elapsed time: 00:00:07Finished backup at 31-MAR-15Starting backup at 31-MAR-15using channel ORA_DISK_1channel ORA_DISK_1: starting datafile conversioninput filename=/u02/cs/TEST01.DBFconverted datafile=/u02/cs/datafiles/test01.dbfchannel
ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:07Finished backup at 31-MAR-15Starting backup at 31-MAR-15using channel ORA_DISK_1channel ORA_DISK_1: starting datafile conversioninput filename=/u02/cs/O1_MF_UNDOTBS1_BKLLOTM0_.DBFconverted datafile=/u02/cs/datafiles/undotsb1.dbfchannel
ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03Finished backup at 31-MAR-15Starting backup at 31-MAR-15using channel ORA_DISK_1channel ORA_DISK_1: starting datafile conversioninput filename=/u02/cs/O1_MF_USERS_BKLLOTM6_.DBFconverted datafile=/u02/cs/datafiles/users01.dbfchannel
ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01Finished backup at 31-MAR-15
8.执行传输脚本中的内容来创建新数据库(也可以直接执行传输脚本)
[oracle@oracle11g admin]$ export ORACLE_SID=cs[oracle@oracle11g admin]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.5.0 – Production on
Tue Mar 31 22:01:12 2015Copyright (c) 1982, 2010, Oracle. All Rights Reserved.Connected to an idle instance.SQL> STARTUP NOMOUNT PFILE=’/u01/app/oracle/10.2.0/db/dbs/initcs.ora’ORACLE instance started.Total System Global Area 138412032 bytesFixed Size 1272432
bytesVariable Size 62915984 bytesDatabase Buffers 71303168 bytesRedo Buffers 2920448 bytesSQL> CREATE CONTROLFILE REUSE SET DATABASE "CS" RESETLOGS NOARCHIVELOG 2 MAXLOGFILES 16 3 MAXLOGMEMBERS 3 4 MAXDATAFILES 100 5 MAXINSTANCES 8 6 MAXLOGHISTORY 292 7 LOGFILE
8 GROUP 1 ‘/u02/cs/datafiles/redo01.log’ SIZE 50M, 9 GROUP 2 ‘/u02/cs/datafiles/redo02.log’ SIZE 50M, 10 GROUP 3 ‘/u02/cs/datafiles/redo03.log’ SIZE 50M 11 DATAFILE 12 ‘/u02/cs/datafiles/system01.dbf’, 13 ‘/u02/cs/datafiles/sysaux01.dbf’, 14 ‘/u02/cs/datafiles/example01.dbf’,
15 ‘/u02/cs/datafiles/tspitr01.dbf’, 16 ‘/u02/cs/datafiles/test01.dbf’, 17 ‘/u02/cs/datafiles/undotsb1.dbf’, 18 ‘/u02/cs/datafiles/users01.dbf’ 19 CHARACTER SET ZHS16GBK 20 ;Control file created.SQL> ALTER DATABASE OPEN RESETLOGS;ALTER DATABASE OPEN RESETLOGS*ERROR
at line 1:ORA-01092: ORACLE instance terminated. Disconnection forced
在执行恢复后正常打开数据库实例被终止,在alert.log中的错误信息如下:
Errors in file /u01/app/oracle/admin/cs/udump/cs_ora_6458.trc:ORA-00704: bootstrap process failureORA-39700: database must be opened with
UPGRADE optionTue Mar 31 22:04:28 CST 2015Error 704 happened during db open, shutting down databaseUSER: terminating instance due to error 704Instance terminated by USER, pid = 6458ORA-1092 signalled during: ALTER DATABASE OPEN RESETLOGS…
错误信息指示需要以升级模式来启动数据库,因为迁移过来的源数据库的版本是10.2.0.1,而目标主机上的数据库版本是10.2.0.5。
以升级模式启动数据库
[oracle@oracle11g admin]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.5.0 – Production on Tue Mar 31 22:06:55 2015Copyright (c) 1982,
2010, Oracle. All Rights Reserved.Connected to an idle instance.SQL> startup upgradeORACLE instance started.Total System Global Area 138412032 bytesFixed Size 1272432 bytesVariable Size 62915984 bytesDatabase Buffers 71303168 bytesRedo Buffers 2920448 bytesDatabase
mounted.ORA-01113: file 1 needs media recovery if it was restored from backup, or ENDBACKUP if it was notORA-01110: data file 1: ‘/u02/cs/datafiles/system01.dbf’
执行恢复并关闭数据库
SQL> recover database;Media recovery complete.SQL> shutdown immediate;ORA-01109: database not openDatabase dismounted.ORACLE instance
shut down.
再次以升级模式启动数据库
SQL> startup upgrade;ORACLE instance started.Total System Global Area 138412032 bytesFixed Size 1272432 bytesVariable Size 62915984 bytesDatabase
Buffers 71303168 bytesRedo Buffers 2920448 bytesDatabase mounted.Database opened.
创建临时表空间
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE ‘/u02/cs/datafiles/temp01.dbf’ 2 SIZE 50M AUTOEXTEND OFF;Tablespace altered.
SQL>@$ORACLE_HOME/rdbms/admin/utlirp.sql省略…SQL>SQL> Rem Continue even if there are SQL errorsSQL> WHENEVER SQLERROR CONTINUE;SQL>SQL>
Rem ===========================================================================SQL> Rem END utlip.sqlSQL> Rem ===========================================================================SQL>SQL> DOCDOC>#######################################################################DOC>#######################################################################DOC>
utlirp.sql completed successfully. All PL/SQL objects in theDOC> database have been invalidated.DOC>DOC> Shut down and restart the database in normal mode and run utlrp.sql toDOC> recompile invalid objects.DOC>#######################################################################DOC>#######################################################################DOC>#
上面的输出信息说在以正常模式重启数据库后执行utlrp.sql脚本来编译无效对象。由于这里源数据库是10.2.0.1,而目标主机数据库的版本是10.2.0.5,在重启数据库仍然需要以升级模式来启动并执行utlrp.sql脚本
SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> startup upgradeORACLE instance started.Total
System Global Area 138412032 bytesFixed Size 1272432 bytesVariable Size 62915984 bytesDatabase Buffers 71303168 bytesRedo Buffers 2920448 bytesDatabase mounted.Database opened.SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sqlSQL> Rem ===========================================================================SQL>
Rem BEGIN utlrp.sqlSQL> Rem ===========================================================================省略…PL/SQL procedure successfully completed.SQL> SET serveroutput offSQL>SQL>SQL> Rem ===========================================================================SQL>
Rem END utlrp.sqlSQL> Rem ===========================================================================
执行和数据库升级相关的脚本catupgrade.sql
SQL> @$ORACLE_HOME/rdbms/admin/catupgrd.sql省略…TIMESTAMP——————————————————————————–COMP_TIMESTAMP
UPGRD_END 2015-03-31 23:04:46.Oracle Database 10.2 Upgrade Status Utility 03-31-2015 23:04:46.Component Status Version HH:MM:SSOracle Database Server VALID 10.2.0.5.0 00:18:17JServer JAVA Virtual Machine VALID 10.2.0.5.0 00:04:52Oracle XDK VALID 10.2.0.5.0
00:00:49Oracle Database Java Packages VALID 10.2.0.5.0 00:00:32Oracle Text VALID 10.2.0.5.0 00:00:56Oracle XML Database VALID 10.2.0.5.0 00:02:33Oracle Workspace Manager VALID 10.2.0.5.0 00:01:05Oracle Data Mining INVALID 10.2.0.5.0 00:00:30OLAP Analytic Workspace
VALID 10.2.0.5.0 00:01:07OLAP Catalog VALID 10.2.0.5.0 00:01:32Oracle OLAP API VALID 10.2.0.5.0 00:01:08Oracle interMedia VALID 10.2.0.5.0 00:05:11Spatial VALID 10.2.0.5.0 00:06:40Oracle Expression Filter INVALID 10.2.0.5.0 00:00:25Oracle Enterprise Manager
VALID 10.2.0.5.0 00:02:50Oracle Rule Manager INVALID 10.2.0.5.0 00:00:20.Total Upgrade Time: 00:51:07DOC>#######################################################################DOC>#######################################################################DOC>DOC>
The above PL/SQL lists the SERVER components in the upgradedDOC> database, along with their current version and status.DOC>DOC> Please review the status and version columns and look forDOC> any errors in the spool log file. If there are errors in the spoolDOC>
file, or any components are not VALID or not the current version,DOC> consult the Oracle Database Upgrade Guide for troubleshootingDOC> recommendations.DOC>DOC> Next shutdown immediate, restart for normal operation, and thenDOC> run utlrp.sql to recompile
any invalid application objects.DOC>DOC>#######################################################################DOC>#######################################################################DOC>
再次运行utlrp.sql脚本来进行编译无效对象
SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sqlTIMESTAMP——————————————————————————–COMP_TIMESTAMP
UTLRP_BGN 2015-03-31 23:05:21DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalidDOC> objects in the database. Recompilation time is proportional to theDOC> number of invalid objects in the database, so this command may takeDOC> a long time
to execute on a database with a large number of invalidDOC> objects.DOC>DOC> Use the following queries to track recompilation progress:DOC>DOC> 1. Query returning the number of invalid objects remaining. ThisDOC> number should decrease with time.DOC> SELECT
COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);DOC>DOC> 2. Query returning the number of objects compiled so far. This numberDOC> should increase with time.DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;DOC>DOC> This script automatically chooses serial or parallel
recompilationDOC> based on the number of CPUs available (parameter cpu_count) multipliedDOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).DOC> On RAC, this number is added across all RAC nodes.DOC>DOC> UTL_RECOMP uses DBMS_SCHEDULER
to create jobs for parallelDOC> recompilation. Jobs are created without instance affinity so that theyDOC> can migrate across RAC nodes. Use the following queries to verifyDOC> whether UTL_RECOMP jobs are being created and run correctly:DOC>DOC> 1. Query showing
jobs created by UTL_RECOMPDOC> SELECT job_name FROM dba_scheduler_jobsDOC> WHERE job_name like ‘UTL_RECOMP_SLAVE_%’;DOC>DOC> 2. Query showing UTL_RECOMP jobs that are runningDOC> SELECT job_name FROM dba_scheduler_running_jobsDOC> WHERE job_name like ‘UTL_RECOMP_SLAVE_%’;DOC>#TIMESTAMP——————————————————————————–COMP_TIMESTAMP
UTLRP_END 2015-03-31 23:07:54DOC> The following query reports the number of objects that have compiledDOC> with errors (objects that compile with errors have status set to 3 inDOC> obj$). If the number is higher than expected, please examine the errorDOC>
messages reported with each object (using SHOW ERRORS) to see if theyDOC> point to system misconfiguration or resource constraints that must beDOC> fixed before attempting to recompile these objects.DOC>#OBJECTS WITH ERRORS——————- 5DOC> The following
query reports the number of errors caught duringDOC> recompilation. If this number is non-zero, please query the errorDOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errorsDOC> are due to misconfiguration or resource constraints that must
beDOC> fixed before objects can compile successfully.DOC>#ERRORS DURING RECOMPILATION————————— 0SQL> column comp_name format a35SQL> SELECT comp_name, status, substr(version,1,10) as version from dba_server_registry order by modified;COMP_NAME
STATUS VERSION———————————– ———————- ——————–Oracle Enterprise Manager VALID 10.2.0.5.0Oracle Database Packages and Types VALID 10.2.0.5.0Oracle Workspace Manager VALID 10.2.0.5.0JServer JAVA Virtual Machine
VALID 10.2.0.5.0Oracle Database Java Packages VALID 10.2.0.5.0Oracle Database Catalog Views VALID 10.2.0.5.0Oracle XDK VALID 10.2.0.5.0Oracle Expression Filter VALID 10.2.0.5.0Oracle Data Mining VALID 10.2.0.5.0Oracle Text VALID 10.2.0.5.0Oracle Rule Manager
VALID 10.2.0.5.0Oracle interMedia VALID 10.2.0.5.0Oracle XML Database VALID 10.2.0.5.0OLAP Analytic Workspace VALID 10.2.0.5.0Oracle OLAP API VALID 10.2.0.5.0OLAP Catalog VALID 10.2.0.5.0Spatial VALID 10.2.0.5.0
IT文库 » RMAN同字节序跨平台跨版本迁移数据库
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址