Oracle 11gR2 使用 RMAN duplicate from active database 複製資料庫
在Oracle 10g下,我們可以使用RMAN duplicate 命令建立一個具有不同DBID 的複製庫。 到了Oracle 11gR2, RMAN 的duplicate 有2種方法實現:
1. Active database duplication
2. Backup-based duplication
Active database duplication 透過網路,直接copy target 庫到auxiliary 庫,然後建立複製庫。 這種方法就不需要先用RMAN 備份資料庫,然後將備份檔案傳送到auxiliary端。
這個功能的作用是非常大的。 尤其是對T級別的庫。 因為對這樣的庫進行備份,然後將備份集傳送到備庫,在進行duplicate 的代價是非常大的。 一備份要佔用時間,二要佔用備份空間,三在網路傳送的時候,還需要佔用頻寬和時間。所以Active database duplicate 很好的解決了以上的問題。 它對大庫的遷移非常有用。
如果是從RAC duplicate 到單例項,操作是一樣的。 如果是從單例項duplicate 到RAC。 那麼先duplicate 到 單例項。 然後將單例項轉換成RAC。
Oracle 10g 下Rman duplicate 的例子參考:
RMAN 異機 複製資料庫
http://blog.csdn.net/tianlesoftware/archive/2010/07/20/5749932.aspx
下面我們看一下11gR2下,Active Database Duplicate的步驟如下:
1. 建立Auxiliary 庫的Initialization Parameter:
如果使用spfile,那麼在pfile檔案裡只需要設定一個DB_NAME引數,其他引數會在duplicate 命令中自己設定。
如果使用pfile,那麼需要設定如下引數:
DB_NAME
CONTROL_FILES
DB_BLOCK_SIZE
DB_FILE_NAME_CONVERT
LOG_FILE_NAME_CONVERT
DB_RECOVERY_FILE_DEST
2. 在Auxiliary庫建立Password File 檔案
對於Backup-based duplication,Password File 不是必須的,但是對於Active Database Duplication,Password File是必須的。 因為Active Database Duplication 使用相同的SYSDBA 密碼直接連線到auxiliary 庫。 所以,確保target 和Auxiliary庫的SYSDBA 密碼一樣很重要。
當然,我們也可以在duplicate 命令中加上PASSWORD FILE 選項(也是預設值), 這樣RMAN 在copy 的時候也會從target 庫把密碼檔案copy過來,如果auxiliary庫上已經存在了Password file,那麼該操作會重寫那個檔案。
如:
RMAN> DUPLICATE TARGET DATABASE TO Dave
2> FROM ACTIVE DATABASE
3> NOFILENAMECHECK
4> PASSWORD FILE
5> SPFILE;
3. 如果是windows 平臺,還需要建立Database service:
% set ORACLE_SID=DAVE
% set ORACLE_HOME=E:/oracle/product/11.1.0/db_1
% oradim -NEW -SID DAVE
4. 配置oracle net,修改listener.ora和the tnsnames.ora 檔案:
在Target 庫和Auxiliary 都要修改。這個也可以使用netca 和netmgr命令配置。
Listener.ora
[oracle@qs-dmm-rh1 admin]$ cat listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost6.localdomain6)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
tnsname.ora
[oracle@qs-dmm-rh1 admin]$ cat tnsnames.ora
ORCL_ST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.43)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL_PD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.42)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
5. 用第一步建立的pfile檔案,將Auxiliary啟動到nomout 狀態。 然後進行Active Database duplicate。
我們看一個完整的複製示例:
Target DB:
IP: 192.168.2.42
SID:orcl
Auxiliary:
IP:192.168.2.43
SID:orcl
我這裡複製的目錄相同。 如果不同的話需要在pfile裡面加入db_file_name_convert和log_file_name_convert.
1. 在Auxiliary 建立pfile 引數檔案:
[oracle@qs-dmm-rh2 dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@qs-dmm-rh2 dbs]$ cat initorcl.ora
DB_NAME=orcl
只有一個引數: DB_NAME
2. 在Auxiliary庫上建立口令檔案
[oracle@qs-dmm-rh2 admin]$ orapwd file=?/dbs/orapworcl password=oracle
3. 在Auxiliary庫建立相關的目錄結構:
[oracle@qs-dmm-rh2 trace]$ mkdir -p /u01/app/oracle/oradata/orcl
不然在duplicate時會報如下錯誤:
ORA-19505: failed to identify file "/u01/app/oracle/oradata/orcl/users01.dbf"
ORA-27040: file create error, unable to create file
4. 啟動Auxiliary 到nomout 狀態:
[oracle@qs-dmm-rh2 admin]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 8 00:28:48 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn / as sysdba;
Connected to an idle instance.
SQL> startup nomount pfile=?/dbs/initorcl.ora
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
SQL>
5. 在Target 和Auxiliary 都配置Oracle Net(Listener.ora and tnsnames.ora):
[oracle@qs-dmm-rh1 admin]$ cat listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost6.localdomain6)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = orcl)
)
)
[oracle@qs-dmm-rh1 admin]$ cat tnsnames.ora
ORCL_ST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.43)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL_PD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.42)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
6. 開始RMAN duplicate from active database:
注意:如果target 和 Auxiliary庫的目錄結構相同,記得加上nofilenamecheck引數,不然會報如下錯誤:
RMAN-05001: auxiliary file name /u01/app/oracle/oradata/orcl/users01.dbf conflicts with a file used by the target database
如果目錄不同,在pfile里加如下2個引數進行轉換:
db_file_name_convert
log_file_name_convert.
[oracle@qs-dmm-rh2 dbs]$ rman target sys/oracle@orcl_pd auxiliary sys/oracle@orcl_st
Recovery Manager: Release 11.2.0.1.0 - Production on Tue Mar 8 01:01:42 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1272955137)
connected to auxiliary database: ORCL (not mounted)
RMAN> duplicate target database to orcl from active database nofilenamecheck;
Starting Duplicate Db at 08-MAR-11
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK
contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''ORCL'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''ORCL'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/cntrlorcl.dbf';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
Starting backup at 08-MAR-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=43 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_orcl.f tag=TAG20110308T010214 RECID=3 STAMP=745203735
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 08-MAR-11
database mounted
contents of Memory Script:
{
set newname for datafile 1 to
"/u01/app/oracle/oradata/orcl/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/orcl/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/orcl/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/orcl/users01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/u01/app/oracle/oradata/orcl/system01.dbf" datafile
2 auxiliary format
"/u01/app/oracle/oradata/orcl/sysaux01.dbf" datafile
3 auxiliary format
"/u01/app/oracle/oradata/orcl/undotbs01.dbf" datafile
4 auxiliary format
"/u01/app/oracle/oradata/orcl/users01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 08-MAR-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
--在這裡開始copy 資料檔案,比較慢。
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
output file name=/u01/app/oracle/oradata/orcl/system01.dbf tag=TAG20110308T010221
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
output file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf tag=TAG20110308T010221
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
output file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf tag=TAG20110308T010221
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
output file name=/u01/app/oracle/oradata/orcl/users01.dbf tag=TAG20110308T010221
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 08-MAR-11
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_03_08/o1_mf_1_7_6qb3zyoo_.arc" auxiliary format
"/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_7_745174404.dbf" ;
catalog clone archivelog "/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_7_745174404.dbf";
switch clone datafile all;
}
executing Memory Script
Starting backup at 08-MAR-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=7 RECID=3 STAMP=745203841
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_7_745174404.dbf RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:07
Finished backup at 08-MAR-11
cataloged archived log
archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_7_745174404.dbf RECID=3 STAMP=745203848
datafile 1 switched to datafile copy
input datafile copy RECID=3 STAMP=745203849 file name=/u01/app/oracle/oradata/orcl/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=4 STAMP=745203849 file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=745203849 file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=6 STAMP=745203849 file name=/u01/app/oracle/oradata/orcl/users01.dbf
contents of Memory Script:
{
set until scn 844147;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 08-MAR-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK
starting media recovery
archived log for thread 1 with sequence 7 is already on disk as file /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_7_745174404.dbf
archived log file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_7_745174404.dbf thread=1 sequence=7
media recovery complete, elapsed time: 00:00:01
Finished recover at 08-MAR-11
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''ORCL'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
sql statement: alter system set db_name = ''ORCL'' comment= ''Reset to original value by RMAN'' scope=spfile
sql statement: alter system reset db_unique_name scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 146472960 bytes
Fixed Size 1335080 bytes
Variable Size 92274904 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/orcl/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/orcl/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/orcl/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u01/app/oracle/oradata/orcl/system01.dbf'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/orcl/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/sysaux01.dbf",
"/u01/app/oracle/oradata/orcl/undotbs01.dbf",
"/u01/app/oracle/oradata/orcl/users01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/orcl/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf RECID=1 STAMP=745203867
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf RECID=2 STAMP=745203867
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/orcl/users01.dbf RECID=3 STAMP=745203867
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=745203867 file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=745203867 file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=745203867 file name=/u01/app/oracle/oradata/orcl/users01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 08-MAR-11
RMAN>
複製結束。 查詢:
Target 庫:
SQL> select name,dbid from v$database;
NAME DBID
--------- ----------
ORCL 1272955137
Auxiliary庫:
SQL> select name,dbid from v$database;
NAME DBID
--------- ----------
ORCL 1272984602
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25462274/viewspace-2147038/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- RMAN duplicate from active database 複製資料庫Database資料庫
- oracle 11g duplicate from active database 複製資料庫(四)OracleDatabase資料庫
- oracle 11g duplicate from active database 複製資料庫(三)OracleDatabase資料庫
- oracle 11g duplicate from active database 複製資料庫(二)OracleDatabase資料庫
- oracle 11g duplicate from active database 複製資料庫(一)OracleDatabase資料庫
- 使用RMAN複製資料庫 active database資料庫Database
- Oracle 11gR2 使用RMAN Duplicate複製資料庫Oracle資料庫
- Oracle11g RMAN Duplicate from Active DatabaseOracleDatabase
- oracle 11gr2 活動資料庫複製(active database duplication)Oracle資料庫Database
- 使用 RMAN DUPLICATE...FROM ACTIVE DATABASE 建立物理備用資料庫的分步指南Database資料庫
- 使用RMAN DUPLICATE...FROM ACTIVE DATABASE命令來建立DataGuard物理備庫Database
- 【RMAN】使用duplicate本地複製資料庫資料庫
- 【RMAN】使用RMAN duplicate複製同機資料庫資料庫
- 使用rman的命令duplicate複製資料庫資料庫
- Oracle11gR2使用RMAN duplicate複製資料庫Oracle資料庫
- Oracle 11g Data Guard 使用duplicate from active databaseOracleDatabase
- 11g rman新特性 duplicate target database for standby from active databaseDatabase
- Oracle 11g Rman Active database duplicateOracleDatabase
- 11g RMAN新特性 active database duplication 複製資料庫Database資料庫
- Oracle 11g Data Guard 使用 duplicate from active database 建立 standby databaseOracleDatabase
- Oracle 11g Data Guard 使用duplicate from active database 建立 standby databaseOracleDatabase
- duplicate rman複製資料庫技術資料庫
- Creating a Physical Standby using RMAN DUPLICATE FROM ACTIVE DATABASEDatabase
- 使用RMAN高階應用之Duplicate複製資料庫資料庫
- 11g RMAN新特性active database duplicate 資料庫異構Database資料庫
- Rman duplicate資料庫複製(單系統)資料庫
- 【RMAN】使用RMAN duplicate複製同機資料庫遇到的問題資料庫
- Oracle 之 Duplicate 複製資料庫Oracle資料庫
- 使用oracle 11g rman新特性 duplicate target database for standby from active database 建立物理dataguard並開啟RealOracleDatabase
- oracle rman複製資料庫Oracle資料庫
- RMAN高階應用之Duplicate複製資料庫(3)複製流程資料庫
- 使用RMAN複製資料庫資料庫
- oracle 11g duplicate database基於備份複製資料庫(六)OracleDatabase資料庫
- oracle 11g duplicate database基於備份複製資料庫(五)OracleDatabase資料庫
- oracle 11g duplicate database基於備份複製資料庫(四)OracleDatabase資料庫
- oracle 11g duplicate database基於備份複製資料庫(三)OracleDatabase資料庫
- oracle 11g duplicate database基於備份複製資料庫(二)OracleDatabase資料庫
- oracle 11g duplicate database基於備份複製資料庫(一)OracleDatabase資料庫