rman作为oracle备份最为方便的工具,以下就总结几条常用的命令,希望能方便大家,也希望可以申请授权:
1、首先使用rman前,需要建一个目录数据库
2、create tablespce rman datafile '/data/oradata/test/rman.dbf' size 20m;
3、create user rman identified by rman default tablespace rman temporary tablespace temp;
4、grant connect,resource,recovery_catalog_ower to rman;
以上建库和建用户基本成功,接着:
1、rman target sys/manager@ora8 catalog rman/rman@rman
2、register database (同步数据库,如果数据库做了alter database open resetlogs,就需要reset database,如果有库结构变化,就需要
resync catalog)
3、create script back {
allocate channel n1 type disk;
backup database
format '/data/backup/ora8_%d_%s_%p';
release channel n1;}
4、如果是备份固定的文件或表空间也可以
create script back_file{
allocate channel n1 type disk;
copy
datafile 4 to '/data/backup/users.dbf';
release channel n1;}
create script back_tablespace{
allocate channel m1 type disk;
backup tablespace users
format '/data/backup/users_%t_%s_%p';
release channel n1;}
使用copy就是文件镜像保存,使用backup就是用oracle专有的格式保存,支持压缩等等,此处就不细说了!
5、执行备份
run{execute script back;}
等等!
以上说了备份数据库,下面是恢复数据库
1、rman target sys/manager@ora8 catalog rman/rman@rman
2、run{
allcote channel n1 type disk;
sql "alter tablespce users offline immediate";
restore tablespace users;
recover tablespace users;
sql "alter tablespace user online";
release channel n1;}
3、run{
allocate channel n1 type disk;
restore database;
recover database;
sql "alter database open resetlogs";
release channel n1;}
4、run{
allocate channel n1 type disk;
restore datafile 4;
release channel n1;}
以上都是一些基本的rman操作,如有错误之处,希望被指出。