缺少log_archive_config導致歸檔路徑被禁用

yangtingkun發表於2011-01-07

10gDATA GUARD的一個主要特點就是引入了log_archive_config引數,如果缺少這個引數,可能會導致歸檔路徑被禁用。

 

 

看別人建立DATA GUARD時碰到了這個問題,當時覺得比較有意思,於是特意重現一下。

當前是一個已經配置好的DATA GUARD,為了模擬錯誤,先將這個引數設定為空:

SQL> alter system set log_archive_config = '';

System altered.

SQL> alter system switch logfile;

System altered.

SQL> show parameter archive_dest_2

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2                   string      SERVICE=standby LGWR SYNC VALI
                                                 D_FOR=(ONLINE_LOGFILES,PRIMARY
                                                 _ROLE) DB_UNIQUE_NAME=standby
SQL> alter system set log_archive_dest_2 = 'SERVICE=standby ARCH ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby';

System altered.

SQL> alter system switch logfile;

System altered.

日誌切換後,alert檔案中並沒有任何的錯誤,包含重新設定log_archive_dest_2引數後再次執行切換日誌,alert檔案中仍然看不到預期的錯誤。

導致問題無法重現的原因可能是由於系統中已經設定過log_archive_config引數了,雖然現在置為空,但是這個引數的生效可能會一直保留,於是嘗試重啟資料庫:

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  2074112 bytes
Variable Size             486541824 bytes
Database Buffers         1644167168 bytes
Redo Buffers               14700544 bytes
Database mounted.
Database opened.
SQL> alter system switch logfile;

System altered.

SQL> alter system set log_archive_dest_2 = 'SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby';

System altered.

SQL> alter system switch logfile;

System altered.

這是從alert檔案中已經可以看到預期的錯誤了:

Thu Dec 23 21:42:48 2010
Completed: ALTER DATABASE OPEN
Thu Dec 23 21:42:51 2010
Thread 1 advanced to log sequence 11
  Current log# 2 seq# 11 mem# 0: /data/oradata/primary/redo02.log
Thu Dec 23 21:42:51 2010
Errors in file /opt/ora10g/admin/primary/bdump/primary_arc1_18406.trc:
ORA-16057: DGID from server not in Data Guard configuration
Thu Dec 23 21:42:51 2010
FAL[server, ARC1]: Error 16057 creating remote archivelog file 'standby'
FAL[server, ARC1]: FAL archive failed, see trace file.
Thu Dec 23 21:42:51 2010
Errors in file /opt/ora10g/admin/primary/bdump/primary_arc1_18406.trc:
ORA-16055: FAL request rejected
ARCH: FAL archive failed. Archiver continuing
Thu Dec 23 21:42:51 2010
ORACLE Instance primary - Archival Error. Archiver continuing.
Thu Dec 23 21:43:46 2010
Shutting down archive processes
Thu Dec 23 21:43:51 2010
ARCH shutting down
ARC2: Archival stopped
Thu Dec 23 21:45:10 2010
ALTER SYSTEM SET log_archive_dest_2='SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby' SCOPE=BOTH;
LNS1 started with pid=18, OS id=18425
Thu Dec 23 21:45:29 2010
Thread 1 advanced to log sequence 12
  Current log# 3 seq# 12 mem# 0: /data/oradata/primary/redo03.log
Thu Dec 23 21:45:29 2010
Errors in file /opt/ora10g/admin/primary/bdump/primary_arc1_18406.trc:
ORA-16057: DGID from server not in Data Guard configuration
Thu Dec 23 21:45:29 2010
FAL[server, ARC1]: Error 16057 creating remote archivelog file 'standby'
FAL[server, ARC1]: FAL archive failed, see trace file.
Thu Dec 23 21:45:29 2010
Errors in file /opt/ora10g/admin/primary/bdump/primary_arc1_18406.trc:
ORA-16055: FAL request rejected
ARCH: FAL archive failed. Archiver continuing
Thu Dec 23 21:45:29 2010
ORACLE Instance primary - Archival Error. Archiver continuing.
Thu Dec 23 21:50:51 2010
Errors in file /opt/ora10g/admin/primary/bdump/primary_arc1_18406.trc:
ORA-16057: DGID from server not in Data Guard configuration
Thu Dec 23 21:50:51 2010
PING[ARC1]: Heartbeat failed to connect to standby 'standby'. Error is 16057.
Thu Dec 23 21:55:51 2010
Errors in file /opt/ora10g/admin/primary/bdump/primary_arc1_18406.trc:
ORA-16057: DGID from server not in Data Guard configuration
Thu Dec 23 21:55:51 2010
PING[ARC1]: Heartbeat failed to connect to standby 'standby'. Error is 16057.
Thu Dec 23 22:00:51 2010
Errors in file /opt/ora10g/admin/primary/bdump/primary_arc1_18406.trc:
ORA-16057: DGID from server not in Data Guard configuration
Thu Dec 23 22:00:51 2010
PING[ARC1]: Heartbeat failed to connect to standby 'standby'. Error is 16057.

錯誤資訊很明確ORA-16057,說明當前的SERVICE歸檔設定的主機沒有包括在DATA GUARD配置中。

下面將log_archive_config引數新增回來:

SQL> alter system set log_archive_config = 'DG_CONFIG=(primary,standby)';

System altered.

SQL> alter system switch logfile;

System altered.

檢查alert檔案:

Thu Dec 23 22:05:29 2010
ALTER SYSTEM SET log_archive_config='DG_CONFIG=(primary,standby)' SCOPE=BOTH;
Thu Dec 23 22:05:40 2010
Thread 1 advanced to log sequence 13
  Current log# 1 seq# 13 mem# 0: /data/oradata/primary/redo01.log
Thu Dec 23 22:05:40 2010
ARC0: Archivelog destination LOG_ARCHIVE_DEST_2 disabled: destination Data Guard configuration error

這時,第二個預期的錯誤也出現了對於LOG_ARCHIVE_DEST_2引數設定的路徑被禁止掉。

SQL> show parameter log_archive_dest_%2

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2                   string      SERVICE=standby LGWR ASYNC VAL
                                                 ID_FOR=(ONLINE_LOGFILES,PRIMAR
                                                 Y_ROLE) DB_UNIQUE_NAME=standby
log_archive_dest_state_2             string      enable

僅從引數上看,log_archive_dest_state_2的值仍然是enable,但是這個歸檔路徑已經不會完成歸檔操作了:

SQL> select name, sequence#
  2  from v$archived_log
  3  order by 2, 1;

NAME                                                          SEQUENCE#
------------------------------------------------------------ ----------
                                                                      3
/data/oradata/primary/archivelog/1_4_737020478.dbf                    4
standby                                                               4
                                                                      4
/data/oradata/primary/archivelog/1_5_737020478.dbf                    5
standby                                                               5
/data/oradata/primary/archivelog/1_6_737020478.dbf                    6
standby                                                               6
/data/oradata/primary/archivelog/1_7_737020478.dbf                    7
standby                                                               7
/data/oradata/primary/archivelog/1_8_737020478.dbf                    8
standby                                                               8
/data/oradata/primary/archivelog/1_9_737020478.dbf                    9
standby                                                               9
/data/oradata/primary/archivelog/1_10_737020478.dbf                  10
/data/oradata/primary/archivelog/1_11_737020478.dbf                  11
/data/oradata/primary/archivelog/1_12_737020478.dbf                  12
/data/oradata/primary/archivelog/1_13_737020478.dbf                  13

18 rows selected.

最近4個歸檔都沒有想到遠端,檢查V$ARCHIVE_DEST檢視:

SQL> select dest_name, status, error
  2  from v$archive_dest
  3  where dest_id = 2;

DEST_NAME            STATUS    ERROR
-------------------- --------- ------------------------------------------------------------
LOG_ARCHIVE_DEST_2   DISABLED  ORA-16057: DGID from server not in Data Guard configuration

可以看到,路徑2對應的狀態是DISABLED,透過設定log_archive_dest_state_2ENABLE,可以解決這個問題:

SQL> alter system set log_archive_dest_state_2 = enable;

System altered.

SQL> alter system switch logfile;

System altered.

檢查檢視狀態:

SQL> select name, sequence#
  2  from v$archived_log
  3  order by 2, 1;

NAME                                                          SEQUENCE#
------------------------------------------------------------ ----------
                                                                      3
/data/oradata/primary/archivelog/1_4_737020478.dbf                    4
standby                                                               4
                                                                      4
/data/oradata/primary/archivelog/1_5_737020478.dbf                    5
standby                                                               5
/data/oradata/primary/archivelog/1_6_737020478.dbf                    6
standby                                                               6
/data/oradata/primary/archivelog/1_7_737020478.dbf                    7
standby                                                               7
/data/oradata/primary/archivelog/1_8_737020478.dbf                    8
standby                                                               8
/data/oradata/primary/archivelog/1_9_737020478.dbf                    9
standby                                                               9
/data/oradata/primary/archivelog/1_10_737020478.dbf                  10
STANDBY                                                              10
/data/oradata/primary/archivelog/1_11_737020478.dbf                  11
STANDBY                                                              11
/data/oradata/primary/archivelog/1_12_737020478.dbf                  12
STANDBY                                                              12
/data/oradata/primary/archivelog/1_13_737020478.dbf                  13
STANDBY                                                              13
/data/oradata/primary/archivelog/1_14_737020478.dbf                  14
standby                                                              14

24 rows selected.

SQL> select dest_name, status, failure_count, error
  2  from v$archive_dest    
  3  where dest_id = 2;

DEST_NAME            STATUS    ERROR
-------------------- --------- ------------------------------------------------------------
LOG_ARCHIVE_DEST_2   VALID

有的時候並不要過分相信Oracle返回的狀態,比如這個例子中路徑已經被禁止,但是查詢引數log_archive_dest_state_2的值卻是ENABLE。而解決這個問題的辦法,又恰好就是將log_archive_dest_state_2引數的值改為ENABLE

 

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-683461/,如需轉載,請註明出處,否則將追究法律責任。

相關文章