Chinaunix首页 | 论坛 | 博客
  • 博客访问: 791538
  • 博文数量: 185
  • 博客积分: 7434
  • 博客等级: 少将
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-29 14:01
文章分类

全部博文(185)

文章存档

2013年(1)

2012年(2)

2011年(17)

2010年(25)

2009年(36)

2008年(104)

分类: Oracle

2008-09-03 17:08:50

一,参数参考
以下是我在配置oracle11g dataguard时所设置参数,环境是在standby与primary分别在二台机器上
#for standby
*.db_unique_name='my11g_dg1'
*.log_archive_dest_1='LOCATION=/u01/oracle11g/oradata/my11g/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=my11g_dg1'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.log_archive_dest_2='SERVICE=my11g LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=my11g'
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.standby_file_management=auto
*.log_archive_config='DG_CONFIG=(my11g,my11g_dg1)'
*.fal_client='my11g_dg1'
*.fal_server='my11g'
*.LOG_FILE_NAME_CONVERT='/u01/oracle11g/','/u01/oracle11g/'
 
#for primary
*.db_unique_name='my11g'
*.log_archive_dest_1='LOCATION=/u01/oracle11g/oradata/my11g/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=my11g'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.log_archive_dest_2='SERVICE=my11g_dg1 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=my11g_dg1'
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.standby_file_management=auto
*.log_archive_config='DG_CONFIG=(my11g,my11g_dg1)'
*.fal_client='my11g'
*.fal_server='my11g_dg1'
*.LOG_FILE_NAME_CONVERT='/u01/oracle11g/','/u01/oracle11g/'
 
二、管理:
查询库状态:
SQL> select name,SWITCHOVER_STATUS,open_mode,PROTECTION_MODE,DATABASE_ROLE
          from v$database;
验证archive log是否接收和 applied.
SQL> alter session set nls_datE_format='YYYY-MM-DD HH24:MI:SS';
select SEQUENCE#,DEST_ID,ARCHIVED,APPLIED,DELETED,
STATUS,FIRST_TIME from v$archived_log order by SEQUENCE#;
启动到管理模式:
SQL> shutdown immediate;
SQL> startup nomount
SQL> alter database mount standby database
SQL> recover managed standby database disconnect from session;
----------
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
10g以后,采用联机日志的传递传递方式,
SQL> recover managed standby database using current logfile disconnect from session;
启动到只读模式:
SQL> shutdown immediate;
SQL> startup nomount
SQL> alter database mount standby database
SQL> alter databae open read only;
在管理模式恢复到只读模式:
SQL> recover managed standby database cancel;
SQL> alter database open read only
在只读模式可以给数据库添加临时数据文件(在rman备份是没有备份的),想让standby提供只读服务或者切换成主库,最好先增加链式文件
SQL> alter tablespace temp add tempfile 'C:\oracle\product\10.2.0\oradata\dgtest\temp02.dbf' size 100m;
只读模式到管理模式
SQL> recover managed standby database disconnect from session;
在备库进行备份
1.停止应用程序,跳转到 read only模式,同坐backup database命令来备份数据库,这样数据库处于一致性模式
2. 备份完成后,备份控制文件
SQL> ALTER DATABASE BACKUP CONTROLFILE TO 'FILE NAME';
主备切换
正常切换 (switchover)
切换准备: 准备参数文件,平时应该备好,注意参数 fal_server,fal_client
先确认能否转换:
SELECT SWITCHOVER_STATUS FROM V$DATABASE;
主 -> 备
$lsnrclt stop
杀光进程或者重启数据库
SQL> alter database commit to switchover to physical standby with session shutdown;
SQL> shutdown immediate;
SQL> startup nomount pfile ='';
SQL> alter database mount standby database;
SQL> recover managed standby database disconnect;
备 -> 主
SQL> alter database commit to switchover to primary with session shutdown;
SQL> shutdown immediate
SQL> startup pfile =''
如果考虑在主备库来回切换,要保证数据库版本一致,参数compatible一致
失败切换 (Failover)
主服务器不能使用情况下
在备库
SQL> recover managed standby database cancel;
--如果在备用库上有备用库日志文件,参考命令
SQL> alter database recover managed standby database finish; -- [force|wait|nowait] 10g or later
--没有备库日志文件[10gR2之前]
SQL> alter database recover managed standby database finish skip standby logfile;
--切换备库到主库
SQL> alter database commit to switchover to primary;
-- open
SQL> shutdown immediate;
SQL> startup pfile=''
如果还有为传递的归档日志或者主库的联机日志
SQL>alter database register logfile 'c:\...'
SQL>recover standby database;
强行切换(激活)
激活备用服务器,在重启数据库时,备库会resetlog。
SQL>alter system archive log current;
SQL>recover managed standby database cancel;
SQL>alter database activate standby database;
SQL>shutdown immediate;
SQL>startup pfile=''
-----
apply 主库redolog并强制切换
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
--选定redolog恢复
SQL> recover standby database until cancel;
Specify log: {=suggested | filename | AUTO | CANCEL}
/u01/oradata/dgtest/redo02.log
Log applied.
Media recovery complete.
recovery 完成之后就要failover了。
SQL>alter database activate standby database;
SQL>shutdown immediate;
SQL>startup pfile=''
相关视图
v$archive_dest
v$archive_dest_status
v$log_history
v$archvied_log
v$managed_standby
v$archive_gap
阅读(1364) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~