Chinaunix首页 | 论坛 | 博客
  • 博客访问: 656443
  • 博文数量: 244
  • 博客积分: 9445
  • 博客等级: 中将
  • 技术积分: 2572
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-11 16:39
个人简介

简单点,再简单点

文章分类

全部博文(244)

文章存档

2020年(2)

2019年(1)

2018年(2)

2014年(2)

2013年(4)

2012年(13)

2011年(24)

2010年(12)

2009年(34)

2008年(61)

2007年(51)

2006年(38)

我的朋友

分类: Oracle

2006-09-25 16:56:54

首先对数据库进行好必要的设置,将数据库设置为归档模式(archivelog)
$ sqlplus '/ as sysdba'
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /space/orcl9i/oradata/beta9i/archive
Oldest online log sequence     1
Next log sequence to archive   3
Current log sequence           3
SQL>

使用RMAN连接到目标数据库进行备份
$ rman target /
RMAN> list backup of database;
using target database controlfile instead of recovery catalog
RMAN> show all;
using target database controlfile 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; # 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 SNAPSHOT CONTROLFILE NAME TO '/space/orcl9i/dbs/snapcf_beta9i.f'; # default
RMAN> run {
2> backup database format '/space/beta9i/%d_%T_%s' tag='fullbak';
3> sql 'alter system archive log current';
4> }
Starting backup at 25-NOV-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=17 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
including current controlfile in backupset
input datafile fno=00001 name=/space/orcl9i/oradata/beta9i/system01.dbf
input datafile fno=00002 name=/space/orcl9i/oradata/beta9i/undotbs01.dbf
input datafile fno=00005 name=/space/orcl9i/oradata/beta9i/example01.dbf
input datafile fno=00010 name=/space/orcl9i/oradata/beta9i/xdb01.dbf
input datafile fno=00006 name=/space/orcl9i/oradata/beta9i/indx01.dbf
input datafile fno=00009 name=/space/orcl9i/oradata/beta9i/users01.dbf
input datafile fno=00003 name=/space/orcl9i/oradata/beta9i/cwmlite01.dbf
input datafile fno=00004 name=/space/orcl9i/oradata/beta9i/drsys01.dbf
input datafile fno=00007 name=/space/orcl9i/oradata/beta9i/odm01.dbf
input datafile fno=00008 name=/space/orcl9i/oradata/beta9i/tools01.dbf
channel ORA_DISK_1: starting piece 1 at 25-NOV-05
channel ORA_DISK_1: finished piece 1 at 25-NOV-05
piece handle=/space/beta9i/BETA9I_20051125_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:10
Finished backup at 25-NOV-05
sql statement: alter system archive log current
在备份结束后,再查询相关系统信息
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /space/orcl9i/oradata/beta9i/archive
Oldest online log sequence     2
Next log sequence to archive   4
Current log sequence           4
发现数据库进行了归档操作(因为备份脚本中使用了alter system archive log current命令)。
RMAN> list backup of database;
List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1       Full    540M       DISK        00:01:03     25-NOV-05
        BP Key: 1   Status: AVAILABLE   Tag: FULLBAK
        Piece Name: /space/beta9i/BETA9I_20051125_1
  List of Datafiles in backup set 1
  File LV   Type Ckp SCN    Ckp Time       Name
  ---- ----  ------ ------------  ---------------- --------------------------------------------------------
  1            Full   456898     25-NOV-05    /space/orcl9i/oradata/beta9i/system01.dbf
  2            Full   456898     25-NOV-05    /space/orcl9i/oradata/beta9i/undotbs01.dbf
  3            Full   456898     25-NOV-05    /space/orcl9i/oradata/beta9i/cwmlite01.dbf
  4            Full   456898     25-NOV-05    /space/orcl9i/oradata/beta9i/drsys01.dbf
  5            Full   456898     25-NOV-05    /space/orcl9i/oradata/beta9i/example01.dbf
  6            Full   456898     25-NOV-05    /space/orcl9i/oradata/beta9i/indx01.dbf
  7            Full   456898     25-NOV-05    /space/orcl9i/oradata/beta9i/odm01.dbf
  8            Full   456898     25-NOV-05    /space/orcl9i/oradata/beta9i/tools01.dbf
  9            Full   456898     25-NOV-05    /space/orcl9i/oradata/beta9i/users01.dbf
  10          Full   456898     25-NOV-05    /space/orcl9i/oradata/beta9i/xdb01.dbf
在备份结束后,可以查询到相关的备份信息,该信息记录在控制文件中。
$ ls -l /space/beta9i/BETA9I_20051125_1
-rw-r-----   1 orcl9i   dba      568991744 Nov 25 09:51 /space/beta9i/BETA9I_200
51125_1
在文件系统下生成了相应的备份文件。
 
在RMAN中使用Recovery Catalog
1.创建Recovery Catalog的Owner
$ sqlplus '/ as sysdba'
SQL> create user rmanuser identified by rmanuser
  2  temporary tablespace temp
  3  default tablespace tools
  4  quota unlimited on tools;
User created.
SQL>grant recovery_catalog_owner to rmanuser;
Grant succeeded.
SQL> grant connect,resource to rmanuser;
Grant succeeded.
注:也可以创建自己的表空间来存放Recovery Catalog的系统表。
2.创建Recovery Catalog
$ rman catalog
RMAN> create catalog;
3.在Recovery Catalog中注册target数据库
$ rman target catalog
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
4.最后进行一下简单测试
RMAN> report schema;
Report of database schema
File K-bytes    Tablespace   RB segs Datafile Name
---- ------------ ---------------- ----------- -------------------
1     409600    SYSTEM         YES         /space/orcl9i/oradata/beta9i/system01.dbf
2     204800    UNDOTBS1    YES         /space/orcl9i/oradata/beta9i/undotbs01.dbf
3     20480      CWMLITE      NO          /space/orcl9i/oradata/beta9i/cwmlite01.dbf
4     20480      DRSYS           NO          /space/orcl9i/oradata/beta9i/drsys01.dbf
5     152960    EXAMPLE       NO          /space/orcl9i/oradata/beta9i/example01.dbf
6     25600      INDX              NO          /space/orcl9i/oradata/beta9i/indx01.dbf
7     20480      ODM              NO          /space/orcl9i/oradata/beta9i/odm01.dbf
8     10240      TOOLS           NO          /space/orcl9i/oradata/beta9i/tools01.dbf
9     25600      USERS           NO          /space/orcl9i/oradata/beta9i/users01.dbf
10   39040      XDB               NO          /space/orcl9i/oradata/beta9i/xdb01.dbf
至此,Recovery Catalog的环境已经创建成功,接下来我们就可以在RMAN中使用Recovery Catalog来进行备份。
阅读(812) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~