全部博文(167)
分类: Oracle
2010-08-03 17:38:58
Rman是ORACLE提供的一个备份与恢复的工具,可以用来备份和还原数据库文件、归档日志和控制文件。它也可以用来执行完全或不完全的数据库恢复。现在来复习复习。
在solaris 10上重新安装了oracle 10g release 2 。
具体环境是:
SQL> startup
ORACLE instance started.
Total System Global Area 427819008 bytes
Fixed Size 1280612 bytes
Variable Size 130024860 bytes
Database Buffers 293601280 bytes
Redo Buffers 2912256 bytes
Database mounted.
Database opened.
为rman建立一个表空间
现有的表空间:
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/export/oracle/product/oradata/orcl/system01.dbf
/export/oracle/product/oradata/orcl/undotbs01.dbf
/export/oracle/product/oradata/orcl/sysaux01.dbf
/export/oracle/product/oradata/orcl/users01.dbf
/export/oracle/product/oradata/orcl/example01.dbf
新建表空间
SQL> create tablespace ora_backup datafile '/export/oracle/back_oracle' size 500M;
Tablespace created.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/export/oracle/product/oradata/orcl/system01.dbf
/export/oracle/product/oradata/orcl/undotbs01.dbf
/export/oracle/product/oradata/orcl/sysaux01.dbf
/export/oracle/product/oradata/orcl/users01.dbf
/export/oracle/product/oradata/orcl/example01.dbf
/export/oracle/back_oracle
建立rman用户、初始化其密码
SQL> create user rman identified by rman default tablespace ora_backup temporary tablespace temp ;
User created.
给rman用户赋权限
SQL> grant connect,resource,recovery_catalog_owner to rman ;
Grant succeeded.
退出sqlplus
连接到Rman进行操作
bash-3.00$ rman target 'orcl' catalog rman/rman
Recovery Manager: Release 10.2.0.2.0 - Production on Tue Aug 3 14:48:59 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
target database Password:
connected to target database: ORCL (DBID=1249795153)
connected to recovery catalog database
建立catalog表空间到ora_backup
RMAN> create catalog tablespace ora_backup
recovery catalog created
注册数据库
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
备份数据库
在这个工程中我定义了自己的channel
RMAN> run {
2> allocate channel dev1 type disk;
3> backup
4> format '/export/oracle/db_t%t_s%s_p%p'
5> (database);
6> release channel dev1;
7> }
最后提示是:
ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
!--! 晕,数据库不是归档模式
补充一下启动oracle的归档步骤
SQL> show parameter log_archive_start;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
log_archive_start boolean
FALSE
已mount的方式启动oracle
SQL> startup mount;
ORACLE instance started.
Total System Global Area 427819008 bytes
Fixed Size 1280612 bytes
Variable Size 130024860 bytes
Database Buffers 293601280 bytes
Redo Buffers 2912256 bytes
Database mounted.
启动归档模式
SQL> alter database archivelog;
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> show parameter log_archive_start;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
log_archive_start boolean
FALSE
从这可一直下次再启动数据库的时候又回到非归档模式了。所以,可以把改参数加入启动参数文件中。
执行下一句使下次启动的时候启用归档模式
SQL> alter system set log_archive_start=true scope=spfile;
System altered.
重启数据库后
SQL> show parameter log_archive_start;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
log_archive_start boolean
TRUE
另外:
如果要从归档模式变为非归档模式,使用alter database noarchivelog 命令
使用show parameter db_recovery_file_dest;查看备份文件的目录及其大小
使用show parameter log_archive_start;查看数据库是否出于自动归档模式
重备份一下,ok
附加一些查看的命令
list backup;list incarnation of database;
RMAN> show all
RMAN> show channel; // 通道分配
RMAN> show device type; // IO设备类型
RMAN> show retention policy; // 保存策略
RMAN> show datafile backup copies; // 多个备份的拷贝数目
RMAN> show maxsetsize; // 备份集大小的最大值
RMAN> show exclude; // 不必备份的表空间
RMAN> show backup optimization; // 备份的优化