--主库
--主库设置为 defer, 取消备库日志应用,关库启动到 mount 状态进行。
show parameter log_archive_dest_state_2
alter system set log_archive_dest_state_2=defer scope=both sid='*';
--备库
alter database recover managed standby database cancel;
shu immediate
startup mount
--强制拉成主库,很遗憾报错 ORA-00349
SQL> ALTER DATABASE ACTIVATE STANDBY DATABASE;
ALTER DATABASE ACTIVATE STANDBY DATABASE
*
ERROR at line 1:
ORA-00349: failure obtaining block size for '+JIEKE_DATA'
ORA-15001: diskgroup "JIEKE_DATA" does not exist or is not mounted
ORA-15001: diskgroup "JIEKE_DATA" does not exist or is not mounted
Errors in file /app/oracle/diag/rdbms/jiekexu/jiekexu/trace/jiekexu_ora_30872.trc:
ORA-00313: open failed for members of log group 5 of thread 1
Clearing online redo logfile 5 +JIEKE_DATA
Clearing online log 5 of thread 1 sequence number 4751
Errors in file /app/oracle/diag/rdbms/jiekexu/jiekexu/trace/jiekexu_ora_30872.trc:
ORA-00313: open failed for members of log group 5 of thread 1
Errors in file /app/oracle/diag/rdbms/jiekexu/jiekexu/trace/jiekexu_ora_30872.trc:
ORA-00313: open failed for members of log group 5 of thread 1
Clearing online redo logfile 5 complete
Errors in file /app/oracle/diag/rdbms/jiekexu/jiekexu/trace/jiekexu_ora_30872.trc:
ORA-00313: open failed for members of log group 6 of thread 2
Clearing online redo logfile 6 +JIEKE_DATA
Clearing online log 6 of thread 2 sequence number 2592
Errors in file /app/oracle/diag/rdbms/jiekexu/jiekexu/trace/jiekexu_ora_30872.trc:
ORA-00313: open failed for members of log group 6 of thread 2
Errors in file /app/oracle/diag/rdbms/jiekexu/jiekexu/trace/jiekexu_ora_30872.trc:
ORA-00313: open failed for members of log group 6 of thread 2
Clearing online redo logfile 6 complete
Errors in file /app/oracle/diag/rdbms/jiekexu/jiekexu/trace/jiekexu_ora_30872.trc:
ORA-00313: open failed for members of log group 23 of thread 1
Clearing online redo logfile 23 +JIEKE_DATA
Clearing online log 23 of thread 1 sequence number 4752
Errors in file /app/oracle/diag/rdbms/jiekexu/jiekexu/trace/jiekexu_ora_30872.trc:
ORA-00313: open failed for members of log group 23 of thread 1
Errors in file /app/oracle/diag/rdbms/jiekexu/jiekexu/trace/jiekexu_ora_30872.trc:
ORA-00313: open failed for members of log group 23 of thread 1
Clearing online redo logfile 23 complete
Resetting resetlogs activation ID 2008461997 (0x77b6b2ad)
Errors in file /app/oracle/diag/rdbms/jiekexu/jiekexu/trace/jiekexu_ora_30872.trc:
ORA-00313: open failed for members of log group 5 of thread 1
Errors in file /app/oracle/diag/rdbms/jiekexu/jiekexu/trace/jiekexu_ora_30872.trc:
ORA-00313: open failed for members of log group 5 of thread 1
ORA-349 signalled during: ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE...
Tue Mar 02 22:42:30 2021
alter database drop logfile group 23
ORA-1623 signalled during: alter database drop logfile group 23...
Tue Mar 02 22:45:07 2021
RFS[7]: Assigned to RFS process 10180
RFS[7]: Opened log for thread 2 sequence 2592 dbid 1797812601 branch 1063804222
Archived Log entry 1100 added for thread 2 sequence 2592 rlc 1063804222 ID 0x77b6b2ad dest 2:
Tue Mar 02 22:45:08 2021
RFS[8]: Assigned to RFS process 10277
RFS[8]: Selected log 17 for thread 2 sequence 2593 dbid 1797812601 branch 1063804222
Tue Mar 02 22:45:08 2021
Primary database is in MAXIMUM PERFORMANCE mode
重建备库 redolog
那么,这里将上演的是重建备库 redolog 的相关操作步骤。
SQL> alter database drop logfile group 27;
alter database drop logfile group 27
*
ERROR at line 1:
ORA-01156: recovery or flashback in progress may need access to files
--由于开启了日志应用进程,直接删除会报错,故需要停止日志应用,修改参数 standby_file_management 为手动。
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter system set standby_file_management='manual' scope=both sid='*';
Database altered.
SQL> show parameter standby_file_management
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
standby_file_management string manual
SQL> alter database drop logfile group 27;
Database altered.
--由于日志组不能少于 2 个,故 日志组 28 不不能够删除。
SQL> alter database drop logfile group 28;
alter database drop logfile group 28
*
ERROR at line 1:
ORA-01567: dropping log 28 would leave less than 2 log files for instance JIEKEXU2 (thread 2)
ORA-00312: online log 28 thread 2: '+JIEKER_DATA/jiekexu/onlinelog/group_28.1742.1065129973'
下面则通过继续应用日志、重启、主库切日志、重命名等各种手段继续尝试删除这三个有问题的日志组。
--重启备库删除日志组 6、23,由于是当前日志组无法删除,庆幸日志组 5 成功删除了。
SQL> alter database drop logfile group 6;
alter database drop logfile group 6
*
ERROR at line 1:
ORA-01623: log 6 is current log for instance JIEKEXU2 (thread 2) - cannot drop
ORA-00312: online log 6 thread 2: '+JIEKE_DATA'
ORA-00312: online log 6 thread 2: '+JIEKE_DATA'
SQL> alter database drop logfile group 5;
Database altered.
SQL> alter database drop logfile group 23;
alter database drop logfile group 23
*
ERROR at line 1:
ORA-01623: log 23 is current log for instance jiekexu (thread 1) - cannot drop
ORA-00312: online log 23 thread 1: '+JIEKE_DATA'
ORA-00312: online log 23 thread 1: '+JIEKE_DATA'
--只剩两组日志组也是当前日志组,则当前日志组无法删除,尝试进行 rename 操作,但也是无效或者缺失命令。
SQL> alter database rename '+JIEKE_DATA' to '+JIEKER_DATA';
alter database rename '+JIEKE_DATA' to '+JIEKER_DATA'
*
ERROR at line 1:
ORA-02231: missing or invalid option to ALTER DATABASE
SQL> alter database rename '+JIEKE_DATA' to '+JIEKER_DATA/jiekexu/onlinelog/group_6.dbf';
alter database rename '+JIEKE_DATA' to '+JIEKER_DATA/jiekexu/onlinelog/group_6.dbf'
*
ERROR at line 1:
ORA-02231: missing or invalid option to ALTER DATABASE
--当然继续激活为主库肯定也是报错。那就继续开启日志同步模式,先保持备库同步吧。
SQL> ALTER DATABASE ACTIVATE STANDBY DATABASE;
ALTER DATABASE ACTIVATE STANDBY DATABASE
*
ERROR at line 1:
ORA-00349: failure obtaining block size for '+JIEKE_DATA'
ORA-15001: diskgroup "JIEKE_DATA" does not exist or is not mounted
ORA-15001: diskgroup "JIEKE_DATA" does not exist or is not mounted
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
jiekeadg:/home/oracle(jiekexu)>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Mar 3 10:52:04 2021
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
SQL> show parameter db_create_online_log_dest_
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_online_log_dest_1 string +JIEKE_DATA
db_create_online_log_dest_2 string +JIEKE_DATA
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
SQL> alter system set db_create_online_log_dest_1='+JIEKER_DATA' scope=spfile;
System altered.
SQL> alter system set db_create_online_log_dest_2='+JIEKER_DATA' scope=spfile;
System altered.