Rman 單例項filesystem(Windows)恢復到ASM環境(Linux)
一.使用RMAN convert將Oracle 從Windows(windows server 2008 R2)遷移到Linux(OLE 6.5)
官方文件關於RMAN CONVERT 解釋()
Database Conversion
To convert a whole database to a different platform, both platforms must use the same endian format.
The RMAN CONVERT DATABASE command automates the movement of an entire database from a source platform to a destination platform.
The transported database contains the same data as the source database and also has, with a few exceptions, the same settings as the source database.
在不同平臺轉換整個庫,兩個平臺必須包含相同位元組順序,RMAN CONVERT 命令會自動轉換整個庫從源平臺到目標平臺
Files automatically transported to the destination platform include:
Data files that belong to permanent tablespaces
Unlike transporting tablespaces across platforms, transporting entire databases requires that certain types of blocks, such as blocks in undo segments,
be reformatted to ensure compatibility with the destination platform. Even though the endian formats for the source and destination platforms are the same,
the data files for a transportable database must undergo a conversion process. You cannot simply copy data files from one platform to another as you can
when transporting tablespaces.
不同於跨平臺傳輸表空間,將整個資料庫要求某些型別的塊,如塊在撤銷段,而為了確保與目標平臺的相容性,儘管在源和目標平臺的位元組序的格式是相同的,
一個可移動的資料庫的資料檔案必須經過轉換過程。當傳輸表空間,你不能簡單的複製資料檔案從一個平臺到另一個平臺。
Initialization parameter file or server parameter file
初始化引數檔案或者是服務引數檔案
If the database uses a text-based initialization parameter file, then RMAN transports it. If the database uses a server parameter file,
then RMAN generates an initialization parameter file based on the server parameter file, transports it and creates a new server parameter
file at the destination based on the settings in the initialization parameter file.
Usually, some parameters in the initialization parameter file require manual updating for the new database. For example, you may change
the DB_NAME and parameters such as CONTROL_FILES that indicate the locations of files on the destination host.
You can convert the format of the data files either on the source platform or on the destination platform. The CONVERT DATABASE ON DESTINATION PLATFORM command does not convert the format of data files. Rather, it generates scripts that you can run manually to perform the conversion. The CONVERT SCRIPT parameter creates a convert script that you can manually execute at the destination host to convert data file copies in batch mode. The TRANSPORT SCRIPT parameter generates a transport script that contains SQL statements to create the new database on the destination platform.
1.搭建單例項環境(請參照)
源庫環境
OS平臺:WINDOWS 2008 R2
DB: Oracle 11.2.0.4(X64)
1. 在源庫新增事例資料
SQL> create tablespace king datafile 'C:\APP\ADMINISTRATOR\ORADATA\NETDATA\king01.dbf' size 50M
表空間已建立。
SQL> create user king identified by king default tablespace king temporary tablespace temp;
使用者已建立。
SQL> grant connect,resource to king;
授權成功。
SQL> conn king/king
已連線。
SQL> create table test (id int,name varchar2(20));
表已建立。
SQL> insert into test values(1,'test');
已建立 1 行。
SQL> insert into test values(2,'test1');
已建立 1 行。
SQL> commit;
提交完成。
SQL>
SQL>
SQL>
SQL> insert into test values(3,'test3');
已建立 1 行。
SQL>
SQL>
SQL> commit;
提交完成。
SQL> select * from test;
ID NAME
---------- ----------------------------------------
1 test
2 test1
3 test3
SQL> show user;
USER 為 "KING"
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on 星期五 6月 19 21:06:47 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
連線到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select file_name from dba_data_files;
FILE_NAME
-------------------------------------------------------------------------------
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\USERS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\UNDOTBS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\SYSAUX01.DBF
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\SYSTEM01.DBF
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\EXAMPLE01.DBF
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\KING01.DBF
2. 查詢源平臺
SQL> select PLATFORM_NAME from v$database;
PLATFORM_NAME
--------------------------------------------------------------------------------
Microsoft Windows x86 64-bit
SQL>
SQL> select PLATFORM_NAME,ENDIAN_FORMAT from v$transportable_platform order by 1,2;
PLATFORM_NAME ENDIAN_FORMAT
-------------------------------------------------- ----------------------------
AIX-Based Systems (64-bit) Big
Apple Mac OS Big
Apple Mac OS (x86-64) Little
HP IA Open VMS Little
HP Open VMS Little
HP Tru64 UNIX Little
HP-UX (64-bit) Big
HP-UX IA (64-bit) Big
IBM Power Based Linux Big
IBM zSeries Based Linux Big
Linux IA (32-bit) Little
PLATFORM_NAME ENDIAN_FORMAT
-------------------------------------------------- ----------------------------
Linux IA (64-bit) Little
Linux x86 64-bit Little
Microsoft Windows IA (32-bit) Little
Microsoft Windows IA (64-bit) Little
Microsoft Windows x86 64-bit Little
Solaris Operating System (x86) Little
Solaris Operating System (x86-64) Little
Solaris[tm] OE (32-bit) Big
Solaris[tm] OE (64-bit) Big
已選擇20行。
SQL> shutdown immediate
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。
SQL> startup mount
ORACLE 例程已經啟動。
Total System Global Area 855982080 bytes
Fixed Size 2286032 bytes
Variable Size 549457456 bytes
Database Buffers 297795584 bytes
Redo Buffers 6443008 bytes
資料庫裝載完畢。
SQL> alter database open read only;
資料庫已更改。
SQL> select open_mode from v$database;
OPEN_MODE
----------------------------------------
READ ONLY
3.轉換之前檢查
Execute the DBMS_TDB.CHECK_DB function.
This check ensures that no conditions would prevent the transport of the database,
such as incorrect compatibility settings, in-doubt or active transactions, or
incompatible endian formats between the source platform and destination platform.
用DBMS_TDB.CHECK_DB這個檢查確保無條件將使資料庫傳輸,如不正確的相容性設定,有in-doubt或活躍的事務,或不相容的Endian格式之間的源平臺和目標平臺。
SQL> set serveroutput on
SQL> declare
2 v_check boolean;
3 begin
4 v_check:=dbms_tdb.check_db('Linux x86 64-bit',dbms_tdb.skip_none);
5 end;
6 /
PL/SQL 過程已成功完成。
Execute the DBMS_TDB.CHECK_EXTERNAL function to identify any external tables, directories, or BFILEs. RMAN cannot automate the transport of
these files, so you must copy the files manually and re-create the database directories.
執行DBMS_TDB.CHECK_EXTERNAL函式標識任何外部表,目錄或者是BFILEs.這些都是RMAN不能自動轉換的檔案,因此你必須手動複製或者是重新這些資料庫目錄
SQL> declare
2 v_ext boolean;
3 begin
4 v_ext:=dbms_tdb.check_external;
5 end;
6 /
The following external tables exist in the database:
SH.SALES_TRANSACTIONS_EXT
The following directories exist in the database:
SYS.MEDIA_DIR, SYS.LOG_FILE_DIR, SYS.DATA_FILE_DIR, SYS.SS_OE_XMLDIR, SYS.SUBDIR, SYS.XMLDIR, SYS.ORACLE_OCM_CONFIG_DIR2, SYS.ORACLE_OCM_CONFIG_DIR, SYS.DATA_PUMP_DIR
The following BFILEs exist in the database:
PM.PRINT_MEDIA
PL/SQL 過程已成功完成。
4.使用RMAN CONVERT進行轉換源DB
源端使用RMAN convert將資料檔案轉換成"Linux x86 64-bit"
RMAN> convert database new database 'netdata'
2> transport script 'c:\backup\trans.sql' to platform 'Linux x86 64-bit'
3> db_file_name_convert 'C:\app\Administrator\oradata\netdata' 'c:\backup';
啟動 conversion at source 於 19-6月 -15
使用通道 ORA_DISK_1
在資料庫中找到外部表 SH.SALES_TRANSACTIONS_EXT
在資料庫中找到目錄 SYS.SUBDIR
在資料庫中找到目錄 SYS.SS_OE_XMLDIR
在資料庫中找到目錄 SYS.MEDIA_DIR
在資料庫中找到目錄 SYS.LOG_FILE_DIR
在資料庫中找到目錄 SYS.DATA_FILE_DIR
在資料庫中找到目錄 SYS.XMLDIR
在資料庫中找到目錄 SYS.ORACLE_OCM_CONFIG_DIR2
在資料庫中找到目錄 SYS.ORACLE_OCM_CONFIG_DIR
在資料庫中找到目錄 SYS.DATA_PUMP_DIR
在資料庫中找到 BFILE PM.PRINT_MEDIA
在口令檔案中找到使用者 SYS (具有 SYSDBA and SYSOPER 許可權)
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00001 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\SYSTEM01.DBF
已轉換的資料檔案 = C:\BACKUP\SYSTEM01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:55
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00002 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\SYSAUX01.DBF
已轉換的資料檔案 = C:\BACKUP\SYSAUX01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:35
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00005 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\EXAMPLE01.DBF
已轉換的資料檔案 = C:\BACKUP\EXAMPLE01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:35
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00003 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\UNDOTBS01.DBF
已轉換的資料檔案 = C:\BACKUP\UNDOTBS01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:08
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00006 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\KING01.DBF
已轉換的資料檔案 = C:\BACKUP\KING01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:07
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00004 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\USERS01.DBF
已轉換的資料檔案 = C:\BACKUP\USERS01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:01
編輯 init.ora 檔案 C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\INIT_00Q9TGBE_1_0.ORA。此 PFILE 將用於在目標平臺上建立資料庫據
在目標平臺上執行 SQL 指令碼 C:\BACKUP\TRANS.SQL 以建立資料庫
要重新編譯所有 PL/SQL 模組, 請在目標平臺上執行 utlirp.sql 和 utlrp.sql
要更改內部資料庫識別符號, 請使用 DBNEWID 實用程式
完成 conversion at source 於 19-6月 -15
5.轉化後檔案傳輸至目標DB伺服器併為目標DB伺服器建立伺服器引數檔案
將c:\backup下面轉換的檔案複製到目標伺服器(Oracle Linux X64)
為目標機器建立引數檔案
直接修改此檔案C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\INIT_00Q9TGBE_1_0.ORA
修改為如下並儲存檔案為initnetdata.ora:
*.__db_cache_size=335544320
netdata.__db_cache_size=167772160
*.__java_pool_size=4194304
netdata.__java_pool_size=20971520
*.__large_pool_size=4194304
netdata.__large_pool_size=8388608
netdata.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.__pga_aggregate_target=318767104
netdata.__pga_aggregate_target=381681664
*.__sga_target=541065216
netdata.__sga_target=478150656
*.__shared_io_pool_size=0
netdata.__shared_io_pool_size=0
*.__shared_pool_size=184549376
netdata.__shared_pool_size=268435456
*.__streams_pool_size=0
netdata.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/netdata/adump'
*.audit_trail='OS'
*.compatible='11.2.0.4.0'
*.control_files='/data/netdata/control01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='netdata'
*.db_recovery_file_dest='/data/netdata/flash_recovery_area'
*.db_recovery_file_dest_size=4102029312
*.dispatchers='(PROTOCOL=TCP) (SERVICE=netdataXDB)'
*.memory_target=859832320
*.open_cursors=500
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
6. 目標DB伺服器建立所需目錄用oracle使用者建立。
mkdir -p /u01/app/oracle/admin/netdata/adump
mkdir -p /data/netdata/
mkdir -p /data/netdata/flash_recovery_area
7.恢復操作
[oracle@OLEASM1 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on 星期三 6月 17 23:29:35 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
已連線到空閒例程。
利用建立的引數檔案啟動到nomount
SQL> startup nomount pfile='initnetdata.ora';
ORACLE 例程已經啟動。
Total System Global Area 855982080 bytes
Fixed Size 2258040 bytes
Variable Size 671091592 bytes
Database Buffers 176160768 bytes
Redo Buffers 6471680 bytes
建立控制檔案
CREATE CONTROLFILE REUSE SET DATABASE "netdata" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/data/netdata/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/data/netdata/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/data/netdata/redo03.log' SIZE 50M BLOCKSIZE 512
DATAFILE
'/data/netdata/SYSTEM01.DBF',
'/data/netdata/SYSAUX01.DBF',
'/data/netdata/UNDOTBS01.DBF',
'/data/netdata/USERS01.DBF',
'/data/netdata/EXAMPLE01.DBF',
'/data/netdata/KING01.DBF'
CHARACTER SET ZHS16GBK
resetlogs方式啟動資料庫,建立臨時表空間
SQL> ALTER DATABASE OPEN RESETLOGS;
ALTER TABLESPACE TEMP ADD TEMPFILE '/data/netdata/temp01.dbf' SIZE 200M AUTOEXTEND ON next 20M maxsize 2G;
編譯64位平臺下的物件
SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP UPGRADE
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 2098208 bytes
Variable Size 167775200 bytes
Database Buffers 436207616 bytes
Redo Buffers 6287360 bytes
Database mounted.
Database opened.
SQL> @?/rdbms/admin/utlirp.sql
重新編譯PL/SQL模組
SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 2098208 bytes
Variable Size 167775200 bytes
Database Buffers 436207616 bytes
Redo Buffers 6287360 bytes
Database mounted.
Database opened.
SQL> @?/rdbms/admin/utlrp.sql
SQL> select name,platform_name,open_mode from v$database;
NAME
---------
PLATFORM_NAME
--------------------------------------------------------------------------------
OPEN_MODE
--------------------
NETDATA
Linux x86 64-bit
READ WRITE
轉換完成!!!
其實這些操作步驟都傳輸指令碼里面
c:\backup\trans.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 PERFORMANCE
STARTUP NOMOUNT PFILE='C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\INIT_00Q9TGBE_1_0.ORA'
CREATE CONTROLFILE REUSE SET DATABASE "NETDATA" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 'C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\ARCH_D-NETDATA_ID-376675875_S-4_T-1_A-882816102_03Q9TGBE' SIZE 50M BLOCKSIZE 512,
GROUP 2 'C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\ARCH_D-NETDATA_ID-376675875_S-5_T-1_A-882816102_04Q9TGBE' SIZE 50M BLOCKSIZE 512,
GROUP 3 'C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\ARCH_D-NETDATA_ID-376675875_S-6_T-1_A-882816102_05Q9TGBE' SIZE 50M BLOCKSIZE 512
DATAFILE
'C:\BACKUP\SYSTEM01.DBF',
'C:\BACKUP\SYSAUX01.DBF',
'C:\BACKUP\UNDOTBS01.DBF',
'C:\BACKUP\USERS01.DBF',
'C:\BACKUP\EXAMPLE01.DBF',
'C:\BACKUP\KING01.DBF'
CHARACTER SET AL32UTF8
;
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS UPGRADE;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE 'C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\DATA_D-NETDATA_I-376675875_TS-TEMP_FNO-1_06Q9TGBE'
SIZE 30408704 AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-- 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='C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\INIT_00Q9TGBE_1_0.ORA'
@@ ?/rdbms/admin/utlirp.sql
SHUTDOWN IMMEDIATE
STARTUP PFILE='C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\INIT_00Q9TGBE_1_0.ORA'
-- The following step will recompile all PL/SQL modules.
-- It may take serveral hours to complete.
@@ ?/rdbms/admin/utlrp.sql
set feedback 6;
官方文件關於RMAN CONVERT 解釋()
Database Conversion
To convert a whole database to a different platform, both platforms must use the same endian format.
The RMAN CONVERT DATABASE command automates the movement of an entire database from a source platform to a destination platform.
The transported database contains the same data as the source database and also has, with a few exceptions, the same settings as the source database.
在不同平臺轉換整個庫,兩個平臺必須包含相同位元組順序,RMAN CONVERT 命令會自動轉換整個庫從源平臺到目標平臺
Files automatically transported to the destination platform include:
Data files that belong to permanent tablespaces
Unlike transporting tablespaces across platforms, transporting entire databases requires that certain types of blocks, such as blocks in undo segments,
be reformatted to ensure compatibility with the destination platform. Even though the endian formats for the source and destination platforms are the same,
the data files for a transportable database must undergo a conversion process. You cannot simply copy data files from one platform to another as you can
when transporting tablespaces.
不同於跨平臺傳輸表空間,將整個資料庫要求某些型別的塊,如塊在撤銷段,而為了確保與目標平臺的相容性,儘管在源和目標平臺的位元組序的格式是相同的,
一個可移動的資料庫的資料檔案必須經過轉換過程。當傳輸表空間,你不能簡單的複製資料檔案從一個平臺到另一個平臺。
Initialization parameter file or server parameter file
初始化引數檔案或者是服務引數檔案
If the database uses a text-based initialization parameter file, then RMAN transports it. If the database uses a server parameter file,
then RMAN generates an initialization parameter file based on the server parameter file, transports it and creates a new server parameter
file at the destination based on the settings in the initialization parameter file.
Usually, some parameters in the initialization parameter file require manual updating for the new database. For example, you may change
the DB_NAME and parameters such as CONTROL_FILES that indicate the locations of files on the destination host.
You can convert the format of the data files either on the source platform or on the destination platform. The CONVERT DATABASE ON DESTINATION PLATFORM command does not convert the format of data files. Rather, it generates scripts that you can run manually to perform the conversion. The CONVERT SCRIPT parameter creates a convert script that you can manually execute at the destination host to convert data file copies in batch mode. The TRANSPORT SCRIPT parameter generates a transport script that contains SQL statements to create the new database on the destination platform.
1.搭建單例項環境(請參照)
源庫環境
OS平臺:WINDOWS 2008 R2
DB: Oracle 11.2.0.4(X64)
1. 在源庫新增事例資料
SQL> create tablespace king datafile 'C:\APP\ADMINISTRATOR\ORADATA\NETDATA\king01.dbf' size 50M
表空間已建立。
SQL> create user king identified by king default tablespace king temporary tablespace temp;
使用者已建立。
SQL> grant connect,resource to king;
授權成功。
SQL> conn king/king
已連線。
SQL> create table test (id int,name varchar2(20));
表已建立。
SQL> insert into test values(1,'test');
已建立 1 行。
SQL> insert into test values(2,'test1');
已建立 1 行。
SQL> commit;
提交完成。
SQL>
SQL>
SQL>
SQL> insert into test values(3,'test3');
已建立 1 行。
SQL>
SQL>
SQL> commit;
提交完成。
SQL> select * from test;
ID NAME
---------- ----------------------------------------
1 test
2 test1
3 test3
SQL> show user;
USER 為 "KING"
C:\Users\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on 星期五 6月 19 21:06:47 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
連線到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select file_name from dba_data_files;
FILE_NAME
-------------------------------------------------------------------------------
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\USERS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\UNDOTBS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\SYSAUX01.DBF
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\SYSTEM01.DBF
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\EXAMPLE01.DBF
C:\APP\ADMINISTRATOR\ORADATA\NETDATA\KING01.DBF
2. 查詢源平臺
SQL> select PLATFORM_NAME from v$database;
PLATFORM_NAME
--------------------------------------------------------------------------------
Microsoft Windows x86 64-bit
SQL>
SQL> select PLATFORM_NAME,ENDIAN_FORMAT from v$transportable_platform order by 1,2;
PLATFORM_NAME ENDIAN_FORMAT
-------------------------------------------------- ----------------------------
AIX-Based Systems (64-bit) Big
Apple Mac OS Big
Apple Mac OS (x86-64) Little
HP IA Open VMS Little
HP Open VMS Little
HP Tru64 UNIX Little
HP-UX (64-bit) Big
HP-UX IA (64-bit) Big
IBM Power Based Linux Big
IBM zSeries Based Linux Big
Linux IA (32-bit) Little
PLATFORM_NAME ENDIAN_FORMAT
-------------------------------------------------- ----------------------------
Linux IA (64-bit) Little
Linux x86 64-bit Little
Microsoft Windows IA (32-bit) Little
Microsoft Windows IA (64-bit) Little
Microsoft Windows x86 64-bit Little
Solaris Operating System (x86) Little
Solaris Operating System (x86-64) Little
Solaris[tm] OE (32-bit) Big
Solaris[tm] OE (64-bit) Big
已選擇20行。
SQL> shutdown immediate
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。
SQL> startup mount
ORACLE 例程已經啟動。
Total System Global Area 855982080 bytes
Fixed Size 2286032 bytes
Variable Size 549457456 bytes
Database Buffers 297795584 bytes
Redo Buffers 6443008 bytes
資料庫裝載完畢。
SQL> alter database open read only;
資料庫已更改。
SQL> select open_mode from v$database;
OPEN_MODE
----------------------------------------
READ ONLY
3.轉換之前檢查
Execute the DBMS_TDB.CHECK_DB function.
This check ensures that no conditions would prevent the transport of the database,
such as incorrect compatibility settings, in-doubt or active transactions, or
incompatible endian formats between the source platform and destination platform.
用DBMS_TDB.CHECK_DB這個檢查確保無條件將使資料庫傳輸,如不正確的相容性設定,有in-doubt或活躍的事務,或不相容的Endian格式之間的源平臺和目標平臺。
SQL> set serveroutput on
SQL> declare
2 v_check boolean;
3 begin
4 v_check:=dbms_tdb.check_db('Linux x86 64-bit',dbms_tdb.skip_none);
5 end;
6 /
PL/SQL 過程已成功完成。
Execute the DBMS_TDB.CHECK_EXTERNAL function to identify any external tables, directories, or BFILEs. RMAN cannot automate the transport of
these files, so you must copy the files manually and re-create the database directories.
執行DBMS_TDB.CHECK_EXTERNAL函式標識任何外部表,目錄或者是BFILEs.這些都是RMAN不能自動轉換的檔案,因此你必須手動複製或者是重新這些資料庫目錄
SQL> declare
2 v_ext boolean;
3 begin
4 v_ext:=dbms_tdb.check_external;
5 end;
6 /
The following external tables exist in the database:
SH.SALES_TRANSACTIONS_EXT
The following directories exist in the database:
SYS.MEDIA_DIR, SYS.LOG_FILE_DIR, SYS.DATA_FILE_DIR, SYS.SS_OE_XMLDIR, SYS.SUBDIR, SYS.XMLDIR, SYS.ORACLE_OCM_CONFIG_DIR2, SYS.ORACLE_OCM_CONFIG_DIR, SYS.DATA_PUMP_DIR
The following BFILEs exist in the database:
PM.PRINT_MEDIA
PL/SQL 過程已成功完成。
4.使用RMAN CONVERT進行轉換源DB
源端使用RMAN convert將資料檔案轉換成"Linux x86 64-bit"
RMAN> convert database new database 'netdata'
2> transport script 'c:\backup\trans.sql' to platform 'Linux x86 64-bit'
3> db_file_name_convert 'C:\app\Administrator\oradata\netdata' 'c:\backup';
啟動 conversion at source 於 19-6月 -15
使用通道 ORA_DISK_1
在資料庫中找到外部表 SH.SALES_TRANSACTIONS_EXT
在資料庫中找到目錄 SYS.SUBDIR
在資料庫中找到目錄 SYS.SS_OE_XMLDIR
在資料庫中找到目錄 SYS.MEDIA_DIR
在資料庫中找到目錄 SYS.LOG_FILE_DIR
在資料庫中找到目錄 SYS.DATA_FILE_DIR
在資料庫中找到目錄 SYS.XMLDIR
在資料庫中找到目錄 SYS.ORACLE_OCM_CONFIG_DIR2
在資料庫中找到目錄 SYS.ORACLE_OCM_CONFIG_DIR
在資料庫中找到目錄 SYS.DATA_PUMP_DIR
在資料庫中找到 BFILE PM.PRINT_MEDIA
在口令檔案中找到使用者 SYS (具有 SYSDBA and SYSOPER 許可權)
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00001 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\SYSTEM01.DBF
已轉換的資料檔案 = C:\BACKUP\SYSTEM01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:55
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00002 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\SYSAUX01.DBF
已轉換的資料檔案 = C:\BACKUP\SYSAUX01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:35
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00005 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\EXAMPLE01.DBF
已轉換的資料檔案 = C:\BACKUP\EXAMPLE01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:35
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00003 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\UNDOTBS01.DBF
已轉換的資料檔案 = C:\BACKUP\UNDOTBS01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:08
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00006 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\KING01.DBF
已轉換的資料檔案 = C:\BACKUP\KING01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:07
通道 ORA_DISK_1: 啟動資料檔案轉換
輸入資料檔案: 檔案號=00004 名稱=C:\APP\ADMINISTRATOR\ORADATA\NETDATA\USERS01.DBF
已轉換的資料檔案 = C:\BACKUP\USERS01.DBF
通道 ORA_DISK_1: 資料檔案轉換完畢, 經過時間: 00:00:01
編輯 init.ora 檔案 C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\INIT_00Q9TGBE_1_0.ORA。此 PFILE 將用於在目標平臺上建立資料庫據
在目標平臺上執行 SQL 指令碼 C:\BACKUP\TRANS.SQL 以建立資料庫
要重新編譯所有 PL/SQL 模組, 請在目標平臺上執行 utlirp.sql 和 utlrp.sql
要更改內部資料庫識別符號, 請使用 DBNEWID 實用程式
完成 conversion at source 於 19-6月 -15
5.轉化後檔案傳輸至目標DB伺服器併為目標DB伺服器建立伺服器引數檔案
將c:\backup下面轉換的檔案複製到目標伺服器(Oracle Linux X64)
為目標機器建立引數檔案
直接修改此檔案C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\INIT_00Q9TGBE_1_0.ORA
修改為如下並儲存檔案為initnetdata.ora:
*.__db_cache_size=335544320
netdata.__db_cache_size=167772160
*.__java_pool_size=4194304
netdata.__java_pool_size=20971520
*.__large_pool_size=4194304
netdata.__large_pool_size=8388608
netdata.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
*.__pga_aggregate_target=318767104
netdata.__pga_aggregate_target=381681664
*.__sga_target=541065216
netdata.__sga_target=478150656
*.__shared_io_pool_size=0
netdata.__shared_io_pool_size=0
*.__shared_pool_size=184549376
netdata.__shared_pool_size=268435456
*.__streams_pool_size=0
netdata.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/netdata/adump'
*.audit_trail='OS'
*.compatible='11.2.0.4.0'
*.control_files='/data/netdata/control01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='netdata'
*.db_recovery_file_dest='/data/netdata/flash_recovery_area'
*.db_recovery_file_dest_size=4102029312
*.dispatchers='(PROTOCOL=TCP) (SERVICE=netdataXDB)'
*.memory_target=859832320
*.open_cursors=500
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
6. 目標DB伺服器建立所需目錄用oracle使用者建立。
mkdir -p /u01/app/oracle/admin/netdata/adump
mkdir -p /data/netdata/
mkdir -p /data/netdata/flash_recovery_area
7.恢復操作
[oracle@OLEASM1 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on 星期三 6月 17 23:29:35 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
已連線到空閒例程。
利用建立的引數檔案啟動到nomount
SQL> startup nomount pfile='initnetdata.ora';
ORACLE 例程已經啟動。
Total System Global Area 855982080 bytes
Fixed Size 2258040 bytes
Variable Size 671091592 bytes
Database Buffers 176160768 bytes
Redo Buffers 6471680 bytes
建立控制檔案
CREATE CONTROLFILE REUSE SET DATABASE "netdata" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/data/netdata/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/data/netdata/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/data/netdata/redo03.log' SIZE 50M BLOCKSIZE 512
DATAFILE
'/data/netdata/SYSTEM01.DBF',
'/data/netdata/SYSAUX01.DBF',
'/data/netdata/UNDOTBS01.DBF',
'/data/netdata/USERS01.DBF',
'/data/netdata/EXAMPLE01.DBF',
'/data/netdata/KING01.DBF'
CHARACTER SET ZHS16GBK
resetlogs方式啟動資料庫,建立臨時表空間
SQL> ALTER DATABASE OPEN RESETLOGS;
ALTER TABLESPACE TEMP ADD TEMPFILE '/data/netdata/temp01.dbf' SIZE 200M AUTOEXTEND ON next 20M maxsize 2G;
編譯64位平臺下的物件
SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP UPGRADE
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 2098208 bytes
Variable Size 167775200 bytes
Database Buffers 436207616 bytes
Redo Buffers 6287360 bytes
Database mounted.
Database opened.
SQL> @?/rdbms/admin/utlirp.sql
重新編譯PL/SQL模組
SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP
ORACLE instance started.
Total System Global Area 612368384 bytes
Fixed Size 2098208 bytes
Variable Size 167775200 bytes
Database Buffers 436207616 bytes
Redo Buffers 6287360 bytes
Database mounted.
Database opened.
SQL> @?/rdbms/admin/utlrp.sql
SQL> select name,platform_name,open_mode from v$database;
NAME
---------
PLATFORM_NAME
--------------------------------------------------------------------------------
OPEN_MODE
--------------------
NETDATA
Linux x86 64-bit
READ WRITE
轉換完成!!!
其實這些操作步驟都傳輸指令碼里面
c:\backup\trans.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 PERFORMANCE
STARTUP NOMOUNT PFILE='C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\INIT_00Q9TGBE_1_0.ORA'
CREATE CONTROLFILE REUSE SET DATABASE "NETDATA" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 'C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\ARCH_D-NETDATA_ID-376675875_S-4_T-1_A-882816102_03Q9TGBE' SIZE 50M BLOCKSIZE 512,
GROUP 2 'C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\ARCH_D-NETDATA_ID-376675875_S-5_T-1_A-882816102_04Q9TGBE' SIZE 50M BLOCKSIZE 512,
GROUP 3 'C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\ARCH_D-NETDATA_ID-376675875_S-6_T-1_A-882816102_05Q9TGBE' SIZE 50M BLOCKSIZE 512
DATAFILE
'C:\BACKUP\SYSTEM01.DBF',
'C:\BACKUP\SYSAUX01.DBF',
'C:\BACKUP\UNDOTBS01.DBF',
'C:\BACKUP\USERS01.DBF',
'C:\BACKUP\EXAMPLE01.DBF',
'C:\BACKUP\KING01.DBF'
CHARACTER SET AL32UTF8
;
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS UPGRADE;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE 'C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\DATA_D-NETDATA_I-376675875_TS-TEMP_FNO-1_06Q9TGBE'
SIZE 30408704 AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-- 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='C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\INIT_00Q9TGBE_1_0.ORA'
@@ ?/rdbms/admin/utlirp.sql
SHUTDOWN IMMEDIATE
STARTUP PFILE='C:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_2\DATABASE\INIT_00Q9TGBE_1_0.ORA'
-- The following step will recompile all PL/SQL modules.
-- It may take serveral hours to complete.
@@ ?/rdbms/admin/utlrp.sql
set feedback 6;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24486203/viewspace-1705702/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- RAC asm恢復到單例項ASM單例
- rac asm 恢復到 單例項 1ASM單例
- rac asm 恢復到 單例項 2ASM單例
- rac到單例項的rman恢復單例
- RMAN異機恢復:RAC到單例項單例
- 恢復RAC資料庫到單例項(ASM)資料庫單例ASM
- oracle 11C rman 恢復到單例項Oracle單例
- Windows平臺模擬單例項ASM環境Windows單例ASM
- 10g rac asm 恢復到 單例項(二)ASM單例
- 10g rac asm 恢復到 單例項(一)ASM單例
- 單機環境配置ASM例項ASM
- RMAN Catalog環境下異機全庫恢復例項
- rac恢復到單例項單例
- 【ASM學習】在windows 環境下建立ASM例項ASMWindows
- ASM單例項(Oracle 11.2.0.4)環境(一)ASM單例Oracle
- ASM單例項(Oracle 11.2.0.4)環境(二)ASM單例Oracle
- 單機環境安裝配置ASM例項ASM
- Oracle 11.2.0.4 從單例項,使用RMAN 異機恢復到RACOracle單例
- 使用RMAN將RAC+ASM複製到單例項+ASM上ASM單例
- 【RMAN】RAC資料恢復至單機環境資料恢復
- 單例項環境利用備份恢復RAC資料庫(四)單例資料庫
- 單例項環境利用備份恢復RAC資料庫(三)單例資料庫
- 單例項環境利用備份恢復RAC資料庫(二)單例資料庫
- 單例項環境利用備份恢復RAC資料庫(一)單例資料庫
- RAC恢復到單例項節點上單例
- 恢復rac db(raw)到單例項下單例
- 單例項備份集恢復到RAC單例
- RAC從帶庫到單例項的恢復單例
- 刪除Linux非rac環境下的ASM例項LinuxASM
- 單例項恢復至RAC單例
- RMAN例項備份與恢復詳解
- 刪除Linux非rac環境下的ASM例項(轉)LinuxASM
- (轉)Oracle rac環境下清除asm例項OracleASM
- RMAN異機恢復異作業系統(Linux到Windows)作業系統LinuxWindows
- RAC資料庫恢復到單例項資料庫資料庫單例
- RAC12.1.0.2.161018PSU從RAC+ASM恢復到單例項非ASM遇到的BUGASM單例
- Windows oracle 11g rman備份恢復到linux系統WindowsOracleLinux
- 單例項刪除ASM例項單例ASM