今天开始学习RMAN备份。
本文主要是将关闭的数据库状态修改为开启状态,并对数据库执行全备份。
首先打开oracle服务,进入oracle数据库的sql*plus
[oracle@LabOracle ~]$ sqlplus /nolog
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
查看Target Database的归档模式:
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 5
Current log sequence 7
目前的数据库处于非归档模式,接下来需要将数据库修改为归档模式
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
将数据库置于mount状态,在该状态下修改数据库的归档模式:
SQL> alter database archivelog ;
Database altered.
将数据库置于Open状态
SQL> alter database open;
Database altered.
再次查看数据库的归档模式,此时数据库处于归档模式,
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 5
Next log sequence to archive 7
Current log sequence
退出SQL*PLUS
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
连接到RMAN环境中
[oracle@LabOracle ~]$ rman nocatalog
Recovery Manager: Release 10.2.0.1.0 - Production on ?lh 2? 28 20:38:34 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
查看是否有备份集
RMAN> list backup;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of list command at 02/28/2011 20:38:50
RMAN-06171: not connected to target database
由于没有连接到目标数据库上,报出上面的错误。连接目标数据库
RMAN> connect target /
connected to target database: ORCL (DBID=1267670310)
using target database control file instead of recovery catalog
将数据库进行全备份
RMAN> backup database;
Starting backup at 28-2? -11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1631 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00006 name=/oracle/oradata/orcl/perfstat_01.dbf
input datafile fno=00001 name=/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 28-2? -11
channel ORA_DISK_1: finished piece 1 at 28-2? -11
piece handle=/oracle/flash_recovery_area/ORCL/backupset/2011_02_28/o1_mf_nnndf_TAG20110228T205022_6pq6jhfp_.bkp tag=TAG20110228T205022 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 28-2? -11
channel ORA_DISK_1: finished piece 1 at 28-2? -11
piece handle=/oracle/flash_recovery_area/ORCL/backupset/2011_02_28/o1_mf_ncsnf_TAG20110228T205022_6pq6mjpj_.bkp tag=TAG20110228T205022 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 28-2? -11
全备份完成后,查看备份集,显示出备份集的内容
RMAN> list backupset;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 614.10M DISK 00:01:30 28-2? -11
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20110228T205022
Piece Name: /oracle/flash_recovery_area/ORCL/backupset/2011_02_28/o1_mf_nnndf_TAG20110228T205022_6pq6jhfp_.bkp
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ---------- ----
1 Full 638815 28-2? -11 /oracle/oradata/orcl/system01.dbf
2 Full 638815 28-2? -11 /oracle/oradata/orcl/undotbs01.dbf
3 Full 638815 28-2? -11 /oracle/oradata/orcl/sysaux01.dbf
4 Full 638815 28-2? -11 /oracle/oradata/orcl/users01.dbf
5 Full 638815 28-2? -11 /oracle/oradata/orcl/example01.dbf
6 Full 638815 28-2? -11 /oracle/oradata/orcl/perfstat_01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 6.80M DISK 00:00:03 28-2? -11
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20110228T205022
Piece Name: /oracle/flash_recovery_area/ORCL/backupset/2011_02_28/o1_mf_ncsnf_TAG20110228T205022_6pq6mjpj_.bkp
Control File Included: Ckp SCN: 638878 Ckp time: 28-2? -11
SPFILE Included: Modification time: 28-2? -11
退出RMAN
RMAN> quit
Recovery Manager complete.