RMAN基础备份数据库

Posted SQLplusDB

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RMAN基础备份数据库相关的知识,希望对你有一定的参考价值。

文章目录

非归档模式下备份

执行命令

SQL> shutdown immediate
SQL> startup mount
[oracle@server1 ~]$ rman target /
RMAN> backup database format '/u01/oracle/full_%U.bak';

执行例:

	[oracle@server1 ~]$ rman target /

	Recovery Manager: Release 11.2.0.3.0 - Production on Sat Jun 8 16:56:51 2019

	Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

	connected to target database: PROD (DBID=421069157, not open)

	RMAN> backup database format '/u01/oracle/full_%U.bak';

	Starting backup at 08-JUN-19
	using target database control file instead of recovery catalog
	allocated channel: ORA_DISK_1
	channel ORA_DISK_1: SID=18 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=00005 name=/u01/oracle/product/11.2.0/dbhome_1/dbs/example01.dbf
	input datafile file number=00001 name=/u01/oracle/oradata/prod/system01.dbf
	input datafile file number=00002 name=/u01/oracle/oradata/prod/sysaux01.dbf
	input datafile file number=00003 name=/u01/oracle/oradata/prod/undotbs01.dbf
	input datafile file number=00004 name=/u01/oracle/product/11.2.0/dbhome_1/dbs/users01.dbf
	input datafile file number=00007 name=/u01/oracle/product/11.2.0/dbhome_1/dbs/oltp01.dbf
	input datafile file number=00006 name=/u01/oracle/product/11.2.0/dbhome_1/dbs/indx01.dbf
	channel ORA_DISK_1: starting piece 1 at 08-JUN-19
	channel ORA_DISK_1: finished piece 1 at 08-JUN-19
	piece handle=/u01/oracle/full_01u3jkt8_1_1.bak tag=TAG20190608T165816 comment=NONE
	channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
	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: starting piece 1 at 08-JUN-19
	channel ORA_DISK_1: finished piece 1 at 08-JUN-19
	piece handle=/u01/oracle/full_02u3jktg_1_1.bak tag=TAG20190608T165816 comment=NONE
	channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
	Finished backup at 08-JUN-19

	RMAN> exit

归档模式下备份

数据库归档(ARCHIVELOG)模式的切换

--确认数据库的归档模式,是否为归档模式
SQL> archive log list
	SQL> archive log list
	Database log mode              No Archive Mode
	Automatic archival             Disabled
	Archive destination            /u01/oracle/product/11.2.0/dbhome_1/dbs/arch
	Oldest online log sequence     5
	Current log sequence           9

---关闭数据库
SQL> shutdown immediate

--mount状态下启动数据库
SQL> startup mount

--切换归档模式
	--启用
	SQL> alter database archivelog;	
	--或者 关闭 
	SQL> alter database noarchivelog;


--完全启动数据库
SQL> alter database open;

--确认数据库的归档模式,是否为归档模式
SQL> archive log list

执行备份

SQL> shutdown immediate
SQL> startup mount
[oracle@server1 ~]$ rman target /

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PROD 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 COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/oracle/product/11.2.0/dbhome_1/dbs/snapcf_PROD.f'; # default

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN> list backup of controlfile;


List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    9.14M      DISK        00:00:01     08-JUN-19
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20190608T165816
        Piece Name: /u01/oracle/full_02u3jktg_1_1.bak
  Control File Included: Ckp SCN: 269004       Ckp time: 08-JUN-19

RMAN>  backup database format '/u01/oracle/archive_full_%U.bak';

Starting backup at 08-JUN-19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 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=00005 name=/u01/oracle/product/11.2.0/dbhome_1/dbs/example01.dbf
input datafile file number=00001 name=/u01/oracle/oradata/prod/system01.dbf
input datafile file number=00002 name=/u01/oracle/oradata/prod/sysaux01.dbf
input datafile file number=00003 name=/u01/oracle/oradata/prod/undotbs01.dbf
input datafile file number=00004 name=/u01/oracle/product/11.2.0/dbhome_1/dbs/users01.dbf
input datafile file number=00007 name=/u01/oracle/product/11.2.0/dbhome_1/dbs/oltp01.dbf
input datafile file number=00006 name=/u01/oracle/product/11.2.0/dbhome_1/dbs/indx01.dbf
channel ORA_DISK_1: starting piece 1 at 08-JUN-19
channel ORA_DISK_1: finished piece 1 at 08-JUN-19
piece handle=/u01/oracle/archive_full_03u3jn3u_1_1.bak tag=TAG20190608T173558 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 08-JUN-19

Starting Control File and SPFILE Autobackup at 08-JUN-19
piece handle=/u01/oracle/product/11.2.0/dbhome_1/dbs/c-421069157-20190608-00 comment=NONE
Finished Control File and SPFILE Autobackup at 08-JUN-19

版权声明:本文为博主原创文章,转载必须注明出处,本人保留一切相关权力!http://blog.csdn.net/lukeunique

欢迎关注微信订阅号:Oracle数据库技术(TeacherWhat)

以上是关于RMAN基础备份数据库的主要内容,如果未能解决你的问题,请参考以下文章

RMAN基础操作

Oracle RMAN备份与还原

Oracle RMAN备份恢复1-基础篇_超越OCP精通Oracle视频教程培训17

linux 下RMAN备份shell脚本

Oracle之RMAN备份恢复1-基础篇

100天精通Oracle-实战系列(第16天)使用 RMAN 备份快速恢复误删数据表