首页 > 数据库 > Oracle > 正文

Oracle与DATA GUARD环境中重建控制文件

2024-08-29 13:52:12
字体:
来源:转载
供稿:网友
环境:linux AS 3+ORA 9.2.4 +DATA GUARD

MAX LOGFILES ,RESETLOGS

问题描述:目前已经搭建好了基于归档日记传输的最大性能保护模式的DG,想把它改基于REDO 日记传输模式。在备库新建STANDBY REDO 的时候报错,示例如下:

SQL> alter database add standby logfile group 4 ('/SERVER/ora9/oradata/ora9i/redo04.log') size 100M;Database altered.SQL> alter database add standby logfile group 5 ('/SERVER/ora9/oradata/ora9i/redo05.log') size 100M;Database altered.SQL> alter database add standby logfile group 6 ('/SERVER/ora9/oradata/ora9i/redo06.log') size 100M*ERROR at line 1:ORA-01185: logfile group number 6 is invalidSQL> alter database add standby logfile group 7 ('/SERVER/ora9/oradata/ora9i/redo07.log') size 100M*ERROR at line 1:ORA-01185: logfile group number 7 is invalid

出现以上这个错误是因为控制文件中限制了MAX LOGFILES 最大日志组数量。

像这种情况只能重建控制文件。

但这是DG环境,处理控制文件要特别的小心,如果搞不好就会DG环境被破坏,需要重建环境。(那样工作量就大了)

1.导出重建脚本

SQL> alter database backup controlfile to trace;Database altered.在新产生的Trace文件中可以看到下面的内容:STARTUP NOMOUNT pfile=$Oracle_HOME/dbs/initora9i.ora-as_PRimaryCREATE CONTROLFILE REUSE DATABASE "ORA9I" RESETLOGS FORCE LOGGING ARCHIVELOG-- SET STANDBY TO MAXIMIZE PERFORMANCEMAXLOGFILES 10MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 1MAXLOGHISTORY 226LOGFILEGROUP 1 '/SERVER/ora9/oradata/ora9i/redo01.log' SIZE 100M,GROUP 2 '/SERVER/ora9/oradata/ora9i/redo02.log' SIZE 100M,GROUP 3 '/SERVER/ora9/oradata/ora9i/redo03.log' SIZE 100M-- STANDBY LOGFILEDATAFILE'/SERVER/ora9/oradata/ora9i/system01.dbf','/SERVER/ora9/oradata/ora9i/undotbs01.dbf','/SERVER/ora9/oradata/ora9i/cwmlite01.dbf','/SERVER/ora9/oradata/ora9i/drsys01.dbf','/SERVER/ora9/oradata/ora9i/example01.dbf','/SERVER/ora9/oradata/ora9i/indx01.dbf','/SERVER/ora9/oradata/ora9i/odm01.dbf','/SERVER/ora9/oradata/ora9i/tools01.dbf','/SERVER/ora9/oradata/ora9i/user01.dbf','/SERVER/ora9/oradata/ora9i/xdb01.dbf','/SERVER/ora9/oradata/ora9i/data01.dbf','/SERVER/ora9/oradata/ora9i/chxi.dbf'CHARACTER SET ZHS16GBK;

注意:

(1)在CREATE CONTROLFILE REUSE DATABASE "ORA9I" RESETLOGS FORCE LOGGING ARCHIVELOG中间的RESETLOGS, 一定要改成NORESETLOGS,不然日志的序列就乱了。也备库的同步就会出现麻烦。

(2)更改MAXLOGFILES 10

2.在主库重建控制文件

SQL> shutdown immediate;

SQL> @recreatectl.sh

控制文件已创建.

SQL> shutdown immediate;

SQL> startup

数据库重起成功,并确认REDO LOG的SEQUENCE有没有被RESET:

SQL> select group#,sequence#,status from v$Log;GROUP# SEQUENCE# STATUS---------- ---------- ----------------1 67 ACTIVE2 66 INACTIVE3 68 CURRENT

3.为备库重建控制文件

在主库上执行:

SQL> alter database create standby controlfile as ‘控制文件名和路径’

并传送到备份机上。

关闭备库,并用新的控制文件覆盖原来的控制文件(注意备份旧的控制文件);

4.重起备库

SQL> startup nomount;SQL> alter database mount standby database;alter database mount standby database*ERROR at line 1:ORA-01991: invalid passWord file '/SERVER/ora9/product/9.2/dbs/orapwora9i'

提示密码文件也失效了。

解决:从主库再传一份过来,覆盖。

重启备库:

SQL> startup nomount;SQL> alter database mount standby database;SQL> alter database recover managed standby database disconnect from session;

确认相关进程已经启动:

SQL> select process,status from v$managed_standby;PROCESS STATUS------- ------------ARCH CONNECTEDARCH CONNECTEDMRP0 WAIT_FOR_LOGRFS RECEIVINGRFS ATTACHED

5.验证备库工作正常:

在主库作日志切换。并看备库是否接收正常。

SQL> alter system switch logfile;

查看备库是否接收到主库的日志并正确应用。

SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME, APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

6.继续加REDO lOG GROUP

这是因为控制文件被重建过了,之前在备库中建立成功的两个REDO4,REDO5也已经被用了。在OS中删除。

[oracle@ora9-2 ora9i]$ rm redo04.log redo05.logSQL> alter database add standby logfile group 4 ('/SERVER/ora9/oradata/ora9i/redo04.log') size 100M;Database altered.SQL> alter database add standby logfile group 5('/SERVER/ora9/oradata/ora9i/redo05.log') size 100M;Database altered.SQL> alter database add standby logfile group 6('/SERVER/ora9/oradata/ora9i/redo06.log') size 100M;Database altered.SQL> alter database add standby logfile group 7('/SERVER/ora9/oradata/ora9i/redo07.log') size 100M;Database altered.

7.特殊情况

假如不能正常传输切换之间产生的日志,需要手动传输并注册到备库来进行恢复:

SQL> ALTER DATABASE REGISTER PHYSICAL LOGFILE '/SERVER/ora9/primary-arc/ora9i_1_60.log'; SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

8.完成


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表