你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle 10g data guard 创建全过程

[日期:2012-11-13] 来源:Linux社区  作者:mikixiyou [字体:大 中 小]

7、构建data guard环境

在主库上修改初始化参数文件的部分参数

*.log_archive_config='dg_config=(webdb,webdg)'
这个参数配置了主库和备库的初始化参数db_unique_name的值。

*.log_archive_dest_2='service=webdb_standby lgwr sync affirm valid_for=(online_logfiles,primary_role) db_unique_name=webdg'
*.log_archive_dest_state_2='enable'
这个参数配置了主库采用Oracle net 服务webdb_standby向备库传输日志。webdb_standby是主库的tnsnames.ora文件中的一个条目。

在主库上tnsnames.ora文件中添加两个条目webdb_standby和webdb_primary

WEBDB_STANDBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.15.90)(PORT = 1521))
)
(CONNECT_DATA =
(SID = webdb)
)
)

WEBDB_PRIMARY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.15.89)(PORT = 1521))
)
(CONNECT_DATA =
(SID = webdb)
)
)

在备库上修改初始化参数

*.db_unique_name='webdg'
这个参数是10g中用于定义数据库唯一名称的一个参数,主要在data guard中使用到。以后也可以修改。

*.fal_client='webdb_standby'
*.fal_server='webdb_primary'
这两个参数用于解决主库和备库的日志传输缺口,分别设置为指向备库的oracle net服务名和指向主库的oracle net服务名。这两个服务名定义在备库的tnsnams.ora文件中。

一个FAL(Fetch Archive Log,获取归档日志)请求由MRP进程监测可用归档中的缺口来触发。用来连接回应这个请求的服务器由FAL_SERVER参数指定,你给这个参数设置一个合适的tnsnames别名。这使你的备库可以与主库连接并使用arch进程来传送所缺少的日志。

*.log_archive_config='dg_config=(webdb,webdg)'
这个参数配置了主库和备库的初始化参数db_unique_name的值,和主库保持一致。

*.log_archive_dest_1='location=/u01/app/oratt/archivelog/ valid_for=(all_logfiles,all_roles) db_unique_name=webdg'
这个参数设置从主库传输过来的归档日志的保存目录。

在备库系统上tnsnames.ora文件中也添加两个条目webdb_standby和webdb_primary,它们的内容和主库上的完全一致。

在备库系统上listener.ora文件中,也必须将webdb实例静态注册进去。不能使用动态注册,因为备库实例不会处于open状态。否则在主库上传输日志时会出现ORA-12514错误。

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oratt/product/10.2.0/dbhome_1)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = webdb)
(ORACLE_HOME = /u01/app/oratt/product/10.2.0/dbhome_1)
)
)

 

在主库上使用RMAN全备份数据库和standby用途的控制文件

oratt@serv1:/u01/app/oratt/dbbackup=>webdb$rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Wed Nov 7 15:07:51 2012

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: WEBDB (DBID=3348254801)

RMAN> backup database format '/u01/app/oratt/dbbackup/db%U.%T';

Starting backup at 2012-11-07 15:08:15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=143 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oratt/webdb/system01.dbf
input datafile fno=00002 name=/u01/app/oratt/webdb/undotbs01.dbf
input datafile fno=00003 name=/u01/app/oratt/webdb/sysaux01.dbf
input datafile fno=00004 name=/u01/app/oratt/webdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2012-11-07 15:08:16
channel ORA_DISK_1: finished piece 1 at 2012-11-07 15:08:19
piece handle=/u01/app/oratt/dbbackup/db01npnfn0_1_1.20121107 tag=TAG20121107T150816 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 2012-11-07 15:08:19
channel ORA_DISK_1: finished piece 1 at 2012-11-07 15:08:20
piece handle=/u01/app/oratt/dbbackup/db02npnfn3_1_1.20121107 tag=TAG20121107T150816 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2012-11-07 15:08:20

RMAN> sql 'alter system switch logfile';

sql statement: alter system switch logfile

RMAN> backup current controlfile for standby format '/u01/app/oratt/dbbackup/ctl.standby';

Starting backup at 2012-11-07 15:09:09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including standby control file in backupset
channel ORA_DISK_1: starting piece 1 at 2012-11-07 15:09:09
channel ORA_DISK_1: finished piece 1 at 2012-11-07 15:09:10
piece handle=/u01/app/oratt/dbbackup/ctl.standby tag=TAG20121107T150909 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2012-11-07 15:09:10

备份结果集传到备库所在服务器上,密码文件也可以一块传一份。


在备库上恢复standby控制文件和数据文件

oratt@serv2:/u01/app/oratt/dbbackup=>webdb$rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Wed Nov 7 15:18:27 2012

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: webdb (not mounted)

RMAN> restore controlfile from '/u01/app/oratt/dbbackup/ctl.standby';

Starting restore at 2012-11-07 15:18:42
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/u01/app/oratt/webdb/control01.ctl
output filename=/u01/app/oratt/webdb/control02.ctl
output filename=/u01/app/oratt/webdb/control03.ctl
Finished restore at 2012-11-07 15:18:45


Starting restore at 2012-11-07 15:20:07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oratt/webdb/system01.dbf
restoring datafile 00002 to /u01/app/oratt/webdb/undotbs01.dbf
restoring datafile 00003 to /u01/app/oratt/webdb/sysaux01.dbf
restoring datafile 00004 to /u01/app/oratt/webdb/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oratt/dbbackup/db01npnfn0_1_1.20121107
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oratt/dbbackup/db01npnfn0_1_1.20121107 tag=TAG20121107T150816
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 2012-11-07 15:20:14

RMAN> recover database;

Starting recover at 2012-11-07 15:20:21
using channel ORA_DISK_1

starting media recovery

unable to find archive log
archive log thread=1 sequence=12
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/07/2012 15:20:22
RMAN-06054: media recovery requesting unknown log: thread 1 seq 12 lowscn 216603

恢复到哪里算哪里。

在备库上创建standby logfile,满足最大可用模式的data guard配置的要求

ALTER DATABASE ADD STANDBY LOGFILE group 21 ('/u01/app/oratt/webdb/standby_redo21.log') SIZE 52428800 reuse;
ALTER DATABASE ADD STANDBY LOGFILE group 22 ('/u01/app/oratt/webdb/standby_redo22.log') SIZE 52428800 reuse;
ALTER DATABASE ADD STANDBY LOGFILE group 23 ('/u01/app/oratt/webdb/standby_redo23.log') SIZE 52428800 reuse;
ALTER DATABASE ADD STANDBY LOGFILE group 24 ('/u01/app/oratt/webdb/standby_redo24.log') SIZE 52428800 reuse;
ALTER DATABASE ADD STANDBY LOGFILE group 25 ('/u01/app/oratt/webdb/standby_redo25.log') SIZE 52428800 reuse;

linux
相关资讯       ORACLE 10G  Data Guard 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款