Oracle的RMAN備份方法

來源:互聯網
上載者:User

1、切換伺服器歸檔模式,如果已經是歸檔模式可跳過此步:
%sqlplus /nolog (啟動sqlplus)
SQL> conn / as sysdba (以DBA身份串連資料庫)
SQL> shutdown immediate; (立即關閉資料庫)
SQL> startup mount (啟動執行個體並載入資料庫,但不開啟)
SQL> alter database archivelog; (更改資料庫為歸檔模式)
SQL> alter database open; (開啟資料庫)
SQL> alter system archive log start; (啟用自動歸檔)
SQL> exit (退出)

2、建立recovery catalog db資料庫的相關內容

a,建好catalog庫並建catalog資料表空間
  SQL> create tablespace tbs_rman datafile 'd:/Oracle/product/10.1.0/oradata/wind/rman.dbf' size 200M;

b,建好管理catalog的rman的user,並給recovery_catalog_owner許可權:
SQL>create user rmanuser identified by rmanuser
    temporary tablespace TEMP
    default tablespace tbs_rman
    quota unlimited on tbs_rman;

c,分配許可權
SQL> grant recovery_catalog_owner to rmanuser;


3.建立 catalog

#有些時候直接使用rman linux會認為是他本身的命令,所以加入全路徑比較保險
>$ORACLE_HOME/bin/rman

RMAN> connect catalog rmanuser/rmanuser@rman_db;

RMAN> create catalog;  ##這句就是把 userrman 的預設資料表空間分配給 catalog;

RMAN> create catalog tablespace tbs_catalog;##如果user_rman有預設資料表空間那麼就不需要這句

##如果想刪除catalog可以使用兩邊 RMAN>drop catalog;     RMAN>drop catalog;

將目標資料庫註冊到catalog
RMAN> register database;


4.配置NFS

查看nfs服務是否啟動   service nfs status
啟動nfs               service nfs start

vim /etc/exports

/oracle/rmanbak 10.1.50.81(rw,no_root_squash)

在target伺服器上掛載遠程備份目錄
關於備份路徑的掛載點是有要求的,而且參數上也有要求如下,掛載在 $ORACLE_HOME目錄及其父目錄下

mount -o rw,bg,intr,hard,timeo=600,wsize=32768,rsize=32768 -t nfs 10.1.50.80:/oracle/rmanbak /home/oracle/rmanbak


5.開始備份

做一個全庫備份

run{
allocate channel d1 type disk;
backup as compressed backupset
format='/home/oracle/rmanbak/full_%d_%u_%s_%p'
tag='fullbak'
channel=d1
database plus archivelog delete input;
release channel d1;
}


增量備份 0
run{
allocate channel d1 device type disk;
backup as compressed backupset
incremental level=0
format='/home/oracle/rmanbak/inc0_%d_%u_%s_%p'
tag='inc0'
channel=d1
database plus archivelog delete input;
release channel d1;
}

增量備份 1
run{
allocate channel d1 device type disk;
backup as compressed backupset
incremental level=1
format='/home/oracle/rmanbak/inc1_%d_%u_%s_%p'
tag='inc1'
channel=d1
database plus archivelog delete input;
release channel d1;
}


資料表空間
run{
allocate channel d1 device type disk;
backup as compressed backupset
format='/home/oracle/rmanbak/tbs_%d_%u_%s_%p'
tag='tbs'
channel=d1
tablespace users;
release channel d1;
}


//


///
crontab

 

//delete expired copy
//list backup by files;
//umount -l /mnt/rmanbak
//crosscheck backupset
//validate backupset
//delete expixed backupset
//delete backupset of database device type disk completed between 'sysdate-1' and 'sysdate+1
//delete noprompt obsolete recovery window of 0 days
//
set limit channel '' readrate
set limit channel '' kbytes

  • 1
  • 2
  • 下一頁

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.