共計(jì) 10412 個(gè)字符,預(yù)計(jì)需要花費(fèi) 27 分鐘才能閱讀完成。
本篇內(nèi)容主要講解“如何使用備份集跨平臺(tái)傳輸整個(gè) CDB 數(shù)據(jù)庫”,感興趣的朋友不妨來看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓丸趣 TV 小編來帶大家學(xué)習(xí)“如何使用備份集跨平臺(tái)傳輸整個(gè) CDB 數(shù)據(jù)庫”吧!
可以從源平臺(tái)傳輸整個(gè)數(shù)據(jù)庫到有相同字節(jié)序的不同平臺(tái)。當(dāng)為了傳輸數(shù)據(jù)庫而創(chuàng)建跨平臺(tái)備份時(shí),可以在源平臺(tái)或目標(biāo)平臺(tái)上執(zhí)行對(duì)數(shù)據(jù)庫的轉(zhuǎn)換。在目標(biāo)平臺(tái)執(zhí)行對(duì)數(shù)據(jù)庫的轉(zhuǎn)換的最大好處就是執(zhí)行轉(zhuǎn)換的開鎖從源平臺(tái)轉(zhuǎn) 移到了目標(biāo)平臺(tái)。
使用備份集執(zhí)行跨平臺(tái)數(shù)據(jù)庫傳輸?shù)南葲Q條件
在為了跨平臺(tái)傳輸數(shù)據(jù)庫而創(chuàng)建跨平臺(tái)備份之前需要滿足以下條件:
. 源數(shù)據(jù)庫與目標(biāo)數(shù)據(jù)庫的 spfile 文件中的 compatible 參數(shù)必須設(shè)置為 12.0.0 或更高的版本。
. 源數(shù)據(jù)庫必須是 read-only 模式打開。
.dbms_tdb.check_db 過程必須成功運(yùn)行。
. 源平臺(tái)與目標(biāo)平臺(tái)必須有相同的字節(jié)序。
下面的例子將使用備份集執(zhí)行跨平臺(tái)傳輸數(shù)據(jù)庫,源平臺(tái)為 Linux 64 位,目標(biāo)平臺(tái)為 windows 64 位其具體操作如下
1. 在目標(biāo)平臺(tái)上創(chuàng)建數(shù)據(jù)庫實(shí)例 jy
設(shè)置環(huán)境變量 ORACLE_SID
C:\Users\Administrator set ORACLE_SID=jy
創(chuàng)建實(shí)例
C:\Users\Administrator oradim -new -sid jy -startmode m
輸入 Oracle 服務(wù)用戶的口令:
實(shí)例已創(chuàng)建。
創(chuàng)建 Oracle 口令文件
C:\Users\Administrator orapwd file=D:\app\oracle\product\12.2.0\dbhome_1\database\pwdjy.ora password=xxzx$7817600 sysbackup=xxzx$7817600
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = jy)
(ORACLE_HOME =D:\app\oracle\product\12.2.0\dbhome_1)
(GLOBAL_DBNAME=jy)
)
)
在 tnsnames.ora 文件中增加以下內(nèi)容
JY =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = WIN-ROUOJ6ERFO3)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jy)
(UR = A)
)
)
2. 利用源數(shù)據(jù)庫的 spfile 文件來為目標(biāo)數(shù)據(jù)庫創(chuàng)建 spfile 文件
SQL create pfile= $ORACLE_HOME/dbs/inityyl.ora from spfile;
File created.
將上面生成的 inityyl.ora 文件復(fù)制到目標(biāo)平臺(tái) D:\app\oracle\product\12.2.0\dbhome_1\database 目錄下并將其內(nèi)容修改成如下所示
*.audit_file_dest= D:\app\oracle\admin\jy\adump
*.cluster_database=false
*.compatible= 12.2.0
*.control_files= D:\APP\ORACLE\ORADATA\JY\CONTROLFILE\control01.ctl
*.db_block_size=8192
*.db_create_file_dest= D:\app\oracle\oradata\
*.db_name= jy
*.diagnostic_dest= D:\app\oracle\
*.dispatchers= (PROTOCOL=TCP) (SERVICE=jyXDB)
*.enable_pluggable_database=true
jy2.instance_number=2
jy1.instance_number=1
*.log_archive_dest_1= location=D:\app\oracle\oradata\arch\jy
*.nls_language= AMERICAN
*.nls_territory= AMERICA
*.open_cursors=300
*.pga_aggregate_target=1g
*.processes=2000
*.remote_login_passwordfile= exclusive
*.sga_max_size=2147483648
*.sga_target=2147483648
jy2.thread=2
jy1.thread=1
*.undo_retention=8640
jy1.undo_tablespace= UNDOTBS1
jy2.undo_tablespace= UNDOTBS2
3. 在目標(biāo)平臺(tái)上啟動(dòng)實(shí)例 jy
C:\Users\Administrator sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on 星期四 2 月 1 01:23:54 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
已連接到空閑例程。
Total System Global Area 2147483648 bytes
Fixed Size 8920984 bytes
Variable Size 1392509032 bytes
Database Buffers 738197504 bytes
Redo Buffers 7856128 bytes
創(chuàng)建 spfile 參數(shù)文件并重啟實(shí)例到 nomount 狀態(tài)
SQL create spfile from pfile= D:\app\oracle\product\12.2.0\dbhome_1\database\initjy.ora
文件已創(chuàng)建。SQL shutdown immediate
ORA-01507: ??????
Total System Global Area 2147483648 bytes
Fixed Size 8920984 bytes
Variable Size 1392509032 bytes
Database Buffers 738197504 bytes
Redo Buffers 7856128 bytes
SQL show parameter spfile
NAME TYPE VALUE
------------------------------------ ---------------------- -----------------------------------------------------------
spfile string D:\APP\ORACLE\PRODUCT\12.2.0\DBHOME_1\DATABASE\SPFILEJY.ORA
測(cè)試 tns 連接實(shí)例 jy 是否能夠成功
C:\Users\Administrator sqlplus /nolog
SQL*Plus: Release 12.2.0.1.0 Production on 星期四 2 月 1 18:01:52 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
SQL conn sys/abcd@jy as sysdba
已連接。
4. 使用有 sysdba 權(quán)限的用戶通過 SQL*Plus 連接到源數(shù)據(jù)庫,并查詢 v$transportable_platform 來查詢目標(biāo)平臺(tái)的名字,因?yàn)閭鬏斦麄€(gè)數(shù)據(jù)庫源平臺(tái)與目標(biāo)平臺(tái)的字節(jié)序應(yīng)該相同。
[oracle@jytest1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Thu Feb 1 18:06:37 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL set long 200
SQL set linesize 200
SQL select platform_name,endian_format from v$transportable_platform;
PLATFORM_NAME ENDIAN_FORMAT
----------------------------------------------------------------------------------------------------- --------------
Solaris[tm] OE (32-bit) Big
Solaris[tm] OE (64-bit) Big
Microsoft Windows IA (32-bit) Little
Linux IA (32-bit) Little
AIX-Based Systems (64-bit) Big
HP-UX (64-bit) Big
HP Tru64 UNIX Little
HP-UX IA (64-bit) Big
Linux IA (64-bit) Little
HP Open VMS Little
Microsoft Windows IA (64-bit) Little
IBM zSeries Based Linux Big
Linux x86 64-bit Little
Apple Mac OS Big
Microsoft Windows x86 64-bit Little
Solaris Operating System (x86) Little
IBM Power Based Linux Big
HP IA Open VMS Little
Solaris Operating System (x86-64) Little
Apple Mac OS (x86-64) Little
20 rows selected.
我這里源平臺(tái)為 Linux x86 64-bit, 目標(biāo)平臺(tái)為 Microsoft Windows IA (64-bit), 兩個(gè)平臺(tái)的字節(jié)序都是 Little
5. 給 RMAN 備份輸出文件選擇命名方法
使用 backup 命令的 format 子句來為備份輸出文件選擇輸出方法。比如使用 format 子句來為備份輸出文件指定存儲(chǔ)目錄 /ora_backup/tdb 并且為每個(gè)文件生成以 transport_為前綴的唯一文件名。FORMAT /ora_backup/tdb/transport_%U
6. 啟動(dòng) RMAN 連接到源數(shù)據(jù)庫 (整個(gè) RAC CDB) 并將重啟源數(shù)據(jù)庫并以只讀方式打開。
[oracle@jytest1 tdb]$ rman target sys/abcd0@jy catalog rco/abcd@jypdb_173
Recovery Manager: Release 12.2.0.1.0 - Production on Thu Feb 1 18:37:04 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: JY (DBID=979425723)
connected to recovery catalog database
RMAN shutdown immediate
starting full resync of recovery catalog
full resync complete
database closed
database dismounted
Oracle instance shut down
RMAN startup mount
connected to target database: JY (DBID=979425723)
database is already started
starting full resync of recovery catalog
full resync complete
RMAN alter database open read only;
starting full resync of recovery catalog
full resync complete
Statement processed
7. 在 backup 命令中使用 for transport 或 to platform 子句來備份源數(shù)據(jù)庫。下面的例子對(duì)整個(gè)數(shù)據(jù)庫創(chuàng)建跨平臺(tái)傳輸備份。備份可以被還原到任何與源平臺(tái)有相同字節(jié)序的平臺(tái)。這里源平臺(tái)為 Linux x86 64-bit,因?yàn)槭褂昧?for transport 子句,那么對(duì)整個(gè)數(shù)據(jù)庫的轉(zhuǎn)換操作將在目標(biāo)平臺(tái)上執(zhí)行。跨平臺(tái)數(shù)據(jù)庫備份被存儲(chǔ)在 /ora_backup/tdb 目錄中。
RMAN backup for transport format /ora_backup/tdb/db_transport_%U database;
Starting backup at 01-FEB-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=+DATA/JY/DATAFILE/sysaux.298.962209605
input datafile file number=00009 name=+DATA/JY/DATAFILE/undotbs2.312.962209605
input datafile file number=00004 name=+DATA/JY/DATAFILE/undotbs1.277.962209605
input datafile file number=00001 name=+DATA/JY/DATAFILE/system.317.962209603
input datafile file number=00007 name=+DATA/JY/DATAFILE/users.301.962209605
channel ORA_DISK_1: starting piece 1 at 01-FEB-18
channel ORA_DISK_1: finished piece 1 at 01-FEB-18
piece handle=/ora_backup/tdb/db_transport_7ssq5l1i_1_1 tag=TAG20180201T192745 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:05
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00014 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649
input datafile file number=00011 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649
input datafile file number=00013 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649
input datafile file number=00010 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649
input datafile file number=00012 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649
input datafile file number=00015 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609
input datafile file number=00022 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/tts.257.966380353
input datafile file number=00023 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/cs.294.966380783
channel ORA_DISK_1: starting piece 1 at 01-FEB-18
channel ORA_DISK_1: finished piece 1 at 01-FEB-18
piece handle=/ora_backup/tdb/db_transport_7tsq5l5g_1_1 tag=TAG20180201T192745 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00017 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
input datafile file number=00016 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
input datafile file number=00018 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
input datafile file number=00019 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
input datafile file number=00021 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409
input datafile file number=00020 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
channel ORA_DISK_1: starting piece 1 at 01-FEB-18
channel ORA_DISK_1: finished piece 1 at 01-FEB-18
piece handle=/ora_backup/tdb/db_transport_7usq5l8p_1_1 tag=TAG20180201T192745 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.270.962209675
input datafile file number=00005 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/system.256.962209675
input datafile file number=00008 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.296.962209675
channel ORA_DISK_1: starting piece 1 at 01-FEB-18
channel ORA_DISK_1: finished piece 1 at 01-FEB-18
piece handle=/ora_backup/tdb/db_transport_7vsq5lbf_1_1 tag=TAG20180201T192745 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
Finished backup at 01-FEB-18
total 5532808
-rw-r----- 1 oracle asmadmin 3146178560 Feb 1 13:27 db_transport_7ssq5l1i_1_1
-rw-r----- 1 oracle asmadmin 990789632 Feb 1 13:29 db_transport_7tsq5l5g_1_1
-rw-r----- 1 oracle asmadmin 988348416 Feb 1 13:30 db_transport_7usq5l8p_1_1
-rw-r----- 1 oracle asmadmin 540270592 Feb 1 13:31 db_transport_7vsq5lbf_1_1
備份源數(shù)據(jù)庫的控制文件到跨蹤文件中用于在目標(biāo)平臺(tái)為目標(biāo)數(shù)據(jù)庫重新創(chuàng)建控制文件
SQL alter session set tracefile_identifier= create
Session altered.
SQL alter database backup controlfile to trace resetlogs;
Database altered.
[root@jytest1 /]# find / -name *create*.trc
/u01/app/oracle/diag/rdbms/jy/jy1/trace/jy1_ora_22752_create.trc
[root@jytest1 /]# cat /u01/app/oracle/diag/rdbms/jy/jy1/trace/jy1_ora_22752_create.trc
Trace file /u01/app/oracle/diag/rdbms/jy/jy1/trace/jy1_ora_22752_create.trc
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Build label: RDBMS_12.2.0.1.0_LINUX.X64_170125
ORACLE_HOME: /u01/app/oracle/product/12.2.0/db
System name: Linux
Node name: jytest1.jydba.net
Release: 3.8.13-55.1.6.el7uek.x86_64
Version: #2 SMP Wed Feb 11 14:18:22 PST 2015
Machine: x86_64
Instance name: jy1
Redo thread mounted by this instance: 1
Oracle process number: 40
Unix process pid: 22752, image: oracle@jytest1.jydba.net (TNS V1-V3)