分类: Oracle
2011-07-14 01:40:13
rman可以连接的数据库的类型:
1. target database
2. recovery catalog database
3. auxiliary database
[root@station23 ~]# find / -name rman
/u01/app/oracle/product/10.2.0/db_1/oc4j/j2ee/oc4j_applications/applications/em/em/database/rman
/u01/app/oracle/product/10.2.0/db_1/oc4j/j2ee/oc4j_applications/applications/em/em/WEB-INF/perl/db/rman
/u01/app/oracle/product/10.2.0/db_1/bin/rman
/u01/app/oracle/product/10.2.0/db_1/sysman/admin/scripts/db/rman
[root@station23 ~]# su - oracle
[oracle@station23 ~]$ vim ./.bash_profile
#Oracle Settings
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin
改成
#Oracle Settings
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH
[oracle@station23 ~]$ source .bash_profile
[oracle@station23 ~]$ $PATH
-bash: /u01/app/oracle/product/10.2.0/db_1/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/u01/app/oracle/product/10.2.0/db_1/bin:/home/oracle/bin: No such file or directory
[oracle@station23 ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jul 9 17:39:16 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 2
Current log sequence 4
SQL>
切换到archive log模式
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 683671552 bytes
Fixed Size 1221276 bytes
Variable Size 192941412 bytes
Database Buffers 486539264 bytes
Redo Buffers 2969600 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> archive log start
Statement processed.
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 2
Next log sequence to archive 4
Current log sequence 4
SQL>
非catalog方式
l 全备份
l 0级增量备份
l 1级增量备份
[oracle@station23 ~]$ rman
Recovery Manager: Release 10.2.0.1.0 - Production on Sat Jul 9 18:00:41 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> connect target /
connected to target database: ORCL (DBID=1267524952)
using target database control file instead of recovery catalog
RMAN> list backupset;
RMAN>
没有备份,做一个full database backup
RMAN> backup database;
Starting backup at 09-JUL-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=144 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 09-JUL-11
channel ORA_DISK_1: finished piece 1 at 09-JUL-11
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_nnndf_TAG20110709T180445_71j9xy1s_.bkp tag=TAG20110709T180445 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:17:08
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 09-JUL-11
channel ORA_DISK_1: finished piece 1 at 09-JUL-11
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_ncsnf_TAG20110709T180445_71jby8bw_.bkp tag=TAG20110709T180445 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:10
Finished backup at 09-JUL-11
RMAN> list backupset;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 581.56M DISK 00:17:01 09-JUL-11
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20110709T180445
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_nnndf_TAG20110709T180445_71j9xy1s_.bkp
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 519401 09-JUL-11 /u01/app/oracle/oradata/orcl/system01.dbf
2 Full 519401 09-JUL-11 /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 Full 519401 09-JUL-11 /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 Full 519401 09-JUL-11 /u01/app/oracle/oradata/orcl/users01.dbf
5 Full 519401 09-JUL-11 /u01/app/oracle/oradata/orcl/example01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 6.80M DISK 00:00:08 09-JUL-11
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20110709T180445
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_ncsnf_TAG20110709T180445_71jby8bw_.bkp
Control File Included: Ckp SCN: 519570 Ckp time: 09-JUL-11
SPFILE Included: Modification time: 09-JUL-11
RMAN> quit
[oracle@station23 ~]$ cd /u01/app/oracle/flash_recovery_area/ORCL/backupset/
[oracle@station23 backupset]$ ls
2011_07_09
[oracle@station23 backupset]$ cd 2011_07_09/
[oracle@station23 2011_07_09]$ ll -h
total 589M
-rw-r----- 1 oracle oinstall 6.9M Jul 9 18:22 o1_mf_ncsnf_TAG20110709T180445_71jby8bw_.bkp
-rw-r----- 1 oracle oinstall 582M Jul 9 18:21 o1_mf_nnndf_TAG20110709T180445_71j9xy1s_.bkp
查看rman缺省参数设定
[oracle@station23 2011_07_09]$ rman
Recovery Manager: Release 10.2.0.1.0 - Production on Sat Jul 9 18:42:19 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> connect target /
connected to target database: ORCL (DBID=1267524952)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_orcl.f'; # default
RMAN> quit
查看备份信息
[oracle@station23 dbs]$ cd /u01/app/oracle/oradata/orcl/
[oracle@station23 orcl]$ ls
control01.ctl control03.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
control02.ctl example01.dbf redo02.log sysaux01.dbf temp01.dbf users01.dbf
[oracle@station23 orcl]$ strings control01.ctl
}|{z
KORCL
,ORCL
,ORCL
orcl
orcl
/u01/app/oracle/oradata/orcl/redo03.log
/u01/app/oracle/oradata/orcl/redo02.log
/u01/app/oracle/oradata/orcl/redo01.log
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/temp01.dbf
/u01/app/oracle/oradata/orcl/example01.dbf
/u01/app/oracle/oradata/orcl/redo03.log
/u01/app/oracle/oradata/orcl/redo02.log
/u01/app/oracle/oradata/orcl/redo01.log
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/temp01.dbf
/u01/app/oracle/oradata/orcl/example01.dbf
SYSTEM
UNDOTBS1
SYSAUX
USERS
TEMP
EXAMPLE
SYSTEM
UNDOTBS1
SYSAUX
USERS
TEMP
EXAMPLE
DISK
/u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_nnndf_TAG20110709T180445_71j9xy1s_.bkp
TAG20110709T180445
DISK
/u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_ncsnf_TAG20110709T180445_71jby8bw_.bkp
TAG20110709T180445
DISK
/u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_nnndf_TAG20110709T180445_71j9xy1s_.bkp
TAG20110709T180445
u01/app/oracle/oradata/orcl/example01.dbf
/u01/app/oracle/oradata/orcl/example01.dbf
2011-07-09T18:00:41
RMAN
2011-07-09T18:00:41
list
2011-07-09T18:00:41
backup
2011-07-09T18:00:41
list
2011-07-09T18:42:19
RMAN
2011-07-09T18:00:41
RMAN
2011-07-09T18:00:41
list
2011-07-09T18:00:41
backup
2011-07-09T18:00:41
list
2011-07-09T18:42:19
RMAN
orcl
UNNAMED_INSTANCE_2
UNNAMED_INSTANCE_3
UNNAMED_INSTANCE_4
UNNAMED_INSTANCE_5
UNNAMED_INSTANCE_6
UNNAMED_INSTANCE_7
UNNAMED_INSTANCE_8
UNNAMED_INSTANCE_1
UNNAMED_INSTANCE_2
UNNAMED_INSTANCE_3
UNNAMED_INSTANCE_4
UNNAMED_INSTANCE_5
UNNAMED_INSTANCE_6
UNNAMED_INSTANCE_7
UNNAMED_INSTANCE_8
[oracle@station23 orcl]$
0级增量备份
RMAN> backup incremental level 0 database;
RMAN> list backupset;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 581.56M DISK 00:17:01 09-JUL-11
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20110709T180445
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_nnndf_TAG20110709T180445_71j9xy1s_.bkp
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 519401 09-JUL-11 /u01/app/oracle/oradata/orcl/system01.dbf
2 Full 519401 09-JUL-11 /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 Full 519401 09-JUL-11 /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 Full 519401 09-JUL-11 /u01/app/oracle/oradata/orcl/users01.dbf
5 Full 519401 09-JUL-11 /u01/app/oracle/oradata/orcl/example01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 6.80M DISK 00:00:08 09-JUL-11
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20110709T180445
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_ncsnf_TAG20110709T180445_71jby8bw_.bkp
Control File Included: Ckp SCN: 519570 Ckp time: 09-JUL-11
SPFILE Included: Modification time: 09-JUL-11
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Incr 0 582.33M DISK 00:10:24 09-JUL-11
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20110709T185731
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_nnnd0_TAG20110709T185731_71jf0vv3_.bkp
List of Datafiles in backup set 3
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 0 Incr 520694 09-JUL-11 /u01/app/oracle/oradata/orcl/system01.dbf
2 0 Incr 520694 09-JUL-11 /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 0 Incr 520694 09-JUL-11 /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 0 Incr 520694 09-JUL-11 /u01/app/oracle/oradata/orcl/users01.dbf
5 0 Incr 520694 09-JUL-11 /u01/app/oracle/oradata/orcl/example01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Incr 0 6.80M DISK 00:00:10 09-JUL-11
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20110709T185731
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_ncsn0_TAG20110709T185731_71jfnscl_.bkp
Control File Included: Ckp SCN: 520966 Ckp time: 09-JUL-11
SPFILE Included: Modification time: 09-JUL-11
RMAN>
1级增量备份
RMAN> backup incremental level 1 database;
备份archivelog
backup database plus archivelog delete input; //这条命令备份所有的文件并在备份完后删除archive log
/ 代表当前数据库
[oracle@station23 orcl]$ rman
RMAN> connect target sys/oracle
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
ORA-12154: TNS:could not resolve the connect identifier specified
RMAN> quit
Recovery Manager complete.
[oracle@station23 orcl]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 09-JUL-2011 22:09:24
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=station23.example.com)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 09-JUL-2011 22:09:25
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=station23.example.com)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@station23 orcl]$ lsnrctl service
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 09-JUL-2011 22:10:05
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:1 refused:0 state:ready
LOCAL SERVER
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Handler(s):
"D000" established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=station23.example.com)(PORT=4427))
Service "orcl_XPT" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:1 refused:0 state:ready
LOCAL SERVER
The command completed successfully
[oracle@station23 orcl]$rman
RMAN> connect target sys/oracle
connected to target database: ORCL (DBID=1267524952)
RMAN> backup database plus archivelog delete input;
Starting backup at 09-JUL-11
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=133 devtype=DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=4 recid=1 stamp=756080283
channel ORA_DISK_1: starting piece 1 at 09-JUL-11
channel ORA_DISK_1: finished piece 1 at 09-JUL-11
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_annnn_TAG20110709T221809_71jrs5rv_.bkp tag=TAG20110709T221809 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:47
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_07_09/o1_mf_1_4_71jrqcc2_.arc recid=1 stamp=756080283
Finished backup at 09-JUL-11
Starting backup at 09-JUL-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 09-JUL-11
channel ORA_DISK_1: finished piece 1 at 09-JUL-11
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_nnndf_TAG20110709T221900_71jrv397_.bkp tag=TAG20110709T221900 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:15:47
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 09-JUL-11
channel ORA_DISK_1: finished piece 1 at 09-JUL-11
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_ncsnf_TAG20110709T221900_71jsrdj6_.bkp tag=TAG20110709T221900 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08
Finished backup at 09-JUL-11
Starting backup at 09-JUL-11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=5 recid=2 stamp=756081296
channel ORA_DISK_1: starting piece 1 at 09-JUL-11
channel ORA_DISK_1: finished piece 1 at 09-JUL-11
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_annnn_TAG20110709T223456_71jsrl1o_.bkp tag=TAG20110709T223456 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_07_09/o1_mf_1_5_71jsrjnd_.arc recid=2 stamp=756081296
Finished backup at 09-JUL-11
RMAN> list backupset;
------- ---------- ----------- ------------ ---------------
5 40.47M DISK 00:00:38 09-JUL-11
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20110709T221809
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_annnn_TAG20110709T221809_71jrs5rv_.bkp
List of Archived Logs in backup set 5
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 4 515909 04-JUL-11 525700 09-JUL-11
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6 Full 588.84M DISK 00:15:43 09-JUL-11
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20110709T221900
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_nnndf_TAG20110709T221900_71jrv397_.bkp
List of Datafiles in backup set 6
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 525725 09-JUL-11 /u01/app/oracle/oradata/orcl/system01.dbf
2 Full 525725 09-JUL-11 /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 Full 525725 09-JUL-11 /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 Full 525725 09-JUL-11 /u01/app/oracle/oradata/orcl/users01.dbf
5 Full 525725 09-JUL-11 /u01/app/oracle/oradata/orcl/example01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7 Full 6.80M DISK 00:00:06 09-JUL-11
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20110709T221900
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_ncsnf_TAG20110709T221900_71jsrdj6_.bkp
Control File Included: Ckp SCN: 526063 Ckp time: 09-JUL-11
SPFILE Included: Modification time: 09-JUL-11
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
8 607.50K DISK 00:00:01 09-JUL-11
BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20110709T223456
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_annnn_TAG20110709T223456_71jsrl1o_.bkp
List of Archived Logs in backup set 8
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 5 525700 09-JUL-11 526074 09-JUL-11
RMAN>
备份表空间
backup tablespace 表空间名
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_orcl.f'; # default
RMAN> report schema;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 480 SYSTEM *** /u01/app/oracle/oradata/orcl/system01.dbf
2 25 UNDOTBS1 *** /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 240 SYSAUX *** /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 5 USERS *** /u01/app/oracle/oradata/orcl/users01.dbf
5 100 EXAMPLE *** /u01/app/oracle/oradata/orcl/example01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /u01/app/oracle/oradata/orcl/temp01.dbf
RMAN> backup tablespace example;
Starting backup at 09-JUL-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: starting piece 1 at 09-JUL-11
channel ORA_DISK_1: finished piece 1 at 09-JUL-11
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_nnndf_TAG20110709T225720_71jv2jht_.bkp tag=TAG20110709T225720 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:41
Finished backup at 09-JUL-11
RMAN> list backupset;
------- ---- -- ---------- ----------- ------------ ---------------
9 Full 56.37M DISK 00:01:31 09-JUL-11
BP Key: 9 Status: AVAILABLE Compressed: NO Tag: TAG20110709T225720
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_nnndf_TAG20110709T225720_71jv2jht_.bkp
List of Datafiles in backup set 9
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
5 Full 527727 09-JUL-11 /u01/app/oracle/oradata/orcl/example01.dbf
RMAN>
备份控制文件(两种方式)
backup current controlfile
backup database include current controlfile
RMAN> backup current controlfile;
Starting backup at 09-JUL-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 09-JUL-11
channel ORA_DISK_1: finished piece 1 at 09-JUL-11
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_ncnnf_TAG20110709T231041_71jvvlhr_.bkp tag=TAG20110709T231041 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:09
Finished backup at 09-JUL-11
RMAN> list backupset;
------- ---- -- ---------- ----------- ------------ ---------------
10 Full 6.77M DISK 00:00:04 09-JUL-11
BP Key: 10 Status: AVAILABLE Compressed: NO Tag: TAG20110709T231041
Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/backupset/2011_07_09/o1_mf_ncnnf_TAG20110709T231041_71jvvlhr_.bkp
Control File Included: Ckp SCN: 528602 Ckp time: 09-JUL-11
RMAN>
镜像备份
copy datafile … to …
RMAN> report schema;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 480 SYSTEM *** /u01/app/oracle/oradata/orcl/system01.dbf
2 25 UNDOTBS1 *** /u01/app/oracle/oradata/orcl/undotbs01.dbf
3 240 SYSAUX *** /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 5 USERS *** /u01/app/oracle/oradata/orcl/users01.dbf
5 100 EXAMPLE *** /u01/app/oracle/oradata/orcl/example01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /u01/app/oracle/oradata/orcl/temp01.dbf
RMAN>
[oracle@station23 ~]$ cd /u01/app/
[oracle@station23 app]$ ls
oracle
[oracle@station23 app]$ mkdir rmanbak
[oracle@station23 app]$ ll
total 8
drwxr-xr-x 7 oracle oinstall 4096 Jan 6 2011 oracle
drwxr-xr-x 2 oracle oinstall 4096 Jul 9 23:20 rmanbak
RMAN> copy datafile 5 to '/u01/app/rmanbak/examplebak.dbf';
Starting backup at 09-JUL-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
output filename=/u01/app/rmanbak/examplebak.dbf tag=TAG20110709T232258 recid=2 stamp=756084237
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:07
Finished backup at 09-JUL-11
RMAN>
用list backupset看不到,因为它不是备份集,要用list copy来看
RMAN> list copy;
specification does not match any archive log in the recovery catalog
List of Datafile Copies
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
2 5 A 09-JUL-11 529291 09-JUL-11 /u01/app/rmanbak/examplebak.dbf
RMAN>
[oracle@station23 orcl]$ ls /u01/app/rmanbak/ -lh
total 101M
-rw-r----- 1 oracle oinstall 101M Jul 9 23:23 examplebak.dbf
批命令
RMAN> run {
2> allocate channel cha1 type disk;
3> backup format '/u01/app/rmanbak/full_%t'
4> tag full_backup_bat
5> database;
6> release channel cha1;
7> }
using target database control file instead of recovery catalog
allocated channel: cha1
channel cha1: sid=128 devtype=DISK
Starting backup at 10-JUL-11
channel cha1: starting full datafile backupset
channel cha1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel cha1: starting piece 1 at 10-JUL-11
channel cha1: finished piece 1 at 10-JUL-11
piece handle=/u01/app/rmanbak/full_756127537 tag=FULL_BACKUP_BAT comment=NONE
channel cha1: backup set complete, elapsed time: 00:21:35
channel cha1: starting full datafile backupset
channel cha1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel cha1: starting piece 1 at 10-JUL-11
channel cha1: finished piece 1 at 10-JUL-11
piece handle=/u01/app/rmanbak/full_756128832 tag=FULL_BACKUP_BAT comment=NONE
channel cha1: backup set complete, elapsed time: 00:00:18
Finished backup at 10-JUL-11
released channel: cha1
RMAN>
[oracle@station23 orcl]$ ls /u01/app/rmanbak/ -lh
total 700M
-rw-r----- 1 oracle oinstall 101M Jul 9 23:23 examplebak.dbf
-rw-r----- 1 oracle oinstall 593M Jul 10 11:47 full_756127537
-rw-r----- 1 oracle oinstall 6.9M Jul 10 11:47 full_756128832
[oracle@station23 orcl]$
备份脚本
[oracle@station23 rmanbak]$ mkdir script
[oracle@station23 rmanbak]$ pwd
/u01/app/rmanbak
[oracle@station23 script]$ vim bakl0
run {
allocate channel c1 type disk;
backup
incremental level 0
format "/u01/app/rmanbak/inc0_%u_%T"
tag monday_inc0
database;
release channel c1;
}
[oracle@station23 ~]$ rman target / msglog=/u01/app/rmanbak/bakl0.log cmdfile=/u01/app/rmanbak/script/bakl0
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> [oracle@station23 ~]$ ls /u01/app/rmanbak/ -lh
total 1.3G
-rw-r--r-- 1 oracle oinstall 1.7K Jul 10 12:15 bakl0.log
-rw-r----- 1 oracle oinstall 593M Jul 10 12:14 inc0_0emh383g_20110710
-rw-r----- 1 oracle oinstall 6.9M Jul 10 12:15 inc0_0fmh38lu_20110710
drwxr-xr-x 2 oracle oinstall 4.0K Jul 10 12:00 script
[oracle@station23 ~]$ cat /u01/app/rmanbak/bakl0.log
Recovery Manager: Release 10.2.0.1.0 - Production on Sun Jul 10 12:05:01 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1267524952)
RMAN> run {
2> allocate channel c1 type disk;
3> backup
4> incremental level 0
5> format "/u01/app/rmanbak/inc0_%u_%T"
6> tag monday_inc0
7> database;
8> release channel c1;
9> }
10>
11>
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=143 devtype=DISK
Starting backup at 10-JUL-11
channel c1: starting incremental level 0 datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel c1: starting piece 1 at 10-JUL-11
channel c1: finished piece 1 at 10-JUL-11
piece handle=/u01/app/rmanbak/inc0_0emh383g_20110710 tag=MONDAY_INC0 comment=NONE
channel c1: backup set complete, elapsed time: 00:09:48
channel c1: starting incremental level 0 datafile backupset
channel c1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel c1: starting piece 1 at 10-JUL-11
channel c1: finished piece 1 at 10-JUL-11
piece handle=/u01/app/rmanbak/inc0_0fmh38lu_20110710 tag=MONDAY_INC0 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:11
Finished backup at 10-JUL-11
released channel: c1
Recovery Manager complete.
[oracle@station23 ~]$ crontab -e
[oracle@station23 ~]$ crontab -l
45 23 * * 0 rman target / msglog=bakl0.log cmdfile=bakl0
45 23 * * 1 rman target / msglog=bakl2.log cmdfile=bakl2
45 23 * * 2 rman target / msglog=bakl2.log cmdfile=bakl2
45 23 * * 3 rman target / msglog=bakl1.log cmdfile=bakl1
45 23 * * 4 rman target / msglog=bakl2.log cmdfile=bakl2
45 23 * * 5 rman target / msglog=bakl2.log cmdfile=bakl2
45 23 * * 6 rman target / msglog=bakl2.log cmdfile=bakl2
[oracle@station23 ~]$