How to change the thread of redo logfile group in standby database?
-
08-03-2021 - |
Question
Is there some way to correct the thread of redo logfile group? it's ok the thread to be wrong?
executing the following query I get de logfile groups, thread and members:
set linesize 2000;
set pagesize 0 embedded on;
col member for a80;
select * from (
select g.THREAD#,g.group#,m.type,m.member,g.bytes/1024/1024 "LOGGROUP_SIZE_MB",g.status,nvl(m.status,'FILE IS IN USE') as status_file from
v$log g inner join v$logfile m on m.group#=g.group#
union all
select g.THREAD#,g.group#,m.type,m.member,g.bytes/1024/1024 "LOGGROUP_SIZE_MB",g.status,nvl(m.status,'FILE IS IN USE') as status_file from
v$standby_log g inner join v$logfile m on m.group#=g.group#)
order by type,THREAD#,group#
/
THREAD# GROUP# TYPE MEMBER LOGGROUP_SIZE_MB STATUS STATUS_FILE
---------- ---------- ------- -------------------------------------------------------------------------------- ---------------- ---------------- --------------
1 1 ONLINE +DADOS/mootstb/onlinelog/group_1.276.1052413891 50 CLEARING FILE IS IN USE
1 1 ONLINE +FRA/mootstb/onlinelog/group_1.264.1052413893 50 CLEARING FILE IS IN USE
1 2 ONLINE +DADOS/mootstb/onlinelog/group_2.277.1052413931 50 CURRENT FILE IS IN USE
1 2 ONLINE +FRA/mootstb/onlinelog/group_2.265.1052413933 50 CURRENT FILE IS IN USE
2 3 ONLINE +DADOS/mootstb/onlinelog/group_3.278.1052413939 50 UNUSED FILE IS IN USE
2 3 ONLINE +FRA/mootstb/onlinelog/group_3.266.1052413941 50 UNUSED FILE IS IN USE
2 4 ONLINE +DADOS/mootstb/onlinelog/group_4.279.1052413947 50 UNUSED FILE IS IN USE
2 4 ONLINE +FRA/mootstb/onlinelog/group_4.267.1052413947 50 UNUSED FILE IS IN USE
1 5 STANDBY +DADOS/mootstb/onlinelog/group_5.280.1052413961 50 UNASSIGNED FILE IS IN USE
1 5 STANDBY +FRA/mootstb/onlinelog/group_5.268.1052413963 50 UNASSIGNED FILE IS IN USE
1 6 STANDBY +DADOS/mootstb/onlinelog/group_6.281.1052413969 50 ACTIVE FILE IS IN USE
1 6 STANDBY +FRA/mootstb/onlinelog/group_6.269.1052413969 50 ACTIVE FILE IS IN USE
2 7 STANDBY +DADOS/mootstb/onlinelog/group_7.282.1052413975 50 UNASSIGNED FILE IS IN USE
2 7 STANDBY +FRA/mootstb/onlinelog/group_7.270.1052413975 50 UNASSIGNED FILE IS IN USE
2 8 STANDBY +FRA/mootstb/onlinelog/group_8.271.1052413983 50 UNASSIGNED FILE IS IN USE
2 8 STANDBY +DADOS/mootstb/onlinelog/group_8.283.1052413981 50 UNASSIGNED FILE IS IN USE
You can see that I have some logfile groups with thread 1 and 2. This happen because I've duplicated this database from RAC environment.
My current thread in this environment (physical standby) is 0:
SQL> show parameters thread
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
parallel_threads_per_cpu integer 2
thread integer 0
How can I change the thread of all redo logfile groups to 0 as well? I've tried to drop each and recreate, but this is not possible, for example, I need to switchlog the online logfile group 1 to drop, but the database is not open because is a standby:
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 imootstb (thread 1)
ORA-00312: online log 1 thread 1: '+DADOS/mootstb/onlinelog/group_1.276.1052413891'
ORA-00312: online log 1 thread 1: '+FRA/mootstb/onlinelog/group_1.264.1052413893'
SQL> alter system switch logfile;
alter system switch logfile
*
ERROR at line 1:
ORA-01109: database not open
If it is not possible, it's ok the thread keep wrong? or will have some strange behavior in the database?
Solution
There is nothing wrong with not having the thread
parameter explicitly set in a single instance environment.
SQL> show parameter thread
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
ofs_threads integer 4
parallel_threads_per_cpu integer 1
thread integer 0
threaded_execution boolean FALSE
SQL> select thread# from v$instance;
THREAD#
----------
1
SQL>
By the way, you can not add a logfile to thread 0:
SQL> select thread#, group# from v$log;
THREAD# GROUP#
---------- ----------
1 1
1 2
1 3
SQL> alter database add logfile thread 0 ('/oradata/redo0.log') size 100M;
Database altered.
SQL> alter database add logfile thread 2 ('/oradata/redo2.log') size 100M;
Database altered.
SQL> select thread#, group# from v$log;
THREAD# GROUP#
---------- ----------
1 1
1 2
1 3
1 4
2 5
SQL>