您的位置:首页 > 数据库 > Oracle

Oracle学习笔记:创建physical standby

2009-03-06 13:36 507 查看
基本概念:

1.保护模式:最大保护、最大性能、最高可用。默认为 最大性能。

2.物理备机、逻辑备机:各有千秋

3.online、archived、standby redo日志

4.日志传输、日志应用、角色切换服务

5.dg是企业版的特性。可以通过sqlplus、dbmgrl、oem操作、部署dg

软硬件要求:

1.同硬件平台

2.同os

3.同oracle企业版

primary必要设置:

1.database必须处于archivelog模式

2.database必须处于force logging模式

3.dg内的每个成员必须具有pwdsid.ora文件,且密码相同

4.对于最大保护 和 最大可用 模式,必须设置standby database创建和primary database 相同size的standby redo log文件。推荐:在primary上也进行类似设置

5.初始化参数primary:

db_name=dbname  --dg内的所有成员必须相同

db_unique_name=pridbuniquename  --dg内每个成员的唯一名称

log_archive_format=arc_sid_%s_%t_%r  --redo归档日志的格式,dg内最好格式一致

log_archive_config='dg_config=(priservicename ,stdservicename )'  --必须设置dg所有成员

standby_file_management=auto  --standby对应于primary数据文件的处理:自动处理

log_archive_dest_n='location=pathname'  --必须要有一个本地归档路径

log_archive_dest_m='service=stdservicename db_unique_name=stddbuniquename [lgwr] [async]'  --必须要有一个活动的standby目标

--以下是primary转化为standby时起作用的

fal_server=stdservicename  --角色转化时,standby变为primary

fal_client=priservicename  --角色转化时,primary变为standby

db_file_name_convert='stdfmt','prifmt'  --standby从primary接受的数据文件命名规则

log_file_name_convert='stdfmt','prifmt'  --standby从primary接受的日志文件命名规则

6.初始化参数standby:

db_name=dbname  --dg内的所有成员必须相同

db_unique_name=stddbuniquename  --dg内每个成员的唯一名称

log_archive_format=arc_sid_%s_%t_%r  --redo归档日志的格式,dg内最好格式一致

log_archive_config='dg_config=(priservicename ,stdservicename )'  --必须设置dg所有成员

standby_file_management=auto  --standby对应于primary数据文件的处理:自动处理。在standby上设置有效

log_archive_dest_n='location=pathname'  --必须要有一个本地归档路径

log_archive_dest_m='service=priservicename db_unique_name=pridbuniquename [lgwr] [async]'  --必须要有一个活动的standby目标

--以下是standby转化为primary时起作用的

fal_server=priservicename  --角色转化时,standby变为primary

fal_client=stdservicename  --角色转化时,primary变为standby

db_file_name_convert='prifmt','stdfmt'  --standby从primary接受的数据文件命名规则。在standby上设置有效

log_file_name_convert='prifmt','stdfmt'  --standby从primary接受的日志文件命名规则。在standby上设置有效

LOG_ARCHIVE_DEST_[1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10] =
{ null_string | LOCATION=path_name | SERVICE=service_name }  --path_name可以设置成USE_DB_RECOVERY_FILE_DEST
[ { MANDATORY | OPTIONAL } ]  --通过使用MANDATORY可以强制rts服务进程必须等待目标standby归档日志传输成功才可切换日志
[
REOPEN[=seconds] ]  --Specifies the minimum number of seconds before
the archiver processes (ARCn) or the log writer process (LGWR) should
try again to access a previously failed destination. The default is 300
seconds.
[ DELAY[=minutes] ]  --cannot set the DELAY attribute for a logical standby database destination,default is 30 minutes
[ NOREGISTER ]  --表明该dest不是dg的一部分
[ TEMPLATE=template] ]
[ ALTERNATE=destination ]  --格式LOG_ARCHIVE_DEST_n,主要是解决mandatory带来的负面影响
[ DEPENDENCY=destination ]  --格式LOG_ARCHIVE_DEST_n,强制实施各目标standby的优先顺序
[ MAX_FAILURE=count ]  --和reopen配合,设置primary尝试次数
[ ARCH | LGWR ]  --通常在最大性能模式下用 arch进程 执行日志传输,其他情况下均为lgwr
[ SYNC | ASYNC
]  --network I/O is to be done synchronously or asynchronously when
archival is performed using the log writer process (LGWR) and the
network server (LNSn) processes.
[ AFFIRM | NOAFFIRM ]  --synchronous or asynchronous disk I/O
[ NET_TIMEOUT=seconds ]  --The default is 180 seconds.
[ VALID_FOR=(redo_log_type,database_role) ]  --定义日志传输的制约因素
[{ DB_UNIQUE_NAME }]  --Specifies a unique name for the database at this destination.
[
VERIFY ]  --Indicates if an archiver (ARCn) process should scan and
verify the correctness of the contents of a completed archived redo log
file, either local or remote, after successfully completing the
archival operation. By default, archived redo log files are not
verified.
}

如果设置mandatory,就必须设置alternate,也需要设置reopen 和 max_failure

如果欲定义各目标的dest顺序,就需要设置dependency

通过affirm来保证redo日志在各dest上写入完成,来达到无损保护,同时配置gwr sync

操作步骤:

Section 3.2.1 Create a Backup Copy of the Primary Database Datafiles Primary

Section 3.2.2 Create a Control File for the Standby Database Primary  --非常重要的一步:他用来产生用于standby数据库的控制文件。通过alter database create standby controlfile as 'fullpathfilename',他实质上会产生一条记录到rman元数据库中,并且被rman所用!

Section 3.2.3 Prepare an Initialization Parameter File for the Standby Database Primary

Section 3.2.4 Copy Files from the Primary System to the Standby System Primary

Section 3.2.5 Set Up the Environment to Support the Standby Database Standby

Section 3.2.6 Start the Physical Standby Database Standby

Section 3.2.7 Verify the Physical Standby Database Is Performing Properly Standby

基本的管理:

设置保护模式:在primary上,mount状态:alter database set standby database to maximize {performance|avialability|protection}

添加standby logfile 组、成员:alter database add standby logfile [member] filespec,...

删除standby logfile 组、成员:alter database drop standby logfile [member] filespec,...

激活standby 的recover管理会话、根据初始化参数应用redo日志:alter database recover managed standby database [disconnect from session]

激活standby 的recover管理会话、立即应用redo日志:alter database recover managed standby database nodelay [disconnect from session]

激活standby 的real-time recover管理会话:alter database recover managed standby database using current logfile [disconnect from session]

激活standby 的recover管理会话,还原到某个scn:alter database recover managed standby database until change n [disconnect from session]

取消standby 的recover管理会话:alter database recover managed standby database cancel [immediate | [wait|nowait] ]

终止standy角色功能、结束recover管理会话,准备转化为primary:alter database recover managed standby database finish [force] [wait|nowait]

转化physical为logical standby:alter database recover to logical standby {dbname}--注意:需要在primary上执行dbms_lgstdby.build过程

激活standby 为primary:alter database active [physical|logical] standby database [finish apply--只能用于logical standby database]

开始logical 的redo日志应用:alter database start logical standby apply

结束logical 的redo日志应用:alter database {stop|abort} logical standby apply

将游离于dg之外的primary变为phyisical standby:alter database convert to physical standby

常见错误及处理:

rman 在duplicate target database for standby时提示找不到所需文件:请检查primary数据库是否:alter database create standby controlfile as filespec

rman 在duplicate target database for standby时提示创建错误:请检查standby数据库相关的路径是否有效

redo文件传输失败:检查primary、standby的log_archive_config='dg_config=(pridbuniquename,pridbuniquename)'、db_unique_name、log_archive_dest_n、log_archive_dest_state_n参数是否设置正确。尤其是log_archive_dest_n中的 arch|lgwr 等设置!

standby不能运行于real-time模式,该模式要求standby数据库必须具有standby redo log文件

standby对应的服务不可用:设置静态监听并重启监听
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: