切换主库日志的脚本 logswitch.sh:
sqlplus -s "sys/<passwd>@<primary_db> as sysdba" <<EOF alter system archive log current; exit EOF
先备份数据库,再运行脚本切换主库的日志,再备份归档日志,具体步骤:
[oracle@dg121-2 ~]$ rman target / Recovery Manager: Release 12.1.0.2.0 - Production on Tue Sep 8 19:19:07 2020 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: ORCL (DBID=1461820645, not open) RMAN> run{ allocate channel c1 type 'sbt_tape' parms=' SBT_LIBRARY=/opt/scutech/dbackup3/lib/libobk.so, ENV=(URL=http://192.168.87.155:50306/d2/data/0d36020eecec11ea8000b49691622ac4/c7873e9aed0811ea8000b49691622ac4, EXTRA=X-Access-Key:ea5350ac00fa61d08533a729da808de0)' trace=0; backup database plus archivelog delete input; } RMAN> 2> 3> 4> 5> 6> 7> using target database control file instead of recovery catalog allocated channel: c1 channel c1: SID=363 device type=SBT_TAPE channel c1: DBackup3 Oracle MMS Library Starting backup at Sep 08 2020 19:19:14 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 ...... RMAN> host '/home/oracle/logswitch.sh'; System altered. host command complete RMAN> run{ allocate channel c1 type 'sbt_tape' parms=' SBT_LIBRARY=/opt/scutech/dbackup3/lib/libobk.so, ENV=(URL=http://192.168.87.155:50306/d2/data/0d36020eecec11ea8000b49691622ac4/c7873e9aed0811ea8000b49691622ac4, EXTRA=X-Access-Key:ea5350ac00fa61d08533a729da808de0)' trace=0; backup archivelog all delete input; } RMAN> 2> 3> 4> 5> 6> 7> released channel: ORA_DISK_1 allocated channel: c1 channel c1: SID=363 device type=SBT_TAPE channel c1: DBackup3 Oracle MMS Library Starting backup at Sep 08 2020 19:21:41 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 channel c1: starting archived log backup set channel c1: specifying archived log(s) in backup set input archived log thread=1 sequence=273 RECID=166 STAMP=1050607241 channel c1: starting piece 1 at Sep 08 2020 19:21:41 channel c1: finished piece 1 at Sep 08 2020 19:21:42 piece handle=4uv9tvm5_1_1 tag=TAG20200908T192141 comment=API Version 2.0,MMS Version 8.2.64.76 channel c1: backup set complete, elapsed time: 00:00:01 channel c1: deleting archived log(s) RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process archived log file name=/u01/app/oracle/oradata/cdr1/arc/ORCL1BY/archivelog/2020_09_08/o1_mf_1_273_hogt892p_.arc thread=1 sequence=273 Finished backup at Sep 08 2020 19:21:42 released channel: c1 RMAN>