一个经典的备份语句:backup database plus archivelog;
完成的4个步骤:
- 备份现有的归档日志
- 备份数据文件
- 归档当前日志
- 再次备份归档日志
在备库上执行这条语句在第3步时可能会遇到问题。
用os用户登录rman时,不能滚主库的归档
[oracle@dg121-2 ~]$ rman target / Recovery Manager: Release 12.1.0.2.0 - Production on Tue Sep 8 19:29:13 2020 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: ORCL (DBID=1461820645, not open) 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:29:24 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
用数据库用户sys或sysbackup登录可以滚主库的归档
[oracle@dg121-2 ~]$ rman target sys/dingjia Recovery Manager: Release 12.1.0.2.0 - Production on Tue Sep 8 19:31:14 2020 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: ORCL (DBID=1461820645, not open) RM RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-00558: error encountered while parsing input commands RMAN-01009: syntax error: found "identifier": expecting one of: "advise, allocate, alter, analyze, associate statistics, audit, backup, begin, @, call, catalog, change, comment, commit, configure, connect, convert, copy, create, create catalog, create global, create script, create virtual, crosscheck, declare, delete, delete from, describe, describe catalog, disassociate statistics, drop, drop catalog, drop database, duplicate, exit, explain plan, flashback, flashback table, grant, grant catalog, grant register, host, import, insert, list, lock, merge, mount, noaudit, open, print, purge, quit, recover, register, release, rename, repair, replace, report, " RMAN-01008: the bad identifier was: � RMAN-01007: at line 1 column 1 file: standard input 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:31:31 current log archived at primary database 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 input archived log thread=1 sequence=274 RECID=167 STAMP=1050607891 .....
检查备份集
RMAN> list backup summary; 163 B A A SBT_TAPE Sep 08 2020 19:31:34 1 1 NO TAG20200908T193133 164 B F A SBT_TAPE Sep 08 2020 19:32:02 1 1 NO TAG20200908T193135 165 B F A SBT_TAPE Sep 08 2020 19:32:21 1 1 NO TAG20200908T193135 166 B F A SBT_TAPE Sep 08 2020 19:32:31 1 1 NO TAG20200908T193135 167 B F A SBT_TAPE Sep 08 2020 19:32:34 1 1 NO TAG20200908T193135 168 B A A SBT_TAPE Sep 08 2020 19:32:36 1 1 NO TAG20200908T193236 RMAN> list backup tag TAG20200908T193236; List of Backup Sets =================== BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ -------------------- 168 256.00K SBT_TAPE 00:00:00 Sep 08 2020 19:32:36 BP Key: 168 Status: AVAILABLE Compressed: NO Tag: TAG20200908T193236 Handle: 59v9u0ak_1_1 Media: 59v9u0ak_1_1 List of Archived Logs in backup set 168 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- -------------------- ---------- --------- 1 275 10389987 Sep 08 2020 19:31:11 10390124 Sep 08 2020 19:32:14
我们可以看到最后一个备份集是归档日志,这个归档日志的时间范围正好cover整个备份过程,当然我们这个备份的时间跨度不算长,我们有客户100多T的数据库,通过光纤备份要10多个小时,在备份过程中大约会产生1T的数据,这样最后一个归档的备份集就不只包含一个归档日志了。