Decode360's Blog

业精于勤而荒于嬉 QQ:150355677 MSN:decode360@hotmail.com

  BlogJava :: 首页 :: 新随笔 :: 联系 ::  :: 管理 ::
  397 随笔 :: 33 文章 :: 29 评论 :: 0 Trackbacks
RMAN学习笔记01——登录
 
 
    从今天开始学习一下RMAN的使用。RMAN在Oracle中的重要性就不用多说了,反正要备份数据库不用RMAN是不可想象的。所以明确一下 RMAN的细节用法是非常必要的,从今天开始花几天时间从各个方面学习一下详细用法。本文很大程度上参考了junsansi大牛的《一步一步学RMAN》,另外参考了一些Oracle基础读物。下面开始,首先是使用RMAN前的一些准备工作。
 
 
1、使用RMAN时,需要将数据库设置为归档模式
 
SQL> conn sys/sys as sysdba

Connected.

SQL> show user

USER is "SYS"

SQL> archive log list

Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            D:\oracle\oradata\dodo\archive
Oldest online log sequence     26
Next log sequence to archive   28
Current log sequence           28
 
开启归档方法:
a. shutdown immediate
b. startup mount
c. alter database archivelog
d. alter database opne

 
禁止归档方法:
a.
shutdown immediate
b. startup mount
c. alter database noarchivelog
d. alter database open
 
 
2、创建备份用户和表空间:
 
SQL> create tablespace recovery_tbs datafile 'D:\oracle\oradata\dodo\recovery_tbs.ora' size 15M autoextend on next 10M;
 
Tablespace created
 
SQL> create user rman identified by rman default tablespace recovery_tbs;
 
User created
 
SQL> grant connect,resource,recovery_catalog_owner to rman;
 
Grant succeeded
 
SQL> alter user rman quota unlimited on recovery_tbs;
 
User altered
 
 
3、登录rman:
 
①登录rman后使用connect target命令登录:
 
C:\Documents and Settings\wangxiaoqi>set oracle_sid=dodo
 
C:\Documents and Settings\wangxiaoqi>rman
 
Recovery Manager: Release 9.2.0.1.0 - Production
 
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
 
RMAN> connect target /
 
connected to target database: DODO (DBID=472976704)
 
②直接用rman命令登录:
 
C:\Documents and Settings\wangxiaoqi>rman target /
 
Recovery Manager: Release 9.2.0.1.0 - Production
 
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
 
connected to target database: DODO (DBID=472976704)
 
RMAN>
 
③链接远程数据库:
 
C:\Documents and Settings\wangxiaoqi>rman target sys/sys as sysdba @dodo2
 
Recovery Manager: Release 9.2.0.1.0 - Production
 
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
 
connected to target database: DODO2 (DBID=472976705)
 
RMAN>
 
 
4、创建恢复目录:
 
C:\Documents and Settings\wangxiaoqi>rman
 
Recovery Manager: Release 9.2.0.1.0 - Production
 
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
 
RMAN> connect catalog rman/rman
 
connected to recovery catalog database
recovery catalog is not installed
 
RMAN> create catalog;
 
recovery catalog created
 
若想把恢复目录创建到其他表空间,则使用:
RMAN> create catalog tablespace XXX;
 
删除恢复目录:
RMAN> drop catalog;
 
 
5、连接恢复目录:
 
在登录RMAN后连接:
RMAN> connect catalog rman/rman
 
connected to recovery catalog database
 
也可以直接登录时就连接:
C:\Documents and Settings\wangxiaoqi>rman target / catalog rman/rman
 
Recovery Manager: Release 9.2.0.1.0 - Production
 
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
 
connected to target database: DODO (DBID=472976704)
connected to recovery catalog database
 
RMAN>
 
不连接catalog:
C:\Documents and Settings\wangxiaoqi>rman target / nocatalog
 
Recovery Manager: Release 9.2.0.1.0 - Production
 
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
 
connected to target database: DODO (DBID=472976704)
using target database controlfile instead of recovery catalog
 
 
6、注册数据库:
 
在RMAN中有恢复目录的情况下,连接目标数据后还需要注册数据库
即将目标数据库中的控制文件转到恢复目录中
同一个恢复目录中只能注册一个目标数据库。
 
RMAN> register database;
 
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
 
 
7、使用log方式登录:
 
首先创建一个用于记录log信息的文件
然后在登录时使用:
 
C:\Documents and Settings\wangxiaoqi>rman target / log D:\oracle\oradata\dodo\logs\rman_log.txt
RMAN>
 
当使用了log时,所有的信息将不在屏幕上打印,而直接存入log文件中
所以一般操作还是不要使用log,当执行一个很长的批处理时,可能需要在log文件中记录下操作信息
 
 
 
posted on 2008-09-11 22:29 decode360 阅读(1339) 评论(0)  编辑  收藏 所属分类: 09.Recover

只有注册用户登录后才能发表评论。


网站导航: