Oracle 11g物理备用数据库“实况克隆”详解
2009-05-22 13:14:53 来源:WEB开发网相比Oracle 8i和Oracle 9i,Oracle 11g在数据库备份方面做出了极大的改善,特别是作为Oracle最大可用性架构(MAA)一部分的真正应用集群(RAC)特性。Oracle 11g现在创建一个备用数据库变得更加简单了,因为恢复管理器(RMAN)支持直接从主数据库使用DUPLICATE DATABASE命令集通过网络克隆一个备用数据库,只要目标数据库是活动的即可。这意味着再也不用先生成,再传输,最后在备用数据库上通过复杂的手工方式还原和恢复主数据库的RMAN备份集了,相反,RMAN在主站点上自动生成一个转换脚本在内存中,然后在备用站点上使用这个脚本管理克隆操作,实际上不用DBA进行任何干预。
下文将集中精力讲解备用数据库“实况克隆”特性。笔者的硬件基本情况是:双核AMD Athlon 64位CPU(Winchester 420),4GB内存,主机运行的是Windows xp系统,运行VMWare Server 1.0.8访问访问虚拟数据库服务器环境,每个虚拟机使用1个CPU,1200M内存,我选择Oracle Enterprise Linux (OEL) 4.5.1(Linux内核版本2.6.9-55.0.0.0.2.ELsmp)作为虚拟机客户端操作系统。
每个VMWare虚拟机配置好后,在每个虚拟机的/etc/hosts文件中添加合适的条目,让主站点(training)和备用站点(11gStdby)之间建立起网络连接,然后在每个节点上都安装Oracle 11g数据库,最后,在主站点上创建好标准的11g R1种子数据库,包括标准的示例方案。这个数据库的ORACLE_SID是orcl,接下来就可以开始执行实况克隆操作了。
克隆前准备工作:调整主数据库
在克隆主数据库到对应的备用环境中之前,我需要对主数据库做一些调整,下面的步骤未做特别说明没有先后顺序,只要在发出DUPLICATE DATABASE命令前这些步骤都执行完了即可,在克隆操作过程中应该没有什么让人意外的东西出现。
强制记录所有的交易
大多数组织实施数据卫士配置的主要原因是保证所有交易都不丢失,但遗憾的是,默认情况下,Oracle数据库是运行在NOFORCE LOGGING模式下的,这意味着对对象的改变可能丢失,因为他们的存储属性被设为NOLOGGING,为了确保所有的改变都被记录下来,我将执行ALTER DATABASE FORCE LOGGING命令,这个命令需要在执行ALTER DATABASE ARCHIVELOG命令将数据库ARCHIVELOG模式前执行,这些命令如清单1所示。
清单1 将主数据库切换到ARCHIVELOG模式
--为归档日志文件设置一个合适的格式
ALTER SYSTEM SET log_archive_format = 'log_%s_%t_%r.arc' SCOPE=SPFILE;
--设置新的DB_UNIQUE_NAME参数,它不能动态修改
ALTER SYSTEM SET db_unique_name = 'orcl' SCOPE=SPFILE;
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE FORCE LOGGING;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
创建备用重做日志组
自从Oracle 9i R2开始支持备用重做日志(standby redo log 即SRL)组开始,Oracle就建议配置它,SRL对于实时应用(Real Time Apply)特性是需要的,或DBA想要实现重做日志串联目的时也需要,除此之外,它任然是备用数据库配置选项。Oracle 11g另一个优点是如果SRL在主数据库上已经配置好,那么DUPLICATE DATABASE命令将会在备用数据库上自动创建它们。清单2显示了我在主数据库上创建SRL的命令,注意我也使用了多个重SRL文件保护整个SRL组,避免数据丢失,这一点和在线重做日志组类似。
清单2 在主数据库上创建备用重做日志文件
ALTER DATABASE
ADD STANDBY LOGFILE
'/u01/app/oracle/oradata/orcl/srl01.log'
SIZE 50M
REUSE;
ALTER DATABASE
ADD STANDBY LOGFILE
'/u01/app/oracle/oradata/orcl/srl02.log'
SIZE 50M
REUSE;
ALTER DATABASE
ADD STANDBY LOGFILE
'/u01/app/oracle/oradata/orcl/srl03.log'
SIZE 50M
REUSE;
文件名转换
一般情况下,备用数据库都是创建在与主数据库不同的主机上的,否则,在灾难中主备数据库都有可能受到危害,最佳做法是将对应的备用数据库的目录和文件名都弄成一样,但如果遇到挂载点不一样时,目录名需要修改,这个时候就需要使用DB_FILE_NAME_CONVERT和LOG_FILE_NAME_CONVERT初始化参数进行转换了。
修改主站点初始化参数
在主数据库上设置下列初始化参数确保DUPLICATE DATABASE命令能够一样配置备用数据库,我在清单3中详细列出了这些初始化参数设置:
(1)DB_UNIQUE_NAME
我通过这个参数为主数据库定义一个唯一的实例名,这个参数值使得区分“原始”主数据库和备用数据库变得更加简单,因为这是一个静态参数,我在清单1中已经将其设置为SCOPE=SPFILE,它将在主数据库实例启动时生效。
(2)LOG_ARCHIVE_CONFIG
这个参数控制主或备用数据库是否应该接受和/或发送来自远程源的归档重做日志,它允许我们包含所有主备数据库,因为它在配置中列出了所有数据库的DB_UNIQUE_NAME值,我将其设置为目前我的数据卫士数据库orcl和stdby。
(3)STANDBY_FILE_MANAGEMENT
我将这个参数设置问为auto了,这样主数据库上发生什么操作,备用数据库上就会跟着发生什么操作,如主数据库上创建一个文件,备用数据库上也将创建一个相同的文件,删除主数据库上一个已有文件,备用数据库上也做对应的删除。如新增一个在线重做日志文件组或删除一个表空间。
(4)LOG_ARCHIVE_DEST_n
这个控制是从主数据库上传输归档重做日志到物理备用数据库的关键参数,我将设置两个归档目标:
1. 目标LOG_ARCHIVE_DEST_1指定主数据库归档重做日志的物理位置,注意我们使用了闪回恢复区作为目标。
2. 目标LOG_ARCHIVE_DEST_2指定了对应的备用数据库实例(stdby)的网络服务地址,这个参数确保归档重做日志自动传输到备用站点。
对于这个归档重做日志传输参数我还可以指定另外两个指令:
◆当数据库是以特定角色激活时,指令VALID_FOR大大简化了重做日志传输时的类型,当主备数据库角色不同时,在传输重做日志时这是最关键的参数,表1列出了这个参数允许的值。
表1 VALID_FOR指令值 | |
设置 | 含义 |
ALL_LOGFILES | (默认)目标使用在线或备用重做日志文件 |
ONLINE_LOGFILE | 目标仅适用于在线归档重做日志文件 |
STANDBY_LOGFILE | 目标仅适用于备用重做日志文件 |
ALL_ROLES | 当数据库以主或备用角色运行时(默认)目标都是有效的 |
PRIMARY_ROLE | 当数据库以主角色运行时目标是有效的 |
STANDBY_ROLE | 当数据库以备用角色运行时目标是有效的 |
◆也可以设置合适的重做日志传输模式(redo transport mode)值指定归档重做日志从主数据库传输到备用数据库,表2列出了这个指令允许的值。
表2 重做日志传输模式 | |
设置 | 含义 |
ASYNC | 在事务提交前可能不是所有的目标都接受了传输的重做日志(默认值) |
SYNC | 在事务提交前所有目标必须接受传输的重做日志 |
AFFIRM | 仅当重做数据被写入到备用重做日志后,目标才确认已收到,含有SYNC含义 |
NOAFFIRM | 当重做数据写入到备用重做日志前目标就可以确认收到,含有ASYNC含义 |
网络配置修改
最后,我需要确保主数据库和备用数据库之间能够通过网络通信,唯一需要变化的就是在主数据库本地命名配置文件(TNSNAMES.ORA)中加上备用数据库的实例,备用数据库的LISTENER.ORA配置文件也需要一个备用数据库实例的静态监听器,这些变化如清单4所示。
清单3 在主数据库上设置合适的初始化参数值
ALTER SYSTEM SET log_archive_dest_1 = 'LOCATION=/u01/app/oracle/flash_recovery_area/ORCL/ DB_UNIQUE_NAME=orcl VALID_FOR=(ALL_LOGFILES,ALL_ROLES)';
ALTER SYSTEM SET log_archive_dest_state_1 = 'ENABLE';
ALTER SYSTEM SET log_archive_dest_2 = 'SERVICE=stdby ASYNC DB_UNIQUE_NAME=stdby VALID_FOR=(ONLINE_LOGFILE,PRIMARY_ROLE)';
ALTER SYSTEM SET log_archive_dest_state_2 = 'ENABLE';
ALTER SYSTEM SET standby_file_management = 'AUTO';
ALTER SYSTEM SET log_archive_config = 'DG_CONFIG=(orcl,stdby)';
清单4 网络配置文件修改
#在主数据库实例上添加一个备用数据库条目
STDBY =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 11gStdby)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = stdby)
)
)
#使用备用数据库实例的静态引用设置备用数据库监听器
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = stdby)
(ORACLE_HOME = /u01/app/oracle/product/11.1.0/db_1)
(SID_NAME = stdby)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 11gStdby)(PORT = 1521))
准备克隆:准备备用站点
现在主站点已经准备好可以克隆了,在对应的备用站点上也需要做一些对应的调整:
创建必要的目录
需要为数据库控制文件、数据文件、在线重做日志文件和备用重做日志文件创建必要的目录,我还为数据库的审核跟踪创建了合适的目录。
设置密码文件
因为主数据库要和备用数据库进行通信时需要使用远程认证,我将会使用orapwd工具创建一个新的密码文件,确保SYS的密码和主数据库匹配(注意我可能会直接从主数据库拷贝到备用数据库)。
创建备用初始化参数文件
最后,我需要创建一个初始化参数文件(PFILE),仅允许我启动备用数据库实例,它只需要一个参数:DB_NAME。当DUPLICATE DATABASE命令脚本执行完毕后,它将会创建一个服务端参数文件(SPFILE),它仅包括合适的初始化参数设置。
在清单5中我解释了这些命令和临时备用数据库初始化参数,为了开启DUPLICATE DATABASE克隆操作,我将启动备用站点的监听器,然后使用前面创建的PFILE初始化参数文件将备用数据库实例启动到NOMOUNT状态。
$> export ORACLE_SID=stdby
$> sqlplus / as sysdba
SQL> startup nomount pfile='/home/oracle/init_stdby.ora';
清单5 备用数据库临时初始化参数文件
######
# File: initstdby.ora
# Purpose: "Dummy" PFILE to enable startup of standby database
# instance during DUPLICATE DATABASE over the network
#####
DB_NAME=stdby
通过DUPLICATE DATABASE克隆备用数据库
从主数据库的RMAN会话环境启动DUPLICATE DATABASE命令,前面我已经提到过,Oracle 11g中DUPLICATE DATABASE命令最引人注目的改变是它可以通过网络直接将主数据库克隆到备用数据库站点。作为设置备用数据库的一部分,我也可以为所有需要的初始化参数指定值,DUPLICATE DATABASE将会在备用数据库上创建一个新的SPFILE。
清单6显示了使用DUPLICATE DATABASE命令进行克隆的完整语句,注意我添加了下面这样一些额外的参数,可能和主数据库的参数稍有不同:
(1)DB_UNIQUE_NAME
我将这个参数的值设为stdby了。
(2)CONTROL_FILES
我只为备用数据库创建了一个控制文件,在克隆完毕后我会复制多个。
(3)FAL_CLIENT和FAL_SERVER
这两个参数确定哪个数据库服务分别担任FAL(fetch archive log)客户端和服务器,例如,无论何时,当主数据库和备用数据库之间的网络断掉后,或如果备用数据库已经关闭相当长一段时间,归档重做日志可能就不会传输到备用服务器上。这种情况叫做归档日志空白(archive log gap),这两个FAL服务名确定了由哪个服务器(FAL_SERVER)维护所有归档重做日志组主列表,由它为FAL_CLIENT提供可能发生的归档日志空白解决方案。在我们的数据卫士设置中,将备用服务器配置为FAL_CLIENT,将主服务器配置为FAL_SERVER。
(4)LOG_FILE_NAME_CONVERT
我已经使用这个参数将主数据库的归档重做日志和备用重做日志的目标做了翻译,确保在克隆过程中RMAN能够自动在备用数据库上创建恰当的副本。
(5)LOG_ARCHIVE_DEST_n
和主数据库一样,我也设置了两个归档日志目标:一个主目标LOG_ARCHIVE_DEST_1和次要目标LOG_ARCHIVE_DEST_2。将来主备站点角色发生交换后,将由次要目标中的归档重做日志传输到原始主数据库中。
最后,让我们开始克隆吧!首先在主数据库服务器上启动一个RMAN会话,以target连接到主数据库,以auxiliary连接到备用数据库:
oracle@training> rman target / auxiliary sys/oracle@stdby
Recovery Manager: Release 11.1.0.6.0 - Production on Tue Apr 14 19:29:25 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1210321736)
connected to auxiliary database: STDBY (not mounted)
为了加快处理过程,我将会通过ALLOCATE CHANNEL命令创建两个auxiliary通道和两个normal通道,并在相同的RUN块中使用DUPLICATE DATABASE开始克隆,下面是RMAN命令块所做的事情:
1. 使用主数据库服务器的参数文件作为模版为备用数据库创建了一个新的SPFILE,但在DUPLICATE DATABASE运行块中的SET命令中做了适当的修改。
2. 然后关闭备用数据库,再使用新的SPFILE启动到NOMOUNT模式。
3. 接下来创建主数据库控制文件的拷贝,修改它让所有文件名都与备用数据库匹配,拷贝新的控制文件到备用数据库上,然后使用新的控制文件将数据库启动到MOUNT模式。
4. 然后在备用数据库上直接创建主数据库数据文件的镜像拷贝备份。
5. 最后,使用主数据库上当前的归档重做日志在备用数据库上执行必要的恢复,并将备用数据库置为管理恢复模式。
我在清单7中列出了克隆操作的结果,它显示了RMAN命令的输出内容,清单8列出了克隆过程中产生的备用数据库的警告日志条目。
清单7 来自一个成功的备用数据库克隆操作的输出内容
[oracle@training ~]$ rman target / auxiliary sys/oracle@stdby
Recovery Manager: Release 11.1.0.6.0 - Production on Sat Apr 18 06:25:07 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1210321736)
connected to auxiliary database: STDBY (not mounted)
RMAN> RUN {
ALLOCATE CHANNEL d1 TYPE DISK;
ALLOCATE CHANNEL d2 TYPE DISK;
ALLOCATE AUXILIARY CHANNEL cnv1 TYPE DISK;
ALLOCATE AUXILIARY CHANNEL cnv2 TYPE DISK;
DUPLICATE TARGET DATABASE
FOR STANDBY
FROM ACTIVE DATABASE
DORECOVER
SPFILE
SET db_unique_name='stdby'
SET control_files='/u01/app/oracle/oradata/orcl/control01.ctl'
SET log_file_name_convert='/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/stdby/'
SET log_archive_dest_1='location=/u01/app/oracle/flash_recovery_area/STDBY/ valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=stdby'
SET log_archive_dest_2='service=orcl ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=orcl'
SET fal_client='stdby'
SET fal_server='orcl'
SET standby_file_management='AUTO'
SET log_archive_config='dg_config=(orcl,stdby)'
NOFILENAMECHECK;
}
2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21>
using target database control file instead of recovery catalog
allocated channel: d1
channel d1: SID=126 device type=DISK
allocated channel: d2
channel d2: SID=120 device type=DISK
allocated channel: cnv1
channel cnv1: SID=97 device type=DISK
allocated channel: cnv2
channel cnv2: SID=96 device type=DISK
Starting Duplicate Db at 18-APR-09
contents of Memory Script:
{
backup as copy reuse
file '/u01/app/oracle/product/11.1.0/db_1/dbs/orapworcl' auxiliary format
'/u01/app/oracle/product/11.1.0/db_1/dbs/orapwstdby' file
'/u01/app/oracle/product/11.1.0/db_1/dbs/spfileorcl.ora' auxiliary format
'/u01/app/oracle/product/11.1.0/db_1/dbs/spfilestdby.ora' ;
sql clone "alter system set spfile= ''/u01/app/oracle/product/11.1.0/db_1/dbs/spfilestdby.ora''";
}
executing Memory Script
Starting backup at 18-APR-09
Finished backup at 18-APR-09
sql statement: alter system set spfile= ''/u01/app/oracle/product/11.1.0/db_1/dbs/spfilestdby.ora''
contents of Memory Script:
{
sql clone "alter system set db_unique_name =
''stdby'' comment=
'''' scope=spfile";
sql clone "alter system set control_files =
''/u01/app/oracle/oradata/orcl/control01.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set log_file_name_convert =
''/u01/app/oracle/oradata/orcl/'', ''/u01/app/oracle/oradata/stdby/'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_dest_1 =
''location=/u01/app/oracle/flash_recovery_area/STDBY/ valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=stdby'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_dest_2 =
''service=orcl ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=orcl'' comment=
'''' scope=spfile";
sql clone "alter system set fal_client =
''stdby'' comment=
'''' scope=spfile";
sql clone "alter system set fal_server =
''orcl'' comment=
'''' scope=spfile";
sql clone "alter system set standby_file_management =
''AUTO'' comment=
'''' scope=spfile";
sql clone "alter system set log_archive_config =
''dg_config=(orcl,stdby)'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount ;
}
executing Memory Script
sql statement: alter system set db_unique_name = ''stdby'' comment= '''' scope=spfile
sql statement: alter system set control_files = ''/u01/app/oracle/oradata/orcl/control01.ctl'' comment= '''' scope=spfile
sql statement: alter system set log_file_name_convert = ''/u01/app/oracle/oradata/orcl/'', ''/u01/app/oracle/oradata/stdby/'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_1 = ''location=/u01/app/oracle/flash_recovery_area/STDBY/ valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=stdby'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_2 = ''service=orcl ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=orcl'' comment= '''' scope=spfile
sql statement: alter system set fal_client = ''stdby'' comment= '''' scope=spfile
sql statement: alter system set fal_server = ''orcl'' comment= '''' scope=spfile
sql statement: alter system set standby_file_management = ''AUTO'' comment= '''' scope=spfile
sql statement: alter system set log_archive_config = ''dg_config=(orcl,stdby)'' comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 422678528 bytes
Fixed Size 1300324 bytes
Variable Size 121637020 bytes
Database Buffers 293601280 bytes
Redo Buffers 6139904 bytes
contents of Memory Script:
{
backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/orcl/control01.ctl';
sql clone 'alter database mount standby database';
}
executing Memory Script
Starting backup at 18-APR-09
channel d1: starting datafile copy
copying standby control file
output file name=/home/oracle/snapcf_orcl.f tag=TAG20090418T062548 RECID=36 STAMP=684483962
channel d1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 18-APR-09
sql statement: alter database mount standby database
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/orcl/temp01.dbf";
switch clone tempfile all;
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";
set newname for datafile 5 to
"/u01/app/oracle/oradata/orcl/example01.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" datafile
5 auxiliary format
"/u01/app/oracle/oradata/orcl/example01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/orcl/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 18-APR-09
channel d1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
channel d2: starting datafile 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=TAG20090418T062611 RECID=0 STAMP=0
channel d2: datafile copy complete, elapsed time: 00:01:15
channel d2: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
output file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf tag=TAG20090418T062611 RECID=0 STAMP=0
channel d1: datafile copy complete, elapsed time: 00:01:54
channel d1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
output file name=/u01/app/oracle/oradata/orcl/example01.dbf tag=TAG20090418T062611 RECID=0 STAMP=0
channel d1: datafile copy complete, elapsed time: 00:00:15
channel d1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
output file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf tag=TAG20090418T062611 RECID=0 STAMP=0
channel d2: datafile copy complete, elapsed time: 00:01:01
output file name=/u01/app/oracle/oradata/orcl/users01.dbf tag=TAG20090418T062611 RECID=0 STAMP=0
channel d1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 18-APR-09
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "/u01/app/oracle/flash_recovery_area/ORCL/log_109_1_682541003.arc" auxiliary format
"/u01/app/oracle/flash_recovery_area/STDBY/log_109_1_682541003.arc" ;
catalog clone archivelog "/u01/app/oracle/flash_recovery_area/STDBY/log_109_1_682541003.arc";
switch clone datafile all;
}
executing Memory Script
Starting backup at 18-APR-09
channel d1: starting archived log copy
input archived log thread=1 sequence=109 RECID=110 STAMP=684484146
output file name=/u01/app/oracle/flash_recovery_area/STDBY/log_109_1_682541003.arc RECID=0 STAMP=0
channel d1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 18-APR-09
cataloged archived log
archived log file name=/u01/app/oracle/flash_recovery_area/STDBY/log_109_1_682541003.arc RECID=1 STAMP=684484135
datafile 1 switched to datafile copy
input datafile copy RECID=36 STAMP=684484136 file name=/u01/app/oracle/oradata/orcl/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=37 STAMP=684484136 file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=38 STAMP=684484136 file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=39 STAMP=684484136 file name=/u01/app/oracle/oradata/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=40 STAMP=684484136 file name=/u01/app/oracle/oradata/orcl/example01.dbf
contents of Memory Script:
{
set until scn 4021704;
recover
standby
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 18-APR-09
starting media recovery
archived log for thread 1 with sequence 109 is already on disk as file /u01/app/oracle/flash_recovery_area/STDBY/log_109_1_682541003.arc
archived log file name=/u01/app/oracle/flash_recovery_area/STDBY/log_109_1_682541003.arc thread=1 sequence=109
media recovery complete, elapsed time: 00:00:01
Finished recover at 18-APR-09
Finished Duplicate Db at 18-APR-09
released channel: d1
released channel: d2
清单8 来自一个成功的备用数据库克隆操作的警告日志
Sat Apr 18 06:24:23 2009
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Picked latch-free SCN scheme 2
Using LOG_ARCHIVE_DEST_1 parameter default value as /u01/app/oracle/product/11.1.0/db_1/dbs/arch
Autotune of undo retention is turned on.
IMODE=BR
ILAT =12
LICENSE_MAX_USERS = 0
SYS auditing is disabled
Starting up ORACLE RDBMS Version: 11.1.0.6.0.
Using parameter settings in client-side pfile /home/oracle/initstdby.ora on machine 11gStdby
System parameters with non-default values:
db_name = "stdby"
Sat Apr 18 06:24:25 2009
PMON started with pid=2, OS id=8334
Sat Apr 18 06:24:25 2009
...
(为了简洁,这里有所删减)
...
Sat Apr 18 06:24:29 2009
MMON started with pid=14, OS id=8362
ORACLE_BASE from environment = /u01/app/oracle
Sat Apr 18 06:24:29 2009
MMNL started with pid=15, OS id=8364
Sat Apr 18 06:24:52 2009
Using STANDBY_ARCHIVE_DEST parameter default value as /u01/app/oracle/product/11.1.0/db_1/dbs/arch
destination database instance is 'started' not 'mounted'
Sat Apr 18 06:25:09 2009
ALTER SYSTEM SET spfile='/u01/app/oracle/product/11.1.0/db_1/dbs/spfilestdby.ora' SCOPE=MEMORY;
ALTER SYSTEM SET db_unique_name='stdby' SCOPE=SPFILE;
ALTER SYSTEM SET control_files='/u01/app/oracle/oradata/orcl/control01.ctl' SCOPE=SPFILE;
ALTER SYSTEM SET log_file_name_convert='/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/stdby/' SCOPE=SPFILE;
ALTER SYSTEM SET log_archive_dest_1='location=/u01/app/oracle/flash_recovery_area/STDBY/ valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=stdby' SCOPE=SPFILE;
ALTER SYSTEM SET log_archive_dest_2='service=orcl ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=orcl' SCOPE=SPFILE;
ALTER SYSTEM SET fal_client='stdby' SCOPE=SPFILE;
ALTER SYSTEM SET fal_server='orcl' SCOPE=SPFILE;
ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=SPFILE;
ALTER SYSTEM SET log_archive_config='dg_config=(orcl,stdby)' SCOPE=SPFILE;
Shutting down instance: further logons disabled
Stopping background process MMNL
Stopping background process MMON
Shutting down instance (immediate)
License high water mark = 7
alter database close
ORA-1507 signalled during: alter database close...
alter database dismount
ORA-1507 signalled during: alter database dismount...
ARCH: Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
Archive process shutdown avoided: 0 active
Sat Apr 18 06:25:13 2009
Stopping background process VKTM:
ARCH: Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
Archive process shutdown avoided: 0 active
Sat Apr 18 06:25:16 2009
Instance shutdown complete
Sat Apr 18 06:25:16 2009
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
LICENSE_SESSIONS_WARNING = 0
Picked latch-free SCN scheme 2
Autotune of undo retention is turned on.
IMODE=BR
ILAT =18
LICENSE_MAX_USERS = 0
SYS auditing is disabled
Starting up ORACLE RDBMS Version: 11.1.0.6.0.
Using parameter settings in server-side spfile /u01/app/oracle/product/11.1.0/db_1/dbs/spfilestdby.ora
System parameters with non-default values:
processes = 150
sga_target = 400M
control_files = "/u01/app/oracle/oradata/orcl/control01.ctl"
log_file_name_convert = "/u01/app/oracle/oradata/orcl/"
log_file_name_convert = "/u01/app/oracle/oradata/stdby/"
db_block_size = 8192
compatible = "11.1.0.0.0"
log_archive_config = "dg_config=(orcl,stdby)"
log_archive_dest_1 = "location=/u01/app/oracle/flash_recovery_area/STDBY/ valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=stdby"
log_archive_dest_2 = "service=orcl ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=orcl"
log_archive_dest_state_1 = "ENABLE"
log_archive_dest_state_2 = "ENABLE"
log_archive_max_processes= 4
log_archive_format = "log_%s_%t_%r.arc"
fal_client = "stdby"
fal_server = "orcl"
db_recovery_file_dest = "/u01/app/oracle/flash_recovery_area"
db_recovery_file_dest_size= 8G
standby_file_management = "AUTO"
undo_tablespace = "UNDOTBS1"
remote_login_passwordfile= "EXCLUSIVE"
db_domain = ""
dispatchers = "(PROTOCOL=TCP) (SERVICE=orclXDB)"
audit_file_dest = "/u01/app/oracle/admin/orcl/adump"
audit_trail = "DB"
db_name = "orcl"
db_unique_name = "stdby"
open_cursors = 300
pga_aggregate_target = 150M
diagnostic_dest = "/u01/app/oracle"
Sat Apr 18 06:25:19 2009
PMON started with pid=2, OS id=8395
Sat Apr 18 06:25:19 2009
...
(为了简洁,这里有所删减)
...
ORACLE_BASE from environment = /u01/app/oracle
Sat Apr 18 06:25:25 2009
RFS connections have been disallowed
alter database mount standby database
Sat Apr 18 06:25:38 2009
Set as converted control file due to db_unique_name mismatch
Changing di2dbun from orcl to stdby
Setting recovery target incarnation to 2
ARCH: STARTING ARCH PROCESSES
Sat Apr 18 06:25:38 2009
ARC1 started with pid=21, OS id=8445
Sat Apr 18 06:25:38 2009
ARC0 started with pid=20, OS id=8443
ARC0: Archival started
ARC1: Archival started
ARC2: Archival started
ARC3: Archival started
ARCH: STARTING ARCH PROCESSES COMPLETE
ARC0: Becoming the 'no FAL' ARCH
ARC0: Becoming the 'no SRL' ARCH
ARC0: Thread not mounted
ARC1: Becoming the heartbeat ARCH
Sat Apr 18 06:25:38 2009
ARC3 started with pid=23, OS id=8449
ARC3: Thread not mounted
Sat Apr 18 06:25:38 2009
ARC2 started with pid=22, OS id=8447
ARC2: Thread not mounted
ARC1: Thread not mounted
Sat Apr 18 06:25:39 2009
Successful mount of redo thread 1, with mount id 1212288222
Physical Standby Database mounted.
Lost write protection disabled
Completed: alter database mount standby database
Sat Apr 18 06:28:56 2009
Switch of datafile 1 complete to datafile copy
checkpoint is 4021609
Switch of datafile 2 complete to datafile copy
checkpoint is 4021608
Switch of datafile 3 complete to datafile copy
checkpoint is 4021656
Switch of datafile 4 complete to datafile copy
checkpoint is 4021701
Switch of datafile 5 complete to datafile copy
checkpoint is 4021679
Using STANDBY_ARCHIVE_DEST parameter default value as /u01/app/oracle/flash_recovery_area/STDBY/
alter database recover datafile list clear
Completed: alter database recover datafile list clear
alter database recover datafile list
1 , 2 , 3 , 4 , 5
Completed: alter database recover datafile list
1 , 2 , 3 , 4 , 5
alter database recover if needed
standby start until change 4021704
Media Recovery Start
Fast Parallel Media Recovery NOT enabled
Managed Standby Recovery not using Real Time Apply
ORA-279 signalled during: alter database recover if needed
standby start until change 4021704
...
alter database recover logfile '/u01/app/oracle/flash_recovery_area/STDBY/log_109_1_682541003.arc'
Media Recovery Log /u01/app/oracle/flash_recovery_area/STDBY/log_109_1_682541003.arc
Incomplete Recovery applied until change 4021704 time 04/18/2009 06:29:05
Media Recovery Complete (stdby)
Completed: alter database recover logfile '/u01/app/oracle/flash_recovery_area/STDBY/log_109_1_682541003.arc'
克隆之后:清除和校验
至此克隆操作执行结束,我需要确保备用数据库从主数据库接收到归档重做日志,为了验证主备数据库确实是联通的,我将在主数据库上执行一次重做日志切换。
SQL﹥ ALTER SYSTEM ARCHIVE LOG CURRENT;
下面是来自备用数据库的警告日志,从中可以看出在线重做日志成功传输并应用到备用数据库上了。
Completed: alter database clear logfile group 6
RFS connections are allowed
Sat Apr 18 06:29:58 2009
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[1]: Assigned to RFS process 8492
RFS[1]: Identified database type as 'physical standby'
RFS LogMiner: Client disabled from further notification
Sat Apr 18 06:35:39 2009
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[2]: Assigned to RFS process 8506
RFS[2]: Identified database type as 'physical standby'
Primary database is in MAXIMUM PERFORMANCE mode
Primary database is in MAXIMUM PERFORMANCE mode
RFS[2]: Successfully opened standby log 4: '/u01/app/oracle/oradata/stdby/srl01.log'
Sat Apr 18 06:36:28 2009
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[3]: Assigned to RFS process 8512
RFS[3]: Identified database type as 'physical standby'
kcrrvslf: active RFS archival for log 4 thread 1 sequence 111
RFS[3]: Successfully opened standby log 5: '/u01/app/oracle/oradata/stdby/srl02.log'
Sat Apr 18 06:42:53 2009
- ››oracle 恢复误删除的表和误更新的表
- ››Oracle分页查询排序数据重复问题
- ››Oracle创建dblink报错:ORA-01017、ORA-02063解决
- ››Oracle 提高SQL执行效率的方法
- ››Oracle 动态查询,EXECUTE IMMEDIATE select into...
- ››Oracle 11g必须开启的服务及服务详细介绍
- ››oracle性能34条优化技巧
- ››oracle数据库生成随机数的函数
- ››Oracle 数据库表空间容量调整脚本
- ››oracle单库彻底删除干净的方法
- ››Oracle创建表空间、创建用户以及授权、查看权限
- ››oracle 中 UPDATE nowait 的使用方法
更多精彩
赞助商链接