rman總結(jié)
2024-07-21 02:40:27
供稿:網(wǎng)友
rman作為Oracle備份最為方便的工具,以下就總結(jié)幾條常用的命令,希望能方便大家,也希望可以申請(qǐng)授權(quán):
1、首先使用rman前,需要建一個(gè)目錄數(shù)據(jù)庫(kù)
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;
以上建庫(kù)和建用戶基本成功,接著:
1、rman target sys/manager@ora8 catalog rman/rman@rman
2、register database (同步數(shù)據(jù)庫(kù),假如數(shù)據(jù)庫(kù)做了alter database open resetlogs,就需要reset database,假如有庫(kù)結(jié)構(gòu)變化,就需要
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專有的格式保存,支持壓縮等等,此處就不細(xì)說(shuō)了!
5、執(zhí)行備份
run{execute script back;}
等等!
以上說(shuō)了備份數(shù)據(jù)庫(kù),下面是恢復(fù)數(shù)據(jù)庫(kù)
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操作,如有錯(cuò)誤之處,希望被指出。