RAC 例項 遷移到 單例項 -- 使用RMAN Duplicate
測試環境: Oracle 10gR2 RAC + Redhat 5.4 +ASM + RAW
源庫:
db_name=orcl SID=orcc1/orcl2
IP: 192.168.6.223/224
目標庫:
db_name=orcl SID=orcl
IP:192.168.6.229
操作過程和RMAN 的異機複製有點類似。 區別在引數檔案的處理上。
RMAN 異機 複製資料庫
http://blog.csdn.net/tianlesoftware/archive/2010/07/20/5749932.aspx
一. 目標庫的準備
1. 安裝redhat 5.4 作業系統
2. 安裝Oracle 軟體, 這裡只安裝軟體,不建立例項。
參考:linux平臺下oracle資料庫安裝
http://blog.csdn.net/tianlesoftware/archive/2009/10/24/4718218.aspx
3. 建立相關目錄
[oracle@singledb ~]$ mkdir -p /u01/app/oracle/admin/orcl/cdump
[oracle@singledb ~]$ mkdir -p /u01/app/oracle/admin/orcl/bdump
[oracle@singledb ~]$ mkdir -p /u01/app/oracle/admin/orcl/adump
[oracle@singledb ~]$ mkdir -p /u01/app/oracle/admin/orcl/udump
[oracle@singledb ~]$ mkdir -p /u01/app/oracle/admin/orcl/cdump
[oracle@singledb ~]$ mkdir -p /u01/app/oracle/flash_recovery_area/
[oracle@singledb ~]$ mkdir -p /u01/app/oracle/oradata/orcl/
二. 源庫操作
1. 建立pfile檔案
SQL> create pfile from spfile;
File created.
2. 將建立的pfile檔案傳到目標資料庫的$ORACLE_HOME/dbs/ 目錄下
[oracle@racdb1 ~]$ cd /u01/app/oracle/product/10.2.0/db_1/dbs/
[oracle@racdb1 dbs]$ ls
ab_+ASM1.dat hc_orcl1.dat initdw.ora initorcl1.ora orapworcl1
hc_+ASM1.dat init+ASM1.ora init.ora orapw+ASM1
[oracle@racdb1 dbs]$ scp initorcl1.ora 192.168.6.229:/u01/app/oracle/product/10.2.0/db_1/dbs/
The authenticity of host '192.168.6.229 (192.168.6.229)' can't be established.
RSA key fingerprint is 2a:5a:fb:63:ca:64:75:68:86:f8:43:b3:0b:80:0e:7c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.6.229' (RSA) to the list of known hosts.
oracle@192.168.6.229's password:
initorcl1.ora 100% 1468 1.4KB/s 00:00
確認一下:
[oracle@singledb dbs]$ pwd
/u01/app/oracle/product/10.2.0/db_1/dbs
[oracle@singledb dbs]$ ls
initdw.ora init.ora initorcl1.ora
3. 監聽配置
在源庫的的tnsnames.ora 檔案裡新增如下內容:
targetorcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.229)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
4. 備份源庫,並將備份檔案傳到目標庫的相同位置。 備份目錄必須相同。
先建立備份目錄
[root@racdb1 ~]# mkdir -p /u02/backup
[root@racdb1 ~]# chown -R oracle:oinstall /u02
[root@racdb1 ~]# chmod 777 /u02
用RMAN 全備資料庫:
[oracle@racdb1 ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Sun Dec 5 18:00:02 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1264379992)
RMAN> RUN {
allocate channel c1 type disk;
allocate channel c2 type disk;
BACKUP FORMAT '/u02/backup/orcl_%U_%T' skip inaccessible filesperset 5 DATABASE TAG orcl_hot_db_bk;
sql 'alter system archive log current';
BACKUP FORMAT '/u02/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT;
backup current controlfile tag='bak_ctlfile' format='/u02/backup/ctl_file_%U_%T';
backup spfile tag='spfile' format='/u02/backup/ORCL_spfile_%U_%T';
release channel c2;
release channel c1;
}
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=124 instance=orcl1 devtype=DISK
allocated channel: c2
channel c2: sid=146 instance=orcl1 devtype=DISK
Starting backup at 05-DEC-10
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=+DATA/orcl/datafile/system.256.736598559
input datafile fno=00004 name=+DATA/orcl/datafile/users.259.736598641
channel c1: starting piece 1 at 05-DEC-10
channel c2: starting full datafile backupset
channel c2: specifying datafile(s) in backupset
input datafile fno=00003 name=+DATA/orcl/datafile/sysaux.257.736598563
input datafile fno=00002 name=+DATA/orcl/datafile/undotbs1.258.736598599
input datafile fno=00005 name=+DATA/orcl/datafile/undotbs2.264.736599805
channel c2: starting piece 1 at 05-DEC-10
channel c2: finished piece 1 at 05-DEC-10
piece handle=/u02/backup/orcl_04luqhqp_1_1_20101205 tag=ORCL_HOT_DB_BK comment=NONE
channel c2: backup set complete, elapsed time: 00:08:21
channel c2: starting full datafile backupset
channel c2: specifying datafile(s) in backupset
including current control file in backupset
channel c2: starting piece 1 at 05-DEC-10
channel c1: finished piece 1 at 05-DEC-10
piece handle=/u02/backup/orcl_03luqhqp_1_1_20101205 tag=ORCL_HOT_DB_BK comment=NONE
channel c1: backup set complete, elapsed time: 00:09:37
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel c1: starting piece 1 at 05-DEC-10
channel c2: finished piece 1 at 05-DEC-10
piece handle=/u02/backup/orcl_05luqiaq_1_1_20101205 tag=ORCL_HOT_DB_BK comment=NONE
channel c2: backup set complete, elapsed time: 00:01:09
channel c1: finished piece 1 at 05-DEC-10
piece handle=/u02/backup/orcl_06luqicu_1_1_20101205 tag=ORCL_HOT_DB_BK comment=NONE
channel c1: backup set complete, elapsed time: 00:00:02
Finished backup at 05-DEC-10
sql statement: alter system archive log current
Starting backup at 05-DEC-10
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=3 recid=4 stamp=736718437
input archive log thread=1 sequence=4 recid=6 stamp=736752948
input archive log thread=1 sequence=5 recid=7 stamp=736772474
input archive log thread=1 sequence=6 recid=9 stamp=736893879
input archive log thread=1 sequence=7 recid=12 stamp=736944911
channel c1: starting piece 1 at 05-DEC-10
channel c2: starting archive log backupset
channel c2: specifying archive log(s) in backup set
input archive log thread=1 sequence=2 recid=3 stamp=736718159
channel c2: starting piece 1 at 05-DEC-10
channel c1: finished piece 1 at 05-DEC-10
piece handle=/u02/backup/arch_07luqif5_1_1_20101205 tag=TAG20101205T181350 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:59
channel c1: deleting archive log(s)
archive log filename=+FRA/archivelog/orcl/1_3_736599263.dbf recid=4 stamp=736718437
archive log filename=+FRA/archivelog/orcl/1_4_736599263.dbf recid=6 stamp=736752948
archive log filename=+FRA/archivelog/orcl/1_5_736599263.dbf recid=7 stamp=736772474
archive log filename=+FRA/archivelog/orcl/1_6_736599263.dbf recid=9 stamp=736893879
archive log filename=+FRA/archivelog/orcl/1_7_736599263.dbf recid=12 stamp=736944911
channel c2: finished piece 1 at 05-DEC-10
piece handle=/u02/backup/arch_08luqif6_1_1_20101205 tag=TAG20101205T181350 comment=NONE
channel c2: backup set complete, elapsed time: 00:01:01
channel c2: deleting archive log(s)
archive log filename=+FRA/archivelog/orcl/1_2_736599263.dbf recid=3 stamp=736718159
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=2 sequence=3 recid=5 stamp=736752401
input archive log thread=2 sequence=4 recid=8 stamp=736772568
input archive log thread=2 sequence=5 recid=10 stamp=736893888
input archive log thread=2 sequence=6 recid=11 stamp=736944342
input archive log thread=2 sequence=7 recid=14 stamp=736968019
channel c1: starting piece 1 at 05-DEC-10
channel c2: starting archive log backupset
channel c2: specifying archive log(s) in backup set
input archive log thread=1 sequence=8 recid=13 stamp=736968002
input archive log thread=1 sequence=9 recid=15 stamp=736971214
input archive log thread=1 sequence=10 recid=18 stamp=736971229
input archive log thread=2 sequence=1 recid=1 stamp=736717965
input archive log thread=2 sequence=2 recid=2 stamp=736718031
channel c2: starting piece 1 at 05-DEC-10
channel c1: finished piece 1 at 05-DEC-10
piece handle=/u02/backup/arch_09luqih3_1_1_20101205 tag=TAG20101205T181350 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:30
channel c1: deleting archive log(s)
archive log filename=+FRA/archivelog/orcl/2_3_736599263.dbf recid=5 stamp=736752401
archive log filename=+FRA/archivelog/orcl/2_4_736599263.dbf recid=8 stamp=736772568
archive log filename=+FRA/archivelog/orcl/2_5_736599263.dbf recid=10 stamp=736893888
archive log filename=+FRA/archivelog/orcl/2_6_736599263.dbf recid=11 stamp=736944342
archive log filename=+FRA/archivelog/orcl/2_7_736599263.dbf recid=14 stamp=736968019
channel c2: finished piece 1 at 05-DEC-10
piece handle=/u02/backup/arch_0aluqih5_1_1_20101205 tag=TAG20101205T181350 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:31
channel c2: deleting archive log(s)
archive log filename=+FRA/archivelog/orcl/1_8_736599263.dbf recid=13 stamp=736968002
archive log filename=+FRA/archivelog/orcl/1_9_736599263.dbf recid=15 stamp=736971214
archive log filename=+FRA/archivelog/orcl/1_10_736599263.dbf recid=18 stamp=736971229
archive log filename=+FRA/archivelog/orcl/2_1_736599263.dbf recid=1 stamp=736717965
archive log filename=+FRA/archivelog/orcl/2_2_736599263.dbf recid=2 stamp=736718031
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=2 sequence=8 recid=16 stamp=736971215
input archive log thread=2 sequence=9 recid=17 stamp=736971223
channel c1: starting piece 1 at 05-DEC-10
channel c1: finished piece 1 at 05-DEC-10
piece handle=/u02/backup/arch_0bluqii4_1_1_20101205 tag=TAG20101205T181350 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:04
channel c1: deleting archive log(s)
archive log filename=+FRA/archivelog/orcl/2_8_736599263.dbf recid=16 stamp=736971215
archive log filename=+FRA/archivelog/orcl/2_9_736599263.dbf recid=17 stamp=736971223
Finished backup at 05-DEC-10
Starting backup at 05-DEC-10
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
including current control file in backupset
channel c1: starting piece 1 at 05-DEC-10
channel c1: finished piece 1 at 05-DEC-10
piece handle=/u02/backup/ctl_file_0cluqil1_1_1_20101205 tag=BAK_CTLFILE comment=NONE
channel c1: backup set complete, elapsed time: 00:00:37
Finished backup at 05-DEC-10
Starting backup at 05-DEC-10
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel c1: starting piece 1 at 05-DEC-10
channel c1: finished piece 1 at 05-DEC-10
piece handle=/u02/backup/ORCL_spfile_0dluqimo_1_1_20101205 tag=SPFILE comment=NONE
channel c1: backup set complete, elapsed time: 00:00:08
Finished backup at 05-DEC-10
released channel: c2
released channel: c1
這裡要注意, 我是把歸檔檔案放在了ASM裡,所以可以這樣備份,如果不是這麼放的,可能需要其他配置,具體參考:
RAC 之 RMAN 備份
http://blog.csdn.net/tianlesoftware/archive/2010/09/22/5901053.aspx
Linux 平臺下 RMAN 全備 和 增量備份 shell 指令碼
http://blog.csdn.net/tianlesoftware/archive/2010/07/16/5740630.aspx
三. 目標庫操作
1. 建立目標庫ORCL 的口令檔案
[oracle@singledb dbs]$ cd $ORACLE_HOME/bin
[oracle@singledb bin]$ orapwd file=$ORACLE_HOME/dbs/orapworcl password=admin
[oracle@singledb bin]$ cd $ORACLE_HOME/dbs
[oracle@singledb dbs]$ ls
initdw.ora init.ora initorcl1.ora orapworcl
windows下oracle預設的位置是$ORACLE_HOME/database目錄,檔名格式是pwdSID.ora。
linux下oracle預設的位置是$ORACLE_HOME/dbs目錄,檔名格式是orapwSID。
建立完後,資料庫需要重啟動,新的口令檔案才能生效。
關於口令檔案建立,詳細內容參考blog:
Oracle OS認證 口令檔案 密碼丟失處理
http://blog.csdn.net/tianlesoftware/archive/2009/10/20/4698293.aspx
2. 建立備份目錄
[root@singledb Server]# mkdir -p /u02/backup
[root@singledb Server]# chown -R oracle:oinstall /u02
[root@singledb Server]# chmod 777 /u02
3. 配置監聽
3.1 建立listener.ora 檔案中,並新增如下內容
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = orcl)
)
)
3.2 建立tnsnames.ora 檔案,並新增如下內容
sourceorcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.223)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
(INSTANCE_NAME = orcl1)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
建議使用net manager 工具從介面來修改,這樣不容易出錯:
Oracle 資料庫監聽配置
http://blog.csdn.net/tianlesoftware/archive/2009/11/25/4861572.aspx
Oracle Listener 動態註冊 與 靜態註冊
http://blog.csdn.net/tianlesoftware/archive/2010/04/30/5543166.aspx
4. 修改引數檔案
之前已經將引數檔案傳了過來。 我們先對引數檔案重新命名。
[oracle@singledb dbs]$ mv initorcl1.ora initorcl.ora -- 改成orcl
[oracle@singledb dbs]$ cat initorcl.ora
orcl2.__db_cache_size=117440512
orcl1.__db_cache_size=54525952
orcl1.__java_pool_size=4194304
orcl2.__java_pool_size=4194304
orcl1.__large_pool_size=4194304
orcl2.__large_pool_size=4194304
orcl2.__shared_pool_size=92274688
orcl1.__shared_pool_size=155189248
orcl1.__streams_pool_size=0
orcl2.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.background_dump_dest='/u01/app/oracle/admin/orcl/bdump'
*.cluster_database_instances=2
*.cluster_database=true
*.compatible='10.2.0.1.0'
*.control_files='+DATA/orcl/controlfile/current.260.736599257','+FRA/orcl/controlfile/current.256.736599259'
*.core_dump_dest='/u01/app/oracle/admin/orcl/cdump'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl'
*.db_recovery_file_dest='+FRA'
*.db_recovery_file_dest_size=3040870400
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
orcl1.instance_number=1
orcl2.instance_number=2
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=+FRA/archivelog/orcl/'
*.log_archive_format='%t_%s_%r.dbf'
*.nls_language='SIMPLIFIED CHINESE'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=73400320
*.processes=150
*.remote_listener='LISTENERS_ORCL'
*.remote_login_passwordfile='exclusive'
*.sga_target=221249536
orcl2.thread=2
orcl1.thread=1
*.undo_management='AUTO'
orcl2.undo_tablespace='UNDOTBS2'
orcl1.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/orcl/udump'
[oracle@singledb dbs]$
紅色部分就是我們需要刪除或者修改的。
修改之後的pfile 檔案如下:
[oracle@singledb dbs]$ cat initorcl.ora
*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.background_dump_dest='/u01/app/oracle/admin/orcl/bdump'
*.cluster_database=false
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/oradata/orcl/control02.ctl','/u01/app/oracle/oradata/orcl/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/orcl/cdump'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata/orcl/'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area/'
*.db_recovery_file_dest_size=2147483648
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/u01/archivelog/'
*.log_archive_format='%t_%s_%r.arch'
*.open_cursors=300
*.pga_aggregate_target=150229440
*.processes=150
*.remote_login_passwordfile='exclusive'
*.sga_target=359785472
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/orcl/udump'
*.log_file_name_convert=('+DATA/orcl/onlinelog','/u01/app/oracle/oradata/orcl')
*.log_file_name_convert=('+FRA/orcl/onlinelog','/u01/app/oracle/oradata/orcl')
*.db_file_name_convert=('+DATA/orcl/datafile','/u01/app/oracle/oradata/orcl')
*.db_file_name_convert=('+DATA/orcl/tempfile','/u01/app/oracle/oradata/orcl')
注意最後兩行,因為RAC的目錄結構和我們的單例項不一樣,所以我們這裡進行轉換一下。 這裡面要根據自己的情況來決定。 比如我將redo 放到了FRA了。所以在這裡也需要進行轉換。
這裡可以根據RMAN duplicate的命令進行判斷:
RMAN> duplicate target database to orcl;
..
RMAN-05001: auxiliary filename +FRA/orcl/onlinelog/group_2.258.736599295 conflicts with a file used by the target database
這是我測試時遇到的問題。 把FRA也做一下轉換就搞定了。
如果這裡不寫這個引數的話,那麼在RMAN恢復的時候就需要用命令轉換。 如:
SET NEWNAME FOR DATAFILE 1 to '/u01/app/oracle/oradata/orcl/sys01.dbf';
檢視檔案位置:
SQL> select file#,name from v$datafile;
FILE# NAME
---------- ---------------------------------------------------------------------
1 +DATA/orcl/datafile/system.256.736598559
2 +DATA/orcl/datafile/undotbs1.258.736598599
3 +DATA/orcl/datafile/sysaux.257.736598563
4 +DATA/orcl/datafile/users.259.736598641
5 +DATA/orcl/datafile/undotbs2.264.736599805
SQL> select file#,name from v$tempfile;
FILE# NAME
---------- ---------------------------------------------------------------------
1 +DATA/orcl/tempfile/temp.263.73659950
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+DATA/orcl/onlinelog/group_2.262.736599285
+FRA/orcl/onlinelog/group_2.258.736599295
+DATA/orcl/onlinelog/group_1.261.736599263
+FRA/orcl/onlinelog/group_1.257.736599275
+DATA/orcl/onlinelog/group_3.265.736600119
+FRA/orcl/onlinelog/group_3.259.736600137
+DATA/orcl/onlinelog/group_4.266.736600151
+FRA/orcl/onlinelog/group_4.260.736600165
8 rows selected.
5. 用SCP將源庫的備份copy到目標庫
[oracle@singledb admin]$ scp 192.168.6.223:/u02/backup/* /u02/backup
oracle@192.168.6.223's password:
arch_07luqif5_1_1_20101205 100% 56MB 909.4KB/s 01:03
arch_08luqif6_1_1_20101205 100% 50MB 711.1KB/s 01:12
arch_09luqih3_1_1_20101205 100% 43MB 1.3MB/s 00:34
arch_0aluqih5_1_1_20101205 100% 22MB 933.7KB/s 00:24
arch_0bluqii4_1_1_20101205 100% 1341KB 670.3KB/s 00:02
ctl_file_0cluqil1_1_1_20101205 100% 15MB 998.4KB/s 00:15
orcl_03luqhqp_1_1_20101205 100% 354MB 1.3MB/s 04:42
orcl_04luqhqp_1_1_20101205 100% 210MB 2.3MB/s 01:31
orcl_05luqiaq_1_1_20101205 100% 15MB 2.9MB/s 00:05
orcl_06luqicu_1_1_20101205 100% 96KB 96.0KB/s 00:01
ORCL_spfile_0dluqimo_1_1_20101205 100% 96KB 96.0KB/s 00:00
[oracle@singledb admin]$
6. 將目標庫啟動到nomount 狀態,並進行duplicate
6.1 啟動目標庫到nomount狀態
[oracle@singledb dbs]$ export ORACLE_SID=orcl
[oracle@singledb dbs]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 7 18:47:36 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 360710144 bytes
Fixed Size 1219424 bytes
Variable Size 109053088 bytes
Database Buffers 247463936 bytes
Redo Buffers 2973696 bytes
SQL>
6.2 進行duplicate
[oracle@singledb dbs]$ tnsping sourceorcl
TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 07-DEC-2010 18:49:35
Copyright (c) 1997, 2005, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.223)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) (INSTANCE_NAME = orcl1)))
OK (200 msec)
[oracle@singledb dbs]$ rman target sys/h2oiswater@sourceorcl auxiliary /
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Dec 7 18:54:37 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1264379992)
connected to auxiliary database: ORCL (not mounted)
RMAN>duplicate target database to orcl;
-- 這裡要注意, 因為我是將RAC的歸檔檔案放在ASM上的,所以可以這麼寫。 如果歸檔不是這麼放的,就需要手工配置通過。如
run{
allocate channel d1 type disk connect sys/oracle@rac1;
allocate channel d2 type disk connect sys/oracle@rac2;
allocate auxiliary channel d3 type disk;
duplicate target database to orcl;
}
RMAN> duplicate target database to orcl;
Starting Duplicate Db at 07-DEC-10
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK
contents of Memory Script:
{
set until scn 861023;
set newname for datafile 1 to
"/u01/app/oracle/oradata/orcl/system.256.736598559"; -- 在pfile裡設定的引數
set newname for datafile 2 to
"/u01/app/oracle/oradata/orcl/undotbs1.258.736598599";
set newname for datafile 3 to
"/u01/app/oracle/oradata/orcl/sysaux.257.736598563";
set newname for datafile 4 to
"/u01/app/oracle/oradata/orcl/users.259.736598641";
set newname for datafile 5 to
"/u01/app/oracle/oradata/orcl/undotbs2.264.736599805";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 07-DEC-10
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /u01/app/oracle/oradata/orcl/undotbs1.258.736598599
restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux.257.736598563
restoring datafile 00005 to /u01/app/oracle/oradata/orcl/undotbs2.264.736599805
-- 先將資料從備份集中restore 到/u01/app/oracle/oradata/orcl目錄
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/orcl_0fluu1ac_1_1_20101207
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/orcl_0fluu1ac_1_1_20101207 tag=ORCL_HOT_DB_BK
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system.256.736598559
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users.259.736598641
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/orcl_0eluu1aa_1_1_20101207
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/orcl_0eluu1aa_1_1_20101207 tag=ORCL_HOT_DB_BK
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 07-DEC-10
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL"
-- 建立控制檔案
RESETLOGS ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/orcl/group_1.261.736599263', '/u01/app/oracle/oradata/orcl/group_1.257.736599275' ) SIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/orcl/group_2.262.736599285', '/u01/app/oracle/oradata/orcl/group_2.258.736599295' ) SIZE 50 M REUSE
DATAFILE
'/u01/app/oracle/oradata/orcl/system.256.736598559'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
released channel: ORA_AUX_DISK_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=737150574 filename=/u01/app/oracle/oradata/orcl/undotbs1.258.736598599
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=737150574 filename=/u01/app/oracle/oradata/orcl/sysaux.257.736598563
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=737150574 filename=/u01/app/oracle/oradata/orcl/users.259.736598641
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=737150574 filename=/u01/app/oracle/oradata/orcl/undotbs2.264.736599805
contents of Memory Script:
{
set until scn 861023;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 07-DEC-10
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK
starting media recovery
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
-- restore 歸檔檔案
archive log thread=2 sequence=11
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/arch_0hluu1q6_1_1_20101207
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/arch_0hluu1q6_1_1_20101207 tag=TAG20101207T015407
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=12
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=13
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/arch_0iluu1q7_1_1_20101207
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/arch_0iluu1q7_1_1_20101207 tag=TAG20101207T015407
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
archive log filename=/u01/archivelog/1_12_736599263.arch thread=1 sequence=12
archive log filename=/u01/archivelog/2_11_736599263.arch thread=2 sequence=11
channel clone_default: deleting archive log(s)
archive log filename=/u01/archivelog/2_11_736599263.arch recid=1 stamp=737150585
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=2 sequence=12
channel ORA_AUX_DISK_1: reading from backup piece /u02/backup/arch_0jluu1qu_1_1_20101207
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/backup/arch_0jluu1qu_1_1_20101207 tag=TAG20101207T015407
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archive log filename=/u01/archivelog/2_12_736599263.arch thread=2 sequence=12
channel clone_default: deleting archive log(s)
archive log filename=/u01/archivelog/1_12_736599263.arch recid=3 stamp=737150587
archive log filename=/u01/archivelog/1_13_736599263.arch thread=1 sequence=13
channel clone_default: deleting archive log(s)
archive log filename=/u01/archivelog/1_13_736599263.arch recid=2 stamp=737150587
channel clone_default: deleting archive log(s)
archive log filename=/u01/archivelog/2_12_736599263.arch recid=4 stamp=737150593
media recovery complete, elapsed time: 00:00:06
Finished recover at 07-DEC-10
contents of Memory Script:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script
-- 如果在這裡卡住,就檢查一下有沒有session視窗是開的,有關閉即可
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 360710144 bytes
Fixed Size 1219424 bytes
Variable Size 109053088 bytes
Database Buffers 247463936 bytes
Redo Buffers 2973696 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL" RESETLOGS ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/orcl/group_1.261.736599263', '/u01/app/oracle/oradata/orcl/group_1.257.736599275' ) SIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/orcl/group_2.262.736599285', '/u01/app/oracle/oradata/orcl/group_2.258.736599295' ) SIZE 50 M REUSE
DATAFILE
'/u01/app/oracle/oradata/orcl/system.256.736598559'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/orcl/temp.263.736599505";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/undotbs1.258.736598599";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/sysaux.257.736598563";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/users.259.736598641";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/undotbs2.264.736599805";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oracle/oradata/orcl/temp.263.736599505 in control file
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/orcl/undotbs1.258.736598599 recid=1 stamp=737150639
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/orcl/sysaux.257.736598563 recid=2 stamp=737150640
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/orcl/users.259.736598641 recid=3 stamp=737150641
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/orcl/undotbs2.264.736599805 recid=4 stamp=737150642
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=737150639 filename=/u01/app/oracle/oradata/orcl/undotbs1.258.736598599
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=737150640 filename=/u01/app/oracle/oradata/orcl/sysaux.257.736598563
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=737150641 filename=/u01/app/oracle/oradata/orcl/users.259.736598641
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=737150642 filename=/u01/app/oracle/oradata/orcl/undotbs2.264.736599805
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 07-DEC-10
RMAN>
至此,RMAN的duplicate 已經完成。 遷移基本完成。
四. 目標庫的其他掃尾操作
4.1 清除多餘的undo檔案
檢視UNDO 資訊:
SQL> select name from v$tablespace where name like 'UNDO%';
NAME
------------------------------
UNDOTBS1
UNDOTBS2
因為我們使用的是UNDOTBS1,在pfile裡設定的,所以把UNDOTBS2刪除掉。
SQL> show parameter undo_tablespace;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace string UNDOTBS1
SQL> drop tablespace undotbs2 including contents and datafiles;
Tablespace dropped.
SQL> select name from v$tablespace where name like 'UNDO%';
NAME
------------------------------
UNDOTBS1
SQL>
4.2 清除未使用執行緒的redo日誌組
預設情況下,RAC 環境下,每個例項都有2個redo。 在單例項下,就沒有必要了。 我們刪除點執行緒2的redo 資訊。
SQL> select thread#,status,enabled from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
2 CLOSED PRIVATE
SQL> select group#,thread#,archived,status from v$log;
GROUP# THREAD# ARC STATUS
---------- ---------- --- ----------------
1 1 YES UNUSED
2 1 NO CURRENT
3 2 NO CURRENT
4 2 YES UNUSED
SQL> alter database disable thread 2;
Database altered.
SQL> alter database clear unarchived logfile group 3;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
SQL> alter database drop logfile group 4;
Database altered.
SQL> select group#,thread#,archived,status from v$log;
GROUP# THREAD# ARC STATUS
---------- ---------- --- ----------------
1 1 YES INACTIVE
2 1 NO CURRENT
現在就剩2個了。 一般的單例項是3個online redo。 我們在新增一組。
SQL> alter database add logfile group 3 ('/u01/app/oracle/oradata/orcl/redo03.log') size 10m;
Database altered.
SQL> select group#,thread#,archived,status from v$log;
GROUP# THREAD# ARC STATUS
---------- ---------- --- ----------------
1 1 YES INACTIVE
2 1 NO CURRENT
3 1 YES UNUSED
Redo 的相關資訊,也可以參考:
Redo Log 和Checkpoint not complete
http://blog.csdn.net/tianlesoftware/archive/2009/12/01/4908066.aspx
如何搭建一個資料庫伺服器平臺
http://blog.csdn.net/tianlesoftware/archive/2010/05/17/5602291.aspx
4.3 重建臨時表空間,並刪除原來的資料檔案
SQL> select file#,name from v$tempfile;
FILE# NAME
---------- ---------------------------------------------------------------------
1 /u01/app/oracle/oradata/orcl/temp.263.736599505
Temp 重建參考:
Oracle Temp 臨時表空間
http://blog.csdn.net/tianlesoftware/archive/2009/10/19/4697417.aspx
4.4 OEM 配置
手工用命令建立一下,也就幾個命令。 參考:
Oracle OEM 重建
http://blog.csdn.net/tianlesoftware/archive/2009/10/21/4702978.aspx
小結:
步驟和RMAN的異機複製基本差不多了。 就多加了幾個引數。 也是折騰到現在,都2點多了。 這幾天白天比較忙, 沒有時間搞。 月底公司伺服器要搬遷,從紹興的IDC機房搬到蕭山的IDC機房。 有20臺左右的伺服器,還有盤櫃。搬遷之後還要對資料庫做一次遷移和升級。 夠折騰的, 還有十來天時間,抓緊時間測試。 折騰死了。
轉載請標明出處:http://blog.sina.com.cn/s/blog_465a4a1e0100pyvx.html
相關文章
- rac恢復到單例項單例
- RAC+DG(asm單例項)ASM單例
- RAC+單例項DG的切換單例
- Oracle 11g RAC到單例項OGG同步Oracle單例
- 將RAC軟體轉換為單例項軟體單例
- 【DG】在Linux平臺上搭建單例項的dataguard--duplicateLinux單例
- msfvenom使用例項
- pinctrl使用例項
- expect使用例項
- RMAN Duplicate RAC to Single Instance
- tunna工具使用例項
- awk命令使用例項
- restorecon 命令使用例項REST
- Tee命令使用例項
- PHP 完整表單例項PHP單例
- Redis單例項安裝Redis單例
- 怎麼把達夢資料庫例項從Windows遷移到Linux系統資料庫WindowsLinux
- 將RAC備份集恢復為單例項資料庫單例資料庫
- oracle rac 單個例項不能生成awr報告的問題Oracle
- 單例項Primary快速搭建Standby RAC參考手冊(19.16 ADG)單例
- ORA-29702複製RAC Oracle軟體啟動單例項Oracle單例
- php例項化物件的例項方法PHP物件
- cut命令的使用例項
- docker-compose 使用例項Docker
- C# IDispose使用例項C#
- 單例項mysql.yaml kubernetes單例MySqlYAML
- opengl簡單入門例項
- Spark 簡單例項(基本操作)Spark單例
- OkHttpClient例項HTTPclient
- unittest例項
- jQuery 例項jQuery
- canal同步mysql,監聽單例項,多例項配置MySql單例
- 【DG】在Linux平臺上搭建單例項的dataguard--rman還原方式Linux單例
- 例項QT程式 —— Qt單例不規則介面程式QT單例
- 從nub備份恢復(同平臺)恢復RAC至單例項單例
- 記錄一次Oracle 11.2.0.4 RAC異地恢復到單例項Oracle單例
- Oracle 資料庫巡檢指令碼 單例項 RAC 輸出HTML格式Oracle資料庫指令碼單例HTML
- Linux中printf命令使用例項Linux
- Memcached安裝與使用例項