將Oracle資料庫改為歸檔模式並啟用Rman備份

kuqlan發表於2017-05-18

如下Linux環境下對單節點資料庫採用檔案系統情況的配置歸檔模式過程。


首先檢視資料庫歸檔模式和磁碟使用情況,確定歸檔檔案放到什麼位置:

[oracle@gisdbserver ~]$ sqlplus / as sysdba

SQL> archive log list

Database log mode              No Archive Mode

Automatic archival             Disabled

Archive destination            /dbback/archivelog

Oldest online log sequence     92

Current log sequence           97




根據如下磁碟使用情況,在相應的目錄下建立相關歸檔和備份目錄:

[root@gisdbserver ~]# df -h

Filesystem                           Size  Used Avail Use% Mounted on

/dev/mapper/vg_gisdbserver-lv_root    99G  3.8G   90G   4% /

tmpfs                                 16G   76K   16G   1% /dev/shm

/dev/sda2                            485M   39M  421M   9% /boot

/dev/sda1                            200M  260K  200M   1% /boot/efi

/dev/mapper/vg_gisdbserver-LogVol03  481G  198M  457G   1% /dbback

/dev/mapper/vg_gisdbserver-LogVol04  407G  9.3G  377G   3% /home

/dev/mapper/vg_gisdbserver-LogVol02   99G  4.5G   89G   5% /opt

/dev/sdb                             441G   72G  347G  18% /oradata


建立相關歸檔日誌存放目錄:


[root@gisdbserver ~]# cd /dbback/

[root@gisdbserver dbback]# mkdir archivelog

[root@gisdbserver dbback]# chown -R oracle:oinstall archivelog/

[root@gisdbserver dbback]# mkdir rman

[root@gisdbserver dbback]# chown oracle:oinstall rman/

[root@gisdbserver rman]# mkdir fullback

[root@gisdbserver rman]# mkdir archiveback

[root@gisdbserver rman]# chown oracle:oinstall archiveback/

[root@gisdbserver rman]# chown oracle:oinstall fullback/


登入資料庫指定歸檔存放目錄:


[oracle@gisdbserver ~]$ sqlplus / as sysdba

SQL> alter system set log_archive_dest_1='location=/dbback/archivelog';

System altered.

SQL> show parameter log_archive_dest_1

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

log_archive_dest_1                   string      location=/dbback/archivelog



要將非歸檔資料庫模式改為歸檔模式,需要在mount狀態下執行alter database archivelog命令才行,如下:


SQL> archive log list

Database log mode              No Archive Mode

Automatic archival             Disabled

Archive destination            /dbback/archivelog

Oldest online log sequence     92

Current log sequence           97


SQL> alter database archivelog;

alter database archivelog

*

ERROR at line 1:

ORA-01126: database must be mounted in this instance and not open in any

instance


因此需要在合適的時間關閉資料庫,重新啟動到mount狀態下才能改變為歸檔模式。

SQL> shutdown immediate;

SQL> startup mount;


SQL> alter database archivelog;



要開啟rman備份,需要對配置rman相關的一些引數,具體如下:

oracle@gisdbserver ~]$ rman target /

RMAN> backup DATABASE include CURRENT controlfile format '/dbback/rman/fullback/data_%d_%T_%s_%p' plus archivelog format '+/dbback/rman/archiveback/arch_%d_%T_%s';


以上語句也可以透過linuxcrontab bash指令碼方式進行自動化執行。



run{

 DELETE NOPROMPT expired archivelog ALL;

 allocate channel d1 TYPE disk maxpiecesize=30G;

 allocate channel d2 TYPE disk maxpiecesize=30G;

backup DATABASE include CURRENT controlfile format '/dbback/rman/fullback/data_%d_%T_%s_%p' plus archivelog       format '+/dbback/rman/archiveback/arch_%d_%T_%s';

 release channel d1;

 release channel d2;

 crosscheck backup;

 DELETE noprompt obsolete REDUNDANCY 1;

}



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18841027/viewspace-2139272/,如需轉載,請註明出處,否則將追究法律責任。

相關文章