背景:在生产环境中由于网络的不稳定,导致主库的日志没有及时的传到备库,从而使备库日志应用短缺处理方法

   
备库:
       
SQL> select process, status, thread#, sequence#, block#, blocks from v$managed_standby;

 

PROCESS   STATUS          THREAD#  SEQUENCE#     BLOCK#     BLOCKS

---------------------------------------------------------------------------------------------------------------------

ARCH      CONNECTED             0          0          0          0

MRP0      WAIT_FOR_GAP          1       4028          0          0

RFS       IDLE                     1       4105     155073       2019

RFS       IDLE                     2       3900     120829        171

SQL> select * from v$archive_gap;

 

   THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#

--------------------- ---------------------- ---------------------------------------

         1          4028           4028

 

 

SQL> select * from v$archived_log where sequence#=4028;

 

no rows selected

 

说明备库缺少 sequence# = 4028 的归档日志,需要手工从主库拷贝到备机,并在备库中注册

 

主库操作

SQL> select name from v$archived_log where thread#=1 and sequence#=4028;

 

NAME

--------------------------------------------------------------------------------------------------------

+WARCH1/swrac/archivelog/2008_04_03/thread_1_seq_4028.341.651024283

 

 

主库操作

SQL> set wrap off

SQL> col owner for a10

SQL> col directory_name for a20

SQL> select * from dba_directories;

 

OWNER      DIRECTORY_NAME       DIRECTORY_PATH

---------- -------------------- ------------------------------------------------

SYS        SOURCEDIR            +WARCH2/swrac/archivelog/2008_04_08

SYS        DP_DIR               /backup/dp_dir

SYS        DPDIR                /backup/expdp0201

SYS        DPDATA               /backup/dpdata

SYS        WORK_DIR             /oracle/oracle/product/10.2.0/rac_db/work

SYS        TEST_DIR             /oracle/oracle/product/10.2.0/rac_db/java

SYS        ADMIN_DIR            /oracle/oracle/product/10.2.0/rac_db/md/admin

SYS        DATA_PUMP_DIR        /oracle/oracle/product/10.2.0/rac_db/rdbms/log/

 

8 rows selected.

 

SQL> create directory asm_dir as '+WARCH1/swrac/archivelog/2008_04_03';

 

SQL>

begin dbms_file_transfer.copy_file('asm_dir','thread_1_seq_4028.341.651024283','dp_dir','thread_1_seq_4028.341.651024283');

end;

/

 

将此文件压缩后传到备机

$ scp thread_1_seq_4028.341.651024283.tar.gz 10.2.14.57:/backup/new

 

在备库上手工注册从主库拷贝来的日志

SQL> alter database register logfile '/backup/new/thread_1_seq_4028.341.651024283';

 

Database altered.