Oracle

如何更改備用數據庫中重做日誌文件組的執行緒?

  • September 30, 2020

有沒有辦法糾正重做日誌文件組的執行緒?執行緒錯了沒關係?

執行以下查詢我得到了日誌文件組、執行緒和成員:

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

您可以看到我有一些帶有執行緒 1 和 2 的日誌文件組。發生這種情況是因為我從 RAC 環境中複製了這個數據庫。

我在這個環境中的目前執行緒(物理備用)是0:

SQL> show parameters thread
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
parallel_threads_per_cpu             integer     2
thread                               integer     0

如何將所有重做日誌文件組的執行緒也更改為 0?我嘗試刪除每個並重新創建,但這是不可能的,例如,我需要切換記錄線上日誌文件組 1 以刪除,但數據庫未打開,因為是備用數據庫:

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

如果不可能,執行緒保持錯誤可以嗎?還是會在數據庫中出現一些奇怪的行為?

thread沒有在單實例環境中顯式設置參數並沒有錯。

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>

順便說一句,您不能將日誌文件添加到執行緒 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>

引用自:https://dba.stackexchange.com/questions/276301