[20180115]RMAN-06820.txt
--//在备库做归档备份出现RMAN-06820的问题。就是如果在备库做全表,因为要做主库日志切换,一般执行rman target /会出现问题。
--//必须在备库使用sys/passwd方式登录rman。
1.环境:
SYS@bookdg> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
rman target /
...
RMAN> delete archivelog all ;
....
RMAN> backup archivelog all ;
Starting backup at 2018-01-15 15:49:04
RMAN-06820: WARNING: failed to archive current log at primary database
ORACLE error from target database:
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-00942: table or view does not exist
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
specification does not match any archived log in the repository
backup cancelled because there are no files to backup
Finished backup at 2018-01-15 15:49:04
2.采用输入口令的方法:
$ rlwrap rman
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Jan 15 15:51:57 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target sys
target database Password:
connected to target database: BOOK (DBID=1337401710)
RMAN> backup archivelog all ;
Starting backup at 2018-01-15 15:52:08
using target database control file instead of recovery catalog
current log archived at primary database
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=12 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=73 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=134 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=786 RECID=94 STAMP=965490729
channel ORA_DISK_1: starting piece 1 at 2018-01-15 15:52:12
channel ORA_DISK_1: finished piece 1 at 2018-01-15 15:52:13
piece handle=/u01/app/oracle/fast_recovery_area/BOOKDG/backupset/2018_01_15/o1_mf_annnn_TAG20180115T155211_f5rqfd8f_.bkp tag=TAG20180115T155211 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2018-01-15 15:52:13
Starting Control File and SPFILE Autobackup at 2018-01-15 15:52:13
piece handle=/u01/app/oracle/fast_recovery_area/BOOKDG/autobackup/2018_01_15/o1_mf_s_965475661_f5rqfg61_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2018-01-15 15:52:16
3.做一个跟踪:
$ rman target / | tee aa.txt
RMAN> debug on
RMAN> backup archivelog all ;
RMAN> quit
--//注很奇怪如果这样打rman target / debug trace=tracefile.trc,跟踪文件里面没有RMAN-06820: WARNING: failed to archive current log at primary database错误。
--//检查跟踪文件:
DBGSQL: TARGET> begin :lprimary_db_cs := sys.dbms_backup_restore.get_connect_identifier (dbuname=> :primary_dbuname); end;
DBGSQL: sqlcode = 0
DBGSQL: B :lprimary_db_cs = book
DBGSQL: B :primary_dbuname = book
DBGRCVMAN: getConfig: configurations exists for this site
DBGSQL: ENTERED krmkosqlerr
--//这步ok。
DBGSQL: TARGET> declare null_retVal varchar2(1); begin null_retVal :=
sys.dbms_backup_restore.remoteSQLExecute( source_dbuname=> :primary_dbuname, source_cs
=> :lprimary_db_cs, stmt => 'alter system archive log current'); end;
DBGSQL: sqlcode = 17629
DBGSQL: B :primary_dbuname = book
DBGSQL: B :lprimary_db_cs = book
DBGSQL: error: ORA-17629: Cannot connect to the remote database server (krmkosqlerr)
DBGSQL: ORA-17627: ORA-00942: table or view does not exist (krmkosqlerr)
DBGSQL: ORA-06512: at "SYS.DBMS_BACKUP_RESTORE", line 7809 (krmkosqlerr)
DBGSQL: ORA-06512: at line 1 (krmkosqlerr)
DBGSQL: (krmkosqlerr)
DBGSQL: EXITED krmkosqlerr
RMAN-06820: WARNING: failed to archive current log at primary database
DBGMISC: ENTERED krmkursr [16:22:19.636]
DBGSQL: TARGET> begin sys.dbms_backup_restore.updateRmanStatusRow( row_id => :row_id, row_stamp => :row_stamp, status => :status); end;
DBGSQL: sqlcode = 0
DBGSQL: B :row_id = 507
DBGSQL: B :row_stamp = 965492539
DBGSQL: B :status = 9
DBGMISC: EXITED krmkursr [16:22:19.638] elapsed time [00:00:00:00.001]
DBGMISC: krmksqlerror called from file krmk3.c, line 2094 [16:22:19.638]
RMAN-06003: ORACLE error from target database:
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-00942: table or view does not exist
--//我格式化
/* Formatted on 2018/1/15 16:24:49 (QP5 v5.252.13127.32867) */
DECLARE
null_retVal VARCHAR2 (1);
BEGIN
null_retVal :=
sys.DBMS_BACKUP_RESTORE.remoteSQLExecute
(
source_dbuname => :primary_dbuname
,source_cs => :lprimary_db_cs
,stmt => 'alter system archive log current'
);
END;
--//很明显在使用这条语句报错。导致紧跟的语句也报错。
--//begin sys.dbms_backup_restore.updateRmanStatusRow( row_id => :row_id, row_stamp => :row_stamp, status => :status); end;
$ rman target sys/oracle | tee bb.txt
....
--//检查跟踪文件:
DBGSQL: TARGET> begin :lprimary_db_cs := sys.dbms_backup_restore.get_connect_identifier (dbuname=> :primary_dbuname); end;
DBGSQL: sqlcode = 0
DBGSQL: B :lprimary_db_cs = book
DBGSQL: B :primary_dbuname = book
DBGRCVMAN: getConfig: configurations exists for this site
--// 这里少了DBGSQL: ENTERED krmkosqlerr对比前面,是否意味这这里就报错了。
DBGSQL: TARGET> declare null_retVal varchar2(1); begin null_retVal := sys.dbms_backup_restore.remoteSQLExecute( source_dbuname=> :primary_dbuname, source_cs => :lprimary_db_cs, stmt => 'alter system archive log current'); end;
DBGSQL: sqlcode = 0
DBGSQL: B :primary_dbuname = book
DBGSQL: B :lprimary_db_cs = book
RMAN-06819: current log archived at primary database
--//可以发现切换成功。
DBGSQL: TARGET> begin :max_first_scn := sys.dbms_backup_restore.remoteSQLExecute( source_dbuname=> :primary_dbuname, source_cs => :lprimary_db_cs, stmt => 'select max(first_change#) from v$log where status = ''CURRENT'''); end;
DBGSQL: sqlcode = 0
DBGSQL: B :max_first_scn = 13277506958
DBGSQL: B :primary_dbuname = book
DBGSQL: B :lprimary_db_cs = book
4.另外一个注意的问题,在备库删除归档,总会保留最后1个不会删除。
RMAN> delete archivelog all ;
released channel: ORA_DISK_1
released channel: ORA_DISK_2
released channel: ORA_DISK_3
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=12 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=73 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=134 device type=DISK
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
archived log file name=/u01/app/oracle/archivelog/book/1_788_896605872.dbf thread=1 sequence=788
List of Archived Log Copies for database with db_unique_name BOOKDG
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - -------------------
94 1 786 A 2018-01-15 11:41:01
Name: /u01/app/oracle/archivelog/book/1_786_896605872.dbf
95 1 787 A 2018-01-15 15:52:08
Name: /u01/app/oracle/archivelog/book/1_787_896605872.dbf
Do you really want to delete the above objects (enter YES or NO)? no
--//而实际上已经应用seq=788的日志。
SYS@bookdg> @ &r/dg/dg
PROCESS PID STATUS CLIENT_P GROUP# THREAD# SEQUENCE# BLOCK# BLOCKS DELAY_MINS
--------- ------- ------------ -------- ------- ------- ---------- ---------- ---------- ----------
ARCH 11680 CONNECTED ARCH N/A 0 0 0 0 0
RFS 696 IDLE ARCH N/A 0 0 0 0 0
RFS 359 IDLE UNKNOWN N/A 0 0 0 0 0
RFS 355 IDLE UNKNOWN N/A 0 0 0 0 0
RFS 691 IDLE LGWR 2 1 789 124 1 0
ARCH 11676 CLOSING ARCH 4 1 788 1 398 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ARCH 11678 CLOSING ARCH 4 1 786 26624 680 0
ARCH 11682 CLOSING ARCH 5 1 787 6144 441 0
MRP0 11879 APPLYING_LOG N/A N/A 1 789 124 102400 0
9 rows selected.
--//而在主库执行可以删除到seq=788 (执行delete archivelog all ;)