1.查看数据库是否处于归档模式:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 73
Next log sequence to archive 75
Current log sequence 75
如果不是归档模式,修改为归档模式。
1.1:启动数据库到mount状态
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1135747072 bytes
Fixed Size 2212656 bytes
Variable Size 687869136 bytes
Database Buffers 436207616 bytes
Redo Buffers 9457664 bytes
Database mounted.
SQL>
1.2开启归档并打开数据库
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
1.3
查看是否处于归档模式。
SQL> archive log list;
2.查看实例名,数据库名,dbid
2.1查看实例名:
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
orcl
SQL>
2.2查看数据库名:
SQL> select name from v$database;
NAME
---------
ORCL
SQL>
2.3查看dbid:
SQL> select dbid from v$database;
DBID
----------
1494590907
3.开始备份:
3.1备份脚本:
run {
Allocate channel rman_1 type disk;
Allocate channel rman_2 type disk;
Allocate channel rman_3 type disk;
sql 'alter system switch logfile';
backup database format '/opt/oracle/backup/df_%T_%U.dbf';
backup current controlfile format '/opt/oracle/backup/cf_%T_%U.ctf';
backup spfile format '/opt/oracle/backup/sp_%T_%U.sp';
sql 'alter system archive log current';
release channel rman_1;
release channel rman_2;
release channel rman_3;
}
备份输出信息:
RMAN> run {
2> Allocate channel rman_1 type disk;
3> Allocate channel rman_2 type disk;
4> Allocate channel rman_3 type disk;
5>
6> sql 'alter system switch logfile';
7> backup database format '/opt/oracle/backup/df_%T_%U.dbf';
8> backup current controlfile format '/opt/oracle/backup/cf_%T_%U.ctf';
9> backup spfile format '/opt/oracle/backup/sp_%T_%U.sp';
10> sql 'alter system archive log current';
11>
12> release channel rman_1;
13> release channel rman_2;
14> release channel rman_3;
15>
16> }
using target database control file instead of recovery catalog
allocated channel: rman_1
channel rman_1: SID=1 device type=DISK
allocated channel: rman_2
channel rman_2: SID=31 device type=DISK
allocated channel: rman_3
channel rman_3: SID=35 device type=DISK
sql statement: alter system switch logfile
Starting backup at 02-JUL-18
channel rman_1: starting full datafile backup set
channel rman_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/home/oracle/app/oradata/orcl/system01.dbf
input datafile file number=00003 name=/home/oracle/app/oradata/orcl/undotbs01.dbf
channel rman_1: starting piece 1 at 02-JUL-18
channel rman_2: starting full datafile backup set
channel rman_2: specifying datafile(s) in backup set
input datafile file number=00002 name=/home/oracle/app/oradata/orcl/sysaux01.dbf
input datafile file number=00004 name=/home/oracle/app/oradata/orcl/users01.dbf
channel rman_2: starting piece 1 at 02-JUL-18
channel rman_3: starting full datafile backup set
channel rman_3: specifying datafile(s) in backup set
including current control file in backup set
channel rman_3: starting piece 1 at 02-JUL-18
channel rman_3: finished piece 1 at 02-JUL-18
piece handle=/opt/oracle/backup/df_20180702_0at716qk_1_1.dbf tag=TAG20180702T213203 comment=NONE
channel rman_3: backup set complete, elapsed time: 00:00:03
channel rman_3: starting full datafile backup set
channel rman_3: specifying datafile(s) in backup set
including current SPFILE in backup set
channel rman_3: starting piece 1 at 02-JUL-18
channel rman_3: finished piece 1 at 02-JUL-18
piece handle=/opt/oracle/backup/df_20180702_0bt716qp_1_1.dbf tag=TAG20180702T213203 comment=NONE
channel rman_3: backup set complete, elapsed time: 00:00:07
channel rman_2: finished piece 1 at 02-JUL-18
piece handle=/opt/oracle/backup/df_20180702_09t716qk_1_1.dbf tag=TAG20180702T213203 comment=NONE
channel rman_2: backup set complete, elapsed time: 00:01:02
channel rman_1: finished piece 1 at 02-JUL-18
piece handle=/opt/oracle/backup/df_20180702_08t716qj_1_1.dbf tag=TAG20180702T213203 comment=NONE
channel rman_1: backup set complete, elapsed time: 00:01:22
Finished backup at 02-JUL-18
Starting backup at 02-JUL-18
channel rman_1: starting full datafile backup set
channel rman_1: specifying datafile(s) in backup set
including current control file in backup set
channel rman_1: starting piece 1 at 02-JUL-18
channel rman_1: finished piece 1 at 02-JUL-18
piece handle=/opt/oracle/backup/cf_20180702_0ct716t7_1_1.ctf tag=TAG20180702T213327 comment=NONE
channel rman_1: backup set complete, elapsed time: 00:00:01
Finished backup at 02-JUL-18
Starting backup at 02-JUL-18
channel rman_1: starting full datafile backup set
channel rman_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel rman_1: starting piece 1 at 02-JUL-18
channel rman_1: finished piece 1 at 02-JUL-18
piece handle=/opt/oracle/backup/sp_20180702_0dt716ta_1_1.sp tag=TAG20180702T213330 comment=NONE
channel rman_1: backup set complete, elapsed time: 00:00:01
Finished backup at 02-JUL-18
sql statement: alter system archive log current
released channel: rman_1
released channel: rman_2
released channel: rman_3
RMAN>
RMAN>
3.2验证备份集:
backup validate database;
RMAN> backup validate database;
Starting backup at 02-JUL-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/home/oracle/app/oradata/orcl/system01.dbf
input datafile file number=00002 name=/home/oracle/app/oradata/orcl/sysaux01.dbf
input datafile file number=00003 name=/home/oracle/app/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/home/oracle/app/oradata/orcl/users01.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
1 OK 0 16297 89600 664655
File Name: /home/oracle/app/oradata/orcl/system01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 58172
Index 0 12108
Other 0 3023
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
2 OK 0 35603 76800 664236
File Name: /home/oracle/app/oradata/orcl/sysaux01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 9957
Index 0 7241
Other 0 23999
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
3 OK 0 645 69760 664655
File Name: /home/oracle/app/oradata/orcl/undotbs01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 0
Index 0 0
Other 0 69115
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
4 OK 0 513 640 12429
File Name: /home/oracle/app/oradata/orcl/users01.dbf
Block Type Blocks Failing Blocks Processed
---------- -------------- ----------------
Data 0 0
Index 0 0
Other 0 127
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
List of Control File and SPFILE
===============================
File Type Status Blocks Failing Blocks Examined
------------ ------ -------------- ---------------
SPFILE OK 0 2
Control File OK 0 594
Finished backup at 02-JUL-18
RMAN>
查看备份集:
[oracle@localhost backup]$ ls -al
total 972596
drwxr-xr-x. 2 oracle dba 4096 Jul 2 21:33 .
drwxr-xr-x. 3 oracle dba 20 Jul 2 21:31 ..
-rw-r-----. 1 oracle dba 9797632 Jul 2 21:33 cf_20180702_0ct716t7_1_1.ctf
-rw-r-----. 1 oracle dba 616103936 Jul 2 21:33 df_20180702_08t716qj_1_1.dbf
-rw-r-----. 1 oracle dba 360038400 Jul 2 21:32 df_20180702_09t716qk_1_1.dbf
-rw-r-----. 1 oracle dba 9797632 Jul 2 21:32 df_20180702_0at716qk_1_1.dbf
-rw-r-----. 1 oracle dba 98304 Jul 2 21:32 df_20180702_0bt716qp_1_1.dbf
-rw-r-----. 1 oracle dba 98304 Jul 2 21:33 sp_20180702_0dt716ta_1_1.sp
[oracle@localhost backup]$