在一个dg环境中,配置的是实时同步,需要增加主库的redo大小和组数,本来是一个很简单的问题,解决思路是:先备库增加standby redo删除老standby
redo,然后主库增加redo删除老redo,备库增加新redo删除老redo,最后主库增加standby redo。但是在实施过程中,遇到了一些细节性的问题,主要是
学习到了log_file_name_convert如果不配置,将导致备库redo 文件不能被删除
---备库操作
1、取消日志恢复
alter database recover managed standby database cancel;
2、备库添加standby redolog组。
alter database add standby logfile group 11 ('/u01/app/oradata/orcl/stred11.log','/u01/app/oradata/orcl/stred11b.log') size 100M;
alter database add standby logfile group 12 ('/u01/app/oradata/orcl/stred12.log','/u01/app/oradata/orcl/stred12b.log') size 100M;
alter database add standby logfile group 13 ('/u01/app/oradata/orcl/stred13.log','/u01/app/oradata/orcl/stred13b.log') size 100M;
alter database add standby logfile group 14 ('/u01/app/oradata/orcl/stred14.log','/u01/app/oradata/orcl/stred14b.log') size 100M;
3、备库standby删除stnadby redo log
alter database drop logfile group 4;
alter database drop logfile group 5;
alter database drop logfile group 6;
SQL> alter database drop logfile group 5;
alter database drop logfile group 5
*
ERROR at line 1:
ORA-00261: log 5 of thread 1 is being archived or modified
ORA-00312: online log 5 thread 1: '/u01/app/oradata/orcl/stredo02.log'
--如在清除standby redo log组时出现上面出错信息执行下面的命令清理
alter database clear logfile group 4;
4、主库online redo添加
alter database add logfile thread 1 group 7 ('/u01/app/oradata/orcl/redo07.log','/u01/app/oradata/orcl/redo07b.log') size 100m;
alter database add logfile thread 1 group 8 ('/u01/app/oradata/orcl/redo08.log','/u01/app/oradata/orcl/redo08b.log') size 100m;
alter database add logfile thread 2 group 9 ('/u01/app/oradata/orcl/redo09.log','/u01/app/oradata/orcl/redo09b.log') size 100m;
5、主库删除online redo组
alter database drop logfile group 1;
alter database drop logfile group 2;
alter database drop logfile group 3;
6、备库online redo组添加
刚开始删除的时候可能报错,执行以下命令:
alter system set standby_file_management='manual';
alter database add logfile thread 1 group 7 ('/u01/app/oradata/orcl/redo07.log','/u01/app/oradata/orcl/redo07b.log') size 100m;
alter database add logfile thread 1 group 8 ('/u01/app/oradata/orcl/redo08.log','/u01/app/oradata/orcl/redo08b.log') size 100m;
alter database add logfile thread 2 group 9 ('/u01/app/oradata/orcl/redo09.log','/u01/app/oradata/orcl/redo09b.log') size 100m;
7、备库删除老的online redo log
SQL> alter database drop logfile group 1;
alter database drop logfile group 1
*
ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of instance wasudb (thread 1)
ORA-00312: online log 1 thread 1: '/data/oradata/wasudb/redo01.log'
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1;
ALTER DATABASE CLEAR LOGFILE GROUP 1
*
ERROR at line 1:
ORA-19527: physical standby redo log must be renamed
ORA-00312: online log 1 thread 1: '/data/oradata/wasudb/redo01.log'
SQL> show parameter NAME_CONVERT
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
log_file_name_convert string
SQL> alter system set log_file_name_convert='/u01/app/oradata/orcl','/u01/app/oradata/orcl' scope=spfile;
System altered.
SQL> alter system set db_file_name_convert='/u01/app/oradata/orcl','/u01/app/oradata/orcl' scope=spfile;
System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 413372416 bytes
Fixed Size 2213896 bytes
Variable Size 318769144 bytes
Database Buffers 88080384 bytes
Redo Buffers 4308992 bytes
Database mounted.
Database opened.
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
-------------------- ----------------
READ ONLY PHYSICAL STANDBY
SQL> show parameter file_name_convert
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string /u01/app/oradata/orcl, /u01/ap
p/oradata/orcl
log_file_name_convert string /u01/app/oradata/orcl, /u01/ap
p/oradata/orcl
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE#
NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------ ------------
------------
1 1 25 52428800 512 1 YES CLEARING 1041620 04-MAY-15 1042334 04-
MAY-15
2 1 20 52428800 512 1 YES CLEARING 1035102 20-JAN-15 1038445 04-
MAY-15
3 1 21 52428800 512 1 YES CLEARING 1038445 04-MAY-15 1039447 04-
MAY-15
7 1 28 104857600 512 2 YES CLEARING_CURRENT 1044189 04-MAY-15 0
8 1 27 104857600 512 2 YES CLEARING 1042338 04-MAY-15 1044189 04-
MAY-15
9 2 0 104857600 512 2 YES UNUSED 0 0
6 rows selected.
SQL> alter database drop logfile group 1;
alter database drop logfile group 1
*
ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of instance orcl (thread 1)
ORA-00312: online log 1 thread 1: '/u01/app/oradata/orcl/redo01.log'
SQL> alter database clear logfile group 1;
Database altered.
SQL> alter database clear logfile group 2;
Database altered.
SQL> alter database clear logfile group 3;
Database altered.
SQL> alter database drop logfile 1;
alter database drop logfile 1
*
ERROR at line 1:
ORA-02236: invalid file name
SQL> alter database drop logfile group 1;
Database altered.
SQL> alter database drop logfile group 2;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
SQL>
8、主库删除standby redo log组
SQL> alter database drop logfile group 4;
Database altered.
SQL> alter database drop logfile group 5;
Database altered.
SQL> alter database drop logfile group 6;
Database altered.
9、主库添加standby redo log 组SQL> alter database add standby logfile group 11
alter database add standby logfile group 12 ('/u01/app/oradata/orcl/stred12.log','/u01/app/oradata/orcl/stred12b.log') size 100M;
alter database add standby logfile group 13 ('/u01/app/oradata/orcl/stred13.log','/u01/app/oradata/orcl/stred13b.log') size 100M;
alter database add standby logfile group 14 ('/u01/app/oradata/orcl/stred14.log','/u01/app/oradata/orcl/stred14b.log') size 100M;
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL>
Database altered.
10、启动时实恢复
然后在备库执行
alter database recover managed standby database using current logfile disconnect;
alter system set standby_file_management='auto';
redo,然后主库增加redo删除老redo,备库增加新redo删除老redo,最后主库增加standby redo。但是在实施过程中,遇到了一些细节性的问题,主要是
学习到了log_file_name_convert如果不配置,将导致备库redo 文件不能被删除
---备库操作
1、取消日志恢复
alter database recover managed standby database cancel;
2、备库添加standby redolog组。
alter database add standby logfile group 11 ('/u01/app/oradata/orcl/stred11.log','/u01/app/oradata/orcl/stred11b.log') size 100M;
alter database add standby logfile group 12 ('/u01/app/oradata/orcl/stred12.log','/u01/app/oradata/orcl/stred12b.log') size 100M;
alter database add standby logfile group 13 ('/u01/app/oradata/orcl/stred13.log','/u01/app/oradata/orcl/stred13b.log') size 100M;
alter database add standby logfile group 14 ('/u01/app/oradata/orcl/stred14.log','/u01/app/oradata/orcl/stred14b.log') size 100M;
3、备库standby删除stnadby redo log
alter database drop logfile group 4;
alter database drop logfile group 5;
alter database drop logfile group 6;
SQL> alter database drop logfile group 5;
alter database drop logfile group 5
*
ERROR at line 1:
ORA-00261: log 5 of thread 1 is being archived or modified
ORA-00312: online log 5 thread 1: '/u01/app/oradata/orcl/stredo02.log'
--如在清除standby redo log组时出现上面出错信息执行下面的命令清理
alter database clear logfile group 4;
4、主库online redo添加
alter database add logfile thread 1 group 7 ('/u01/app/oradata/orcl/redo07.log','/u01/app/oradata/orcl/redo07b.log') size 100m;
alter database add logfile thread 1 group 8 ('/u01/app/oradata/orcl/redo08.log','/u01/app/oradata/orcl/redo08b.log') size 100m;
alter database add logfile thread 2 group 9 ('/u01/app/oradata/orcl/redo09.log','/u01/app/oradata/orcl/redo09b.log') size 100m;
5、主库删除online redo组
alter database drop logfile group 1;
alter database drop logfile group 2;
alter database drop logfile group 3;
6、备库online redo组添加
刚开始删除的时候可能报错,执行以下命令:
alter system set standby_file_management='manual';
alter database add logfile thread 1 group 7 ('/u01/app/oradata/orcl/redo07.log','/u01/app/oradata/orcl/redo07b.log') size 100m;
alter database add logfile thread 1 group 8 ('/u01/app/oradata/orcl/redo08.log','/u01/app/oradata/orcl/redo08b.log') size 100m;
alter database add logfile thread 2 group 9 ('/u01/app/oradata/orcl/redo09.log','/u01/app/oradata/orcl/redo09b.log') size 100m;
7、备库删除老的online redo log
SQL> alter database drop logfile group 1;
alter database drop logfile group 1
*
ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of instance wasudb (thread 1)
ORA-00312: online log 1 thread 1: '/data/oradata/wasudb/redo01.log'
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1;
ALTER DATABASE CLEAR LOGFILE GROUP 1
*
ERROR at line 1:
ORA-19527: physical standby redo log must be renamed
ORA-00312: online log 1 thread 1: '/data/oradata/wasudb/redo01.log'
SQL> show parameter NAME_CONVERT
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
log_file_name_convert string
SQL> alter system set log_file_name_convert='/u01/app/oradata/orcl','/u01/app/oradata/orcl' scope=spfile;
System altered.
SQL> alter system set db_file_name_convert='/u01/app/oradata/orcl','/u01/app/oradata/orcl' scope=spfile;
System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 413372416 bytes
Fixed Size 2213896 bytes
Variable Size 318769144 bytes
Database Buffers 88080384 bytes
Redo Buffers 4308992 bytes
Database mounted.
Database opened.
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
-------------------- ----------------
READ ONLY PHYSICAL STANDBY
SQL> show parameter file_name_convert
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string /u01/app/oradata/orcl, /u01/ap
p/oradata/orcl
log_file_name_convert string /u01/app/oradata/orcl, /u01/ap
p/oradata/orcl
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE#
NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------ ------------
------------
1 1 25 52428800 512 1 YES CLEARING 1041620 04-MAY-15 1042334 04-
MAY-15
2 1 20 52428800 512 1 YES CLEARING 1035102 20-JAN-15 1038445 04-
MAY-15
3 1 21 52428800 512 1 YES CLEARING 1038445 04-MAY-15 1039447 04-
MAY-15
7 1 28 104857600 512 2 YES CLEARING_CURRENT 1044189 04-MAY-15 0
8 1 27 104857600 512 2 YES CLEARING 1042338 04-MAY-15 1044189 04-
MAY-15
9 2 0 104857600 512 2 YES UNUSED 0 0
6 rows selected.
SQL> alter database drop logfile group 1;
alter database drop logfile group 1
*
ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of instance orcl (thread 1)
ORA-00312: online log 1 thread 1: '/u01/app/oradata/orcl/redo01.log'
SQL> alter database clear logfile group 1;
Database altered.
SQL> alter database clear logfile group 2;
Database altered.
SQL> alter database clear logfile group 3;
Database altered.
SQL> alter database drop logfile 1;
alter database drop logfile 1
*
ERROR at line 1:
ORA-02236: invalid file name
SQL> alter database drop logfile group 1;
Database altered.
SQL> alter database drop logfile group 2;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
SQL>
8、主库删除standby redo log组
SQL> alter database drop logfile group 4;
Database altered.
SQL> alter database drop logfile group 5;
Database altered.
SQL> alter database drop logfile group 6;
Database altered.
9、主库添加standby redo log 组SQL> alter database add standby logfile group 11
alter database add standby logfile group 12 ('/u01/app/oradata/orcl/stred12.log','/u01/app/oradata/orcl/stred12b.log') size 100M;
alter database add standby logfile group 13 ('/u01/app/oradata/orcl/stred13.log','/u01/app/oradata/orcl/stred13b.log') size 100M;
alter database add standby logfile group 14 ('/u01/app/oradata/orcl/stred14.log','/u01/app/oradata/orcl/stred14b.log') size 100M;
Database altered.
SQL>
Database altered.
SQL>
Database altered.
SQL>
Database altered.
10、启动时实恢复
然后在备库执行
alter database recover managed standby database using current logfile disconnect;
alter system set standby_file_management='auto';
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27252036/viewspace-1622141/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/27252036/viewspace-1622141/