Chinaunix首页 | 论坛 | 博客
  • 博客访问: 413450
  • 博文数量: 65
  • 博客积分: 2711
  • 博客等级: 少校
  • 技术积分: 745
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-02 10:02
文章分类

全部博文(65)

文章存档

2013年(4)

2012年(3)

2011年(24)

2010年(21)

2009年(11)

2008年(2)

分类: Oracle

2010-04-21 14:42:44

实验环境:
    系统环境:redhat-as4.7
    oracle:   oracle10.2.0.4
   
    主数据库:
             ip地址:192.168.1.220
             主机名称:db-primary
             实例名称:lizidb
             数据库名称:lizidb
             oracle软件目录:/opt/oracle/product/10.2.0
             数据库数据文件目录:/u00/oracle/lizidb
             rman备份目录:/u00/dbbackup
    辅助数据库:
             ip地址:192.168.1.221
             主机名称:db-standby
             实例名称:standbydb
             数据库名称:sbydb
             oracle软件目录:/opt/oracle/product/10.2.0
             数据库数据文件目录:/u00/oracle/standbydb
             rman备份目录:/u00/dbbackup
本实验采取rman备份目录采取nfs共享目录模式,共享主机为192.168.1.241,目录为/u03/share,在主辅库服务器中分别挂载这个共享目录到/u00/dbbackup,命令为:mount -t nfs 192.168.1.241:/u03/share /u00/dbbackup
 
实验步骤:
第一步、创建辅助实例
 
1、创建密码文件
[oracle@db-standby dbs]$ pwd
/opt/oracle/product/10.2.0/dbs
[oracle@db-standby dbs]$ orapwd file=/opt/oracle/product/10.2.0/dbs/orapwstandbydb password=aaa entries=30
[oracle@db-standby dbs]$ ls
alert_standbydb.log  hc_standbydb.dat  initdw.ora      spfilelizidb.ora.bak
hc_lizidb.dat        init.ora          orapwstandbydb  spfilestandbydb.ora
这一步中第一次由于创建密码文件的格式及位置错误:
orapwd file=/u00/oracle/standbydb/pwdstandby.ora password=aaa entries=30
导致了用rman连接辅助实例时出现ORA-01031: insufficient privileges错误,之后按照创建密码文件的要求重新创建,没有出现问题。详见:http://blog.chinaunix.net/u2/65284/showart.php?id=2216378
 
2、手动创建初始化参数文件及各个相应的目录
创建参数目录:
[oracle@db-standby oracle]$ cd admin/
[oracle@db-standby admin]$ ls
[oracle@db-standby admin]$ mkdir standbydb
[oracle@db-standby admin]$ ls
standbydb
[oracle@db-standby admin]$ cd standbydb/
[oracle@db-standby standbydb]$ ls
[oracle@db-standby standbydb]$ mkdir adump
[oracle@db-standby standbydb]$ mkdir bdump
[oracle@db-standby standbydb]$ mkdir cdump
[oracle@db-standby standbydb]$ mkdir dpdump
[oracle@db-standby standbydb]$ mkdir udump
[oracle@db-standby standbydb]$ mkdir pfile
[oracle@db-standby standbydb]$
创建数据文件目录:
[oracle@db-standby oracle]$ mkdir standbydb
[oracle@db-standby oracle]$ cd standbydb
[oracle@db-standby standbydb]$ pwd
/u00/oracle/standbydb
将主数据库初始化参数文件远程拷贝到辅助数据库目录的pfile目录中进行修改,如下:
主数据库初始化参数文件:
[root@db-primary pfile]# cat init.ora.1222010164651
##############################################################################
# Copyright (c) 1991, 2001, 2002 by Oracle Corporation
##############################################################################
 
###########################################
# Archive
###########################################
log_archive_dest_1='LOCATION=/u00/arch'
log_archive_format=%t_%s_%r.dbf
 
###########################################
# Cache and I/O
###########################################
db_block_size=8192
db_file_multiblock_read_count=16
 
###########################################
# Cursors and Library Cache
###########################################
open_cursors=300
 
###########################################
# Database Identification
###########################################
db_domain=""
db_name=lizidb
 
###########################################
# Diagnostics and Statistics
###########################################
background_dump_dest=/opt/oracle/admin/lizidb/bdump
core_dump_dest=/opt/oracle/admin/lizidb/cdump
user_dump_dest=/opt/oracle/admin/lizidb/udump
 
###########################################
# File Configuration
###########################################
control_files=("/u00/oracle/lizidb/control01.ctl", "/u00/oracle/lizidb/control02.ctl", "/u00/oracle/lizidb/control03.ctl")
db_recovery_file_dest=/u00/flash
db_recovery_file_dest_size=2147483648
 
###########################################
# Job Queues
###########################################
job_queue_processes=10
 
###########################################
# Miscellaneous
###########################################
compatible=10.2.0.3.0
 
###########################################
# NLS
###########################################
nls_language="SIMPLIFIED CHINESE"
nls_territory="CHINA"
 
###########################################
# Processes and Sessions
###########################################
processes=150
sessions=170
 
###########################################
# SGA Memory
###########################################
sga_target=1073741824
 
###########################################
# Security and Auditing
###########################################
audit_file_dest=/opt/oracle/admin/lizidb/adump
remote_login_passwordfile=EXCLUSIVE
 
###########################################
# Shared Server
###########################################
dispatchers="(PROTOCOL=TCP) (SERVICE=lizidbXDB)"
 
###########################################
# Sort, Hash Joins, Bitmap Indexes
###########################################
pga_aggregate_target=357564416
 
###########################################
# System Managed Undo and Rollback Segments
###########################################
undo_management=AUTO
undo_tablespace=UNDOTBS1
 

辅助数据库初始化参数文件:
[root@db-standby pfile]# cat init.ora.standbydb
##############################################################################
# Copyright (c) 1991, 2001, 2002 by Oracle Corporation
##############################################################################
 
###########################################
# Archive
###########################################
log_archive_dest_1='LOCATION=/u00/arch'
log_archive_format=%t_%s_%r.dbf
 
###########################################
# Cache and I/O
###########################################
db_block_size=8192
db_file_multiblock_read_count=16
 
###########################################
# Cursors and Library Cache
###########################################
open_cursors=300
 
###########################################
# Database Identification
###########################################
db_domain=""
db_name=sbydb
 
###########################################
# Diagnostics and Statistics
###########################################
background_dump_dest=/opt/oracle/admin/standbydb/bdump
core_dump_dest=/opt/oracle/admin/standbydb/cdump
user_dump_dest=/opt/oracle/admin/standbydb/udump
 
###########################################
# File Configuration
###########################################
control_files=("/u00/oracle/standbydb/control01.ctl", "/u00/oracle/standbydb/control02.ctl", "/u00/oracle/standbydb/control03.ctl")
db_recovery_file_dest=/u00/flash
db_recovery_file_dest_size=2147483648
db_file_name_convert=('/u00/oracle/lizidb','/u00/oracle/standbydb')
log_file_name_convert=('/u00/oracle/lizidb','/u00/oracle/standbydb')

 
###########################################
# Job Queues
###########################################
job_queue_processes=10
 
###########################################
# Miscellaneous
###########################################
compatible=10.2.0.3.0
 
###########################################
# NLS
###########################################
nls_language="SIMPLIFIED CHINESE"
nls_territory="CHINA"
 
###########################################
# Processes and Sessions
###########################################
processes=150
sessions=170
 
###########################################
# SGA Memory
###########################################
sga_target=1073741824
 
###########################################
# Security and Auditing
###########################################
audit_file_dest=/opt/oracle/admin/standbydb/adump
remote_login_passwordfile=EXCLUSIVE
 
###########################################
# Shared Server
###########################################
dispatchers="(PROTOCOL=TCP) (SERVICE=standbydbXDB)"
 
###########################################
# Sort, Hash Joins, Bitmap Indexes
###########################################
pga_aggregate_target=357564416
 
###########################################
# System Managed Undo and Rollback Segments
###########################################
undo_management=AUTO
undo_tablespace=UNDOTBS1
蓝色标记的为需要修改的地方。 
 
 
3、在辅助数据库中启动空实例以pfile创建spfile,然后启动到nomount状态:
[oracle@db-standby pfile]$ sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.4.0 - Production on Fri Apr 16 15:51:30 2010
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
Connected to an idle instance.
SQL> create spfile from pfile='/opt/oracle/admin/standbydb/pfile/init.ora.standbydb';
File created.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size                  2089400 bytes
Variable Size             264244808 bytes
Database Buffers          801112064 bytes
Redo Buffers                6295552 bytes
SQL>
 
这一步中遇到了两个问题:

(1)、第一次修改初始化参数文件时候,将db_name设置为db_name=standbydb,启动辅助实例时候报错:
SQL> startup nomount
ORA-01127: database name 'standbydb' exceeds size limit of 8 characters
这是因为oracle自9i以来db_name不允许超过8个字符,将其改为db_name=sbydb,问题解决。

(2)、开始时候设置db_file_name_convert、log_file_name_convert为:
db_file_name_convert=('/u00/oracle/lizidb')
log_file_name_convert=('/u00/oracle/lizidb')
或者:
db_file_name_convert=('/u00/dbbackup','/u00/dbbackup')
log_file_name_convert=('/u00/dbbackup','/u00/dbbackup')
这样,在用rman进行duplicate时候均报错:
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/19/2010 16:40:08
RMAN-05501: aborting duplication of target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/lizi.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/zlktest.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/wkyj.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/web.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/toto.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/rman.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/newdb.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/example01.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/users01.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/sysaux01.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/undotbs01.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/system01.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/redo03.log conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/redo02.log conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u00/oracle/lizidb/redo01.log conflicts with a file used by the target database
这两个参数含义大概为复制前后的数据文件路径,因次必须严格设置为主数据库和辅助数据库的数据文件路径目录:
db_file_name_convert=('/u00/oracle/lizidb','/u00/oracle/standbydb')
log_file_name_convert=('/u00/oracle/lizidb','/u00/oracle/standbydb')
问题解决。
 
 
 
第二步、rman备份主数据库
 
[oracle@db-standby ~]$ rman target
Recovery Manager: Release 10.2.0.4.0 - Production on Mon Apr 19 12:00:17 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database: LIZIDB (DBID=3331456942)
RMAN> run  {
2>  CONFIGURE CONTROLFILE AUTOBACKUP ON;
3>  CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u00/dbbackup/%F';
4>  ALLOCATE CHANNEL CH1 DEVICE TYPE DISK FORMAT '/u00/dbbackup/%U';
5>  BACKUP DATABASE SKIP INACCESSIBLE FILESPERSET 10 PLUS ARCHIVELOG FILESPERSET 20
6>  DELETE ALL INPUT;
7>  RELEASE CHANNEL CH1;
8>  }
using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u00/dbbackup/%F';
new RMAN configuration parameters are successfully stored
allocated channel: CH1
channel CH1: sid=135 devtype=DISK

Starting backup at 2010-04-19 12:00:54
current log archived
released channel: CH1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup plus archivelog command at 04/19/2010 12:00:57
RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
ORA-19625: error identifying file /u00/arch/1_1_711650606.dbf
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
RMAN>
RMAN> crosscheck archivelog all;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=135 devtype=DISK
validation failed for archived log
archive log filename=/u00/arch/1_1_711650606.dbf recid=1 stamp=712638065
validation failed for archived log
archive log filename=/u00/arch/1_2_711650606.dbf recid=3 stamp=713187749
validation succeeded for archived log
archive log filename=/u00/arch/1_3_711650606.dbf recid=2 stamp=713187746
validation succeeded for archived log
archive log filename=/u00/arch/1_4_711650606.dbf recid=4 stamp=713187750
validation succeeded for archived log
archive log filename=/u00/arch/1_5_711650606.dbf recid=5 stamp=713188490
validation succeeded for archived log
archive log filename=/u00/arch/1_8_711650606.dbf recid=6 stamp=713197579
validation succeeded for archived log
archive log filename=/u00/arch/1_9_711650606.dbf recid=7 stamp=713264687
validation failed for archived log
archive log filename=/u00/arch/1_10_711650606.dbf recid=8 stamp=713269590
validation failed for archived log
archive log filename=/u00/arch/1_11_711650606.dbf recid=9 stamp=713270562
validation failed for archived log
archive log filename=/u00/arch/1_12_711650606.dbf recid=10 stamp=713271533
validation failed for archived log
archive log filename=/u00/arch/1_13_711650606.dbf recid=11 stamp=713876115
validation failed for archived log
archive log filename=/u00/arch/1_14_711650606.dbf recid=12 stamp=713981122
validation failed for archived log
archive log filename=/u00/arch/1_15_711650606.dbf recid=13 stamp=715012089
validation failed for archived log
archive log filename=/u00/arch/1_16_711650606.dbf recid=14 stamp=715076804
validation failed for archived log
archive log filename=/u00/arch/1_17_711650606.dbf recid=15 stamp=715088213
validation failed for archived log
archive log filename=/u00/arch/1_18_711650606.dbf recid=16 stamp=715088365
validation failed for archived log
archive log filename=/u00/arch/1_19_711650606.dbf recid=17 stamp=715088549
validation failed for archived log
archive log filename=/u00/arch/1_20_711650606.dbf recid=18 stamp=715088708
validation failed for archived log
archive log filename=/u00/arch/1_21_711650606.dbf recid=19 stamp=715604776
validation failed for archived log
archive log filename=/u00/arch/1_22_711650606.dbf recid=20 stamp=715604784
validation failed for archived log
archive log filename=/u00/arch/1_23_711650606.dbf recid=21 stamp=715692901
validation failed for archived log
archive log filename=/u00/arch/1_24_711650606.dbf recid=22 stamp=715796231
validation failed for archived log
archive log filename=/u00/arch/1_25_711650606.dbf recid=23 stamp=716315449
validation failed for archived log
archive log filename=/u00/arch/1_26_711650606.dbf recid=24 stamp=716407012
validation failed for archived log
archive log filename=/u00/arch/1_27_711650606.dbf recid=25 stamp=716488162
validation failed for archived log
archive log filename=/u00/arch/1_28_711650606.dbf recid=26 stamp=716587412
validation succeeded for archived log
archive log filename=/u00/arch/1_29_711650606.dbf recid=27 stamp=716731536
Crosschecked 27 objects

RMAN> run
2>  {
3>  CONFIGURE CONTROLFILE AUTOBACKUP ON;
4>  CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u00/dbbackup/%F';
5>  ALLOCATE CHANNEL CH1 DEVICE TYPE DISK FORMAT '/u00/dbbackup/%U';
6>  BACKUP DATABASE SKIP INACCESSIBLE FILESPERSET 10 PLUS ARCHIVELOG FILESPERSET 20
7>  DELETE ALL INPUT;
8>  RELEASE CHANNEL CH1;
9>  }
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u00/dbbackup/%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u00/dbbackup/%F';
new RMAN configuration parameters are successfully stored
released channel: ORA_DISK_1
allocated channel: CH1
channel CH1: sid=135 devtype=DISK

Starting backup at 2010-04-19 12:56:42
current log archived
channel CH1: starting archive log backupset
channel CH1: specifying archive log(s) in backup set
input archive log thread=1 sequence=3 recid=2 stamp=713187746
input archive log thread=1 sequence=4 recid=4 stamp=713187750
input archive log thread=1 sequence=5 recid=5 stamp=713188490
input archive log thread=1 sequence=8 recid=6 stamp=713197579
input archive log thread=1 sequence=9 recid=7 stamp=713264687
input archive log thread=1 sequence=29 recid=27 stamp=716731536
input archive log thread=1 sequence=30 recid=28 stamp=716734888
channel CH1: starting piece 1 at 2010-04-19 13:01:30
channel CH1: finished piece 1 at 2010-04-19 13:03:04
piece handle=/u00/dbbackup/01lbh0d9_1_1 tag=TAG20100419T130129 comment=NONE
channel CH1: backup set complete, elapsed time: 00:01:35
channel CH1: deleting archive log(s)
archive log filename=/u00/arch/1_3_711650606.dbf recid=2 stamp=713187746
archive log filename=/u00/arch/1_4_711650606.dbf recid=4 stamp=713187750
archive log filename=/u00/arch/1_5_711650606.dbf recid=5 stamp=713188490
archive log filename=/u00/arch/1_8_711650606.dbf recid=6 stamp=713197579
archive log filename=/u00/arch/1_9_711650606.dbf recid=7 stamp=713264687
archive log filename=/u00/arch/1_29_711650606.dbf recid=27 stamp=716731536
archive log filename=/u00/arch/1_30_711650606.dbf recid=28 stamp=716734888
Finished backup at 2010-04-19 12:58:19
Starting backup at 2010-04-19 12:58:19
channel CH1: starting full datafile backupset
channel CH1: specifying datafile(s) in backupset
input datafile fno=00004 name=/u00/oracle/lizidb/users01.dbf
input datafile fno=00010 name=/u00/oracle/lizidb/wkyj.dbf
input datafile fno=00012 name=/u00/oracle/lizidb/lizi.dbf
input datafile fno=00001 name=/u00/oracle/lizidb/system01.dbf
input datafile fno=00003 name=/u00/oracle/lizidb/sysaux01.dbf
channel CH1: starting piece 1 at 2010-04-19 13:03:05
channel CH1: finished piece 1 at 2010-04-19 13:09:19
piece handle=/u00/dbbackup/02lbh0g9_1_1 tag=TAG20100419T130305 comment=NONE
channel CH1: backup set complete, elapsed time: 00:06:14
channel CH1: starting full datafile backupset
channel CH1: specifying datafile(s) in backupset
input datafile fno=00006 name=/u00/oracle/lizidb/newdb.dbf
input datafile fno=00008 name=/u00/oracle/lizidb/toto.dbf
input datafile fno=00009 name=/u00/oracle/lizidb/web.dbf
input datafile fno=00011 name=/u00/oracle/lizidb/zlktest.dbf
input datafile fno=00002 name=/u00/oracle/lizidb/undotbs01.dbf
input datafile fno=00005 name=/u00/oracle/lizidb/example01.dbf
input datafile fno=00007 name=/u00/oracle/lizidb/rman.dbf
channel CH1: starting piece 1 at 2010-04-19 13:09:19
channel CH1: finished piece 1 at 2010-04-19 13:09:34
piece handle=/u00/dbbackup/03lbh0rv_1_1 tag=TAG20100419T130305 comment=NONE
channel CH1: backup set complete, elapsed time: 00:00:15
Finished backup at 2010-04-19 13:04:50
Starting backup at 2010-04-19 13:04:50
current log archived
channel CH1: starting archive log backupset
channel CH1: specifying archive log(s) in backup set
input archive log thread=1 sequence=31 recid=29 stamp=716735374
channel CH1: starting piece 1 at 2010-04-19 13:09:35
channel CH1: finished piece 1 at 2010-04-19 13:09:36
piece handle=/u00/dbbackup/04lbh0se_1_1 tag=TAG20100419T130934 comment=NONE
channel CH1: backup set complete, elapsed time: 00:00:02
channel CH1: deleting archive log(s)
archive log filename=/u00/arch/1_31_711650606.dbf recid=29 stamp=716735374
Finished backup at 2010-04-19 13:04:52
Starting Control File and SPFILE Autobackup at 2010-04-19 13:04:52
piece handle=/u00/dbbackup/c-3331456942-20100419-00 comment=NONE
Finished Control File and SPFILE Autobackup at 2010-04-19 13:04:55
released channel: CH1
RMAN> list backup
2> ;

List of Backup Sets
===================
BS Key  Size       Device Type Elapsed Time Completion Time   
------- ---------- ----------- ------------ -------------------
1       542.66M    DISK        00:01:33     2010-04-19 13:03:02
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20100419T130129
        Piece Name: /u00/dbbackup/01lbh0d9_1_1
  List of Archived Logs in backup set 1
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    3       1143464    2010-03-09 11:32:12 1163468    2010-03-09 11:33:14
  1    4       1163468    2010-03-09 11:33:14 1183472    2010-03-09 11:42:29
  1    5       1183472    2010-03-09 11:42:29 1184287    2010-03-09 11:54:50
  1    8       1511959    2010-03-09 12:13:31 1609405    2010-03-09 14:25:13
  1    9       1609405    2010-03-09 14:25:13 1635624    2010-03-10 09:04:43
  1    29      65100733   2010-04-17 20:03:13 65178537   2010-04-19 12:05:34
  1    30      65178537   2010-04-19 12:05:34 65180410   2010-04-19 13:01:28
BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
2       Full    2.68G      DISK        00:06:06     2010-04-19 13:09:11
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20100419T130305
        Piece Name: /u00/dbbackup/02lbh0g9_1_1
  List of Datafiles in backup set 2
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 65180488   2010-04-19 13:03:05 /u00/oracle/lizidb/system01.dbf
  3       Full 65180488   2010-04-19 13:03:05 /u00/oracle/lizidb/sysaux01.dbf
  4       Full 65180488   2010-04-19 13:03:05 /u00/oracle/lizidb/users01.dbf
  10      Full 65180488   2010-04-19 13:03:05 /u00/oracle/lizidb/wkyj.dbf
  12      Full 65180488   2010-04-19 13:03:05 /u00/oracle/lizidb/lizi.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
3       Full    73.27M     DISK        00:00:09     2010-04-19 13:09:28
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20100419T130305
        Piece Name: /u00/dbbackup/03lbh0rv_1_1
  List of Datafiles in backup set 3
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  2       Full 65180642   2010-04-19 13:09:19 /u00/oracle/lizidb/undotbs01.dbf
  5       Full 65180642   2010-04-19 13:09:19 /u00/oracle/lizidb/example01.dbf
  6       Full 65180642   2010-04-19 13:09:19 /u00/oracle/lizidb/newdb.dbf
  7       Full 65180642   2010-04-19 13:09:19 /u00/oracle/lizidb/rman.dbf
  8       Full 65180642   2010-04-19 13:09:19 /u00/oracle/lizidb/toto.dbf
  9       Full 65180642   2010-04-19 13:09:19 /u00/oracle/lizidb/web.dbf
  11      Full 65180642   2010-04-19 13:09:19 /u00/oracle/lizidb/zlktest.dbf
BS Key  Size       Device Type Elapsed Time Completion Time   
------- ---------- ----------- ------------ -------------------
4       107.00K    DISK        00:00:02     2010-04-19 13:09:36
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20100419T130934
        Piece Name: /u00/dbbackup/04lbh0se_1_1
  List of Archived Logs in backup set 4
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    31      65180410   2010-04-19 13:01:28 65180650   2010-04-19 13:09:34
BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
5       Full    6.80M      DISK        00:00:01     2010-04-19 13:09:38
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20100419T130937
        Piece Name: /u00/dbbackup/c-3331456942-20100419-00
  Control File Included: Ckp SCN: 65180656     Ckp time: 2010-04-19 13:09:37
  SPFILE Included: Modification time: 2010-04-19 09:31:36
RMAN>
RMAN> exit
 
如以上红色标记所示,在这过程中出现了一些列的错误:
RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
ORA-19625: error identifying file /u00/arch/1_1_711650606.dbf
ORA-27037: unable to obtain file status
这是因为我把archive日至文件删除了一部分,导致archive日至文件与当前的数据库系统中对应的记录号不一致,解决方法只需要同步一下即可,执行命令:RMAN> crosscheck archivelog all;
 

第三步、进行数据库平移
进行数据库平移只需要执行一条duplicate命令,但是,准备条件一定要检查再检查,参照三思的笔记,否则有一处准备工作做不好的话就会出错。
[oracle@db-standby ~]$ rman target auxiliary
Recovery Manager: Release 10.2.0.4.0 - Production on Mon Apr 19 15:56:36 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database: LIZIDB (DBID=3331456942)
connected to auxiliary database: SBYDB (not mounted)
RMAN>
RMAN> run
2>  {
3>  ALLOCATE CHANNEL CH1 DEVICE TYPE DISK;
4>  ALLOCATE CHANNEL CH2 DEVICE TYPE DISK;
5>  ALLOCATE CHANNEL CH3 DEVICE TYPE DISK;
6>  duplicate target database to sbydb;
7>  }
using target database control file instead of recovery catalog
allocated channel: CH1
channel CH1: sid=138 devtype=DISK
allocated channel: CH2
channel CH2: sid=131 devtype=DISK
allocated channel: CH3
channel CH3: sid=140 devtype=DISK
Starting Duplicate Db at 2010-04-19 16:28:12
released channel: CH1
released channel: CH2
released channel: CH3
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/19/2010 16:28:12
RMAN-05503: at least one auxiliary channel must be allocated to execute this command
RMAN> run
2>  {
3>  ALLOCATE AUXILIARY CHANNEL CH1 DEVICE TYPE DISK;
4>  ALLOCATE AUXILIARY CHANNEL CH2 DEVICE TYPE DISK;
5>  ALLOCATE AUXILIARY CHANNEL CH3 DEVICE TYPE DISK;
6>  duplicate target database to sbydb nofilenamecheck;
7>  }
using target database control file instead of recovery catalog
allocated channel: CH1
channel CH1: sid=155 devtype=DISK
allocated channel: CH2
channel CH2: sid=154 devtype=DISK
allocated channel: CH3
channel CH3: sid=153 devtype=DISK
Starting Duplicate Db at 2010-04-19 16:57:40
contents of Memory Script:
{
   set until scn  65180650;
   set newname for datafile  1 to
 "/u00/oracle/standbydb/system01.dbf";
   set newname for datafile  2 to
 "/u00/oracle/standbydb/undotbs01.dbf";
   set newname for datafile  3 to
 "/u00/oracle/standbydb/sysaux01.dbf";
   set newname for datafile  4 to
 "/u00/oracle/standbydb/users01.dbf";
   set newname for datafile  5 to
 "/u00/oracle/standbydb/example01.dbf";
   set newname for datafile  6 to
 "/u00/oracle/standbydb/newdb.dbf";
   set newname for datafile  7 to
 "/u00/oracle/standbydb/rman.dbf";
   set newname for datafile  8 to
 "/u00/oracle/standbydb/toto.dbf";
   set newname for datafile  9 to
 "/u00/oracle/standbydb/web.dbf";
   set newname for datafile  10 to
 "/u00/oracle/standbydb/wkyj.dbf";
   set newname for datafile  11 to
 "/u00/oracle/standbydb/zlktest.dbf";
   set newname for datafile  12 to
 "/u00/oracle/standbydb/lizi.dbf";
   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
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 2010-04-19 16:57:40
channel CH1: starting datafile backupset restore
channel CH1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u00/oracle/standbydb/system01.dbf
restoring datafile 00003 to /u00/oracle/standbydb/sysaux01.dbf
restoring datafile 00004 to /u00/oracle/standbydb/users01.dbf
restoring datafile 00010 to /u00/oracle/standbydb/wkyj.dbf
restoring datafile 00012 to /u00/oracle/standbydb/lizi.dbf
channel CH1: reading from backup piece /u00/dbbackup/02lbh0g9_1_1
channel CH2: starting datafile backupset restore
channel CH2: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /u00/oracle/standbydb/undotbs01.dbf
restoring datafile 00005 to /u00/oracle/standbydb/example01.dbf
restoring datafile 00006 to /u00/oracle/standbydb/newdb.dbf
restoring datafile 00007 to /u00/oracle/standbydb/rman.dbf
restoring datafile 00008 to /u00/oracle/standbydb/toto.dbf
restoring datafile 00009 to /u00/oracle/standbydb/web.dbf
restoring datafile 00011 to /u00/oracle/standbydb/zlktest.dbf
channel CH2: reading from backup piece /u00/dbbackup/03lbh0rv_1_1
channel CH2: restored backup piece 1
piece handle=/u00/dbbackup/03lbh0rv_1_1 tag=TAG20100419T130305
channel CH2: restore complete, elapsed time: 00:06:24
channel CH1: restored backup piece 1
piece handle=/u00/dbbackup/02lbh0g9_1_1 tag=TAG20100419T130305
channel CH1: restore complete, elapsed time: 00:10:59
Finished restore at 2010-04-19 17:08:41
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "SBYDB" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( '/u00/oracle/standbydb/redo01.log' ) SIZE 512 M  REUSE,
  GROUP  2 ( '/u00/oracle/standbydb/redo02.log' ) SIZE 512 M  REUSE,
  GROUP  3 ( '/u00/oracle/standbydb/redo03.log' ) SIZE 512 M  REUSE
 DATAFILE
  '/u00/oracle/standbydb/system01.dbf'
 CHARACTER SET ZHS16GBK

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=716749724 filename=/u00/oracle/standbydb/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=716749724 filename=/u00/oracle/standbydb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=716749724 filename=/u00/oracle/standbydb/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=716749724 filename=/u00/oracle/standbydb/example01.dbf
datafile 6 switched to datafile copy
input datafile copy recid=5 stamp=716749724 filename=/u00/oracle/standbydb/newdb.dbf
datafile 7 switched to datafile copy
input datafile copy recid=6 stamp=716749724 filename=/u00/oracle/standbydb/rman.dbf
datafile 8 switched to datafile copy
input datafile copy recid=7 stamp=716749724 filename=/u00/oracle/standbydb/toto.dbf
datafile 9 switched to datafile copy
input datafile copy recid=8 stamp=716749724 filename=/u00/oracle/standbydb/web.dbf
datafile 10 switched to datafile copy
input datafile copy recid=9 stamp=716749724 filename=/u00/oracle/standbydb/wkyj.dbf
datafile 11 switched to datafile copy
input datafile copy recid=10 stamp=716749724 filename=/u00/oracle/standbydb/zlktest.dbf
datafile 12 switched to datafile copy
input datafile copy recid=11 stamp=716749725 filename=/u00/oracle/standbydb/lizi.dbf
contents of Memory Script:
{
   set until scn  65180650;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script
executing command: SET until clause
Starting recover at 2010-04-19 17:08:46
starting media recovery
channel CH1: starting archive log restore to default destination
channel CH1: restoring archive log
archive log thread=1 sequence=31
channel CH1: reading from backup piece /u00/dbbackup/04lbh0se_1_1
channel CH1: restored backup piece 1
piece handle=/u00/dbbackup/04lbh0se_1_1 tag=TAG20100419T130934
channel CH1: restore complete, elapsed time: 00:00:03
archive log filename=/u00/arch/1_31_711650606.dbf thread=1 sequence=31
channel clone_default: deleting archive log(s)
archive log filename=/u00/arch/1_31_711650606.dbf recid=1 stamp=716749734
media recovery complete, elapsed time: 00:00:01
Finished recover at 2010-04-19 17:08:56
contents of Memory Script:
{
   shutdown clone;
   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    1073741824 bytes
Fixed Size                     2089400 bytes
Variable Size                264244808 bytes
Database Buffers             801112064 bytes
Redo Buffers                   6295552 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "SBYDB" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( '/u00/oracle/standbydb/redo01.log' ) SIZE 512 M  REUSE,
  GROUP  2 ( '/u00/oracle/standbydb/redo02.log' ) SIZE 512 M  REUSE,
  GROUP  3 ( '/u00/oracle/standbydb/redo03.log' ) SIZE 512 M  REUSE
 DATAFILE
  '/u00/oracle/standbydb/system01.dbf'
 CHARACTER SET ZHS16GBK

contents of Memory Script:
{
   set newname for tempfile  1 to
 "/u00/oracle/standbydb/temp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "/u00/oracle/standbydb/undotbs01.dbf";
   catalog clone datafilecopy  "/u00/oracle/standbydb/sysaux01.dbf";
   catalog clone datafilecopy  "/u00/oracle/standbydb/users01.dbf";
   catalog clone datafilecopy  "/u00/oracle/standbydb/example01.dbf";
   catalog clone datafilecopy  "/u00/oracle/standbydb/newdb.dbf";
   catalog clone datafilecopy  "/u00/oracle/standbydb/rman.dbf";
   catalog clone datafilecopy  "/u00/oracle/standbydb/toto.dbf";
   catalog clone datafilecopy  "/u00/oracle/standbydb/web.dbf";
   catalog clone datafilecopy  "/u00/oracle/standbydb/wkyj.dbf";
   catalog clone datafilecopy  "/u00/oracle/standbydb/zlktest.dbf";
   catalog clone datafilecopy  "/u00/oracle/standbydb/lizi.dbf";
   switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u00/oracle/standbydb/temp01.dbf in control file
cataloged datafile copy
datafile copy filename=/u00/oracle/standbydb/undotbs01.dbf recid=1 stamp=716749754
cataloged datafile copy
datafile copy filename=/u00/oracle/standbydb/sysaux01.dbf recid=2 stamp=716749754
cataloged datafile copy
datafile copy filename=/u00/oracle/standbydb/users01.dbf recid=3 stamp=716749754
cataloged datafile copy
datafile copy filename=/u00/oracle/standbydb/example01.dbf recid=4 stamp=716749755
cataloged datafile copy
datafile copy filename=/u00/oracle/standbydb/newdb.dbf recid=5 stamp=716749755
cataloged datafile copy
datafile copy filename=/u00/oracle/standbydb/rman.dbf recid=6 stamp=716749755
cataloged datafile copy
datafile copy filename=/u00/oracle/standbydb/toto.dbf recid=7 stamp=716749755
cataloged datafile copy
datafile copy filename=/u00/oracle/standbydb/web.dbf recid=8 stamp=716749755
cataloged datafile copy
datafile copy filename=/u00/oracle/standbydb/wkyj.dbf recid=9 stamp=716749755
cataloged datafile copy
datafile copy filename=/u00/oracle/standbydb/zlktest.dbf recid=10 stamp=716749755
cataloged datafile copy
datafile copy filename=/u00/oracle/standbydb/lizi.dbf recid=11 stamp=716749755
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=716749754 filename=/u00/oracle/standbydb/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=716749754 filename=/u00/oracle/standbydb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=716749754 filename=/u00/oracle/standbydb/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=716749755 filename=/u00/oracle/standbydb/example01.dbf
datafile 6 switched to datafile copy
input datafile copy recid=5 stamp=716749755 filename=/u00/oracle/standbydb/newdb.dbf
datafile 7 switched to datafile copy
input datafile copy recid=6 stamp=716749755 filename=/u00/oracle/standbydb/rman.dbf
datafile 8 switched to datafile copy
input datafile copy recid=7 stamp=716749755 filename=/u00/oracle/standbydb/toto.dbf
datafile 9 switched to datafile copy
input datafile copy recid=8 stamp=716749755 filename=/u00/oracle/standbydb/web.dbf
datafile 10 switched to datafile copy
input datafile copy recid=9 stamp=716749755 filename=/u00/oracle/standbydb/wkyj.dbf
datafile 11 switched to datafile copy
input datafile copy recid=10 stamp=716749755 filename=/u00/oracle/standbydb/zlktest.dbf
datafile 12 switched to datafile copy
input datafile copy recid=11 stamp=716749755 filename=/u00/oracle/standbydb/lizi.dbf
contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 2010-04-19 17:10:06
RMAN>
RMAN>
RMAN> exit

Recovery Manager complete.
[oracle@db-standby ~]$ sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Apr 19 17:12:33 2010
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown abort
ORACLE instance shut down.
SQL>
SQL> startup
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size                  2089400 bytes
Variable Size             264244808 bytes
Database Buffers          801112064 bytes
Redo Buffers                6295552 bytes
Database mounted.
Database opened.
SQL>
SQL>
SQL>
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@db-standby ~]$
[oracle@db-standby ~]$
[oracle@db-standby ~]$ exit
logout
[root@db-standby ~]# exit
logout
阅读(3839) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~